svn commit: r260065 - stable/9/sys/sparc64/include

Marius Strobl marius at FreeBSD.org
Mon Dec 30 00:43:24 UTC 2013


Author: marius
Date: Mon Dec 30 00:43:24 2013
New Revision: 260065
URL: http://svnweb.freebsd.org/changeset/base/260065

Log:
  MFC: r255937
  
  Implement GET_STACK_USAGE.
  Discussed with:	mav

Modified:
  stable/9/sys/sparc64/include/proc.h
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/sparc64/include/proc.h
==============================================================================
--- stable/9/sys/sparc64/include/proc.h	Sun Dec 29 23:46:59 2013	(r260064)
+++ stable/9/sys/sparc64/include/proc.h	Mon Dec 30 00:43:24 2013	(r260065)
@@ -55,6 +55,17 @@ struct mdproc {
 
 #ifdef _KERNEL
 
+#include <machine/pcb.h>
+
+/* Get the current kernel thread stack usage. */
+#define	GET_STACK_USAGE(total, used) do {				\
+	struct thread *td = curthread;					\
+	(total) = td->td_kstack_pages * PAGE_SIZE - sizeof(struct pcb);	\
+	(used) = (char *)td->td_kstack +				\
+	    td->td_kstack_pages * PAGE_SIZE -				\
+	    (char *)&td;						\
+} while (0)
+
 struct syscall_args {
 	u_int code;
 	struct sysent *callp;


More information about the svn-src-all mailing list