svn commit: r324377 - in head: share/man/man9 sys/kern sys/sys

Mark Johnston markj at FreeBSD.org
Fri Oct 6 21:52:30 UTC 2017


Author: markj
Date: Fri Oct  6 21:52:28 2017
New Revision: 324377
URL: https://svnweb.freebsd.org/changeset/base/324377

Log:
  Let stack_create(9) take a malloc flags argument.
  
  Reviewed by:	cem
  Sponsored by:	Dell EMC Isilon
  Differential Revision:	https://reviews.freebsd.org/D12614

Modified:
  head/share/man/man9/stack.9
  head/sys/kern/kern_proc.c
  head/sys/kern/subr_sleepqueue.c
  head/sys/kern/subr_stack.c
  head/sys/sys/stack.h

Modified: head/share/man/man9/stack.9
==============================================================================
--- head/share/man/man9/stack.9	Fri Oct  6 20:51:32 2017	(r324376)
+++ head/share/man/man9/stack.9	Fri Oct  6 21:52:28 2017	(r324377)
@@ -27,7 +27,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd September 10, 2015
+.Dd October 6, 2017
 .Dt STACK 9
 .Os
 .Sh NAME
@@ -42,7 +42,7 @@ In the kernel configuration file:
 .Cd "options STACK"
 .Pp
 .Ft struct stack *
-.Fn stack_create "void"
+.Fn stack_create "int flags"
 .Ft void
 .Fn stack_destroy "struct stack *st"
 .Ft int
@@ -85,8 +85,11 @@ Each stack trace is described by a
 .Vt "struct stack" .
 Before a trace may be created or otherwise manipulated, storage for the trace
 must be allocated with
-.Fn stack_create ,
-which may sleep.
+.Fn stack_create .
+The
+.Ar flags
+argument is passed to
+.Xr malloc 9 .
 Memory associated with a trace is freed by calling
 .Fn stack_destroy .
 .Pp

Modified: head/sys/kern/kern_proc.c
==============================================================================
--- head/sys/kern/kern_proc.c	Fri Oct  6 20:51:32 2017	(r324376)
+++ head/sys/kern/kern_proc.c	Fri Oct  6 21:52:28 2017	(r324377)
@@ -2547,7 +2547,7 @@ sysctl_kern_proc_kstack(SYSCTL_HANDLER_ARGS)
 		return (error);
 
 	kkstp = malloc(sizeof(*kkstp), M_TEMP, M_WAITOK);
-	st = stack_create();
+	st = stack_create(M_WAITOK);
 
 	lwpidarray = NULL;
 	PROC_LOCK(p);

Modified: head/sys/kern/subr_sleepqueue.c
==============================================================================
--- head/sys/kern/subr_sleepqueue.c	Fri Oct  6 20:51:32 2017	(r324376)
+++ head/sys/kern/subr_sleepqueue.c	Fri Oct  6 21:52:28 2017	(r324377)
@@ -1163,7 +1163,7 @@ sleepq_sbuf_print_stacks(struct sbuf *sb, void *wchan,
 		    M_TEMP, M_WAITOK);
 		for (stack_idx = 0; stack_idx < stacks_to_allocate;
 		    stack_idx++)
-			st[stack_idx] = stack_create();
+			st[stack_idx] = stack_create(M_WAITOK);
 
 		/* Where we will store the td name, tid, etc. */
 		td_infos = malloc(sizeof(struct sbuf *) * stacks_to_allocate,

Modified: head/sys/kern/subr_stack.c
==============================================================================
--- head/sys/kern/subr_stack.c	Fri Oct  6 20:51:32 2017	(r324376)
+++ head/sys/kern/subr_stack.c	Fri Oct  6 21:52:28 2017	(r324377)
@@ -50,11 +50,11 @@ static int stack_symbol(vm_offset_t pc, char *namebuf,
 static int stack_symbol_ddb(vm_offset_t pc, const char **name, long *offset);
 
 struct stack *
-stack_create(void)
+stack_create(int flags)
 {
 	struct stack *st;
 
-	st = malloc(sizeof *st, M_STACK, M_WAITOK | M_ZERO);
+	st = malloc(sizeof(*st), M_STACK, flags | M_ZERO);
 	return (st);
 }
 

Modified: head/sys/sys/stack.h
==============================================================================
--- head/sys/sys/stack.h	Fri Oct  6 20:51:32 2017	(r324376)
+++ head/sys/sys/stack.h	Fri Oct  6 21:52:28 2017	(r324377)
@@ -34,7 +34,7 @@
 struct sbuf;
 
 /* MI Routines. */
-struct stack	*stack_create(void);
+struct stack	*stack_create(int);
 void		 stack_destroy(struct stack *);
 int		 stack_put(struct stack *, vm_offset_t);
 void		 stack_copy(const struct stack *, struct stack *);


More information about the svn-src-head mailing list