fail(9): Only gather/print stacks if STACK is enabled

This is a follow-up fix to the earlier r296927.

Reported by:	bz
Sponsored by:	EMC / Isilon Storage Division
This commit is contained in:
Conrad Meyer 2016-03-17 01:05:53 +00:00
parent 342f335141
commit 82e17adcb4
3 changed files with 12 additions and 1 deletions

View File

@ -52,6 +52,8 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include "opt_stack.h"
#include <sys/ctype.h>
#include <sys/errno.h>
#include <sys/fail.h>
@ -708,6 +710,7 @@ fail_point_get(struct fail_point *fp, struct sbuf *sb,
fp_free(fp_entry_cpy);
if (verbose) {
#ifdef STACK
/* Print number of sleeping threads. queue=0 is the argument
* used by msleep when sending our threads to sleep. */
sbuf_printf(sb, "\nsleeping_thread_stacks = {\n");
@ -715,14 +718,17 @@ fail_point_get(struct fail_point *fp, struct sbuf *sb,
&cnt_sleeping);
sbuf_printf(sb, "},\n");
#endif
sbuf_printf(sb, "sleeping_thread_count = %d,\n",
cnt_sleeping);
#ifdef STACK
sbuf_printf(sb, "paused_thread_stacks = {\n");
sleepq_sbuf_print_stacks(sb, FP_PAUSE_CHANNEL(fp), 0,
&cnt_sleeping);
sbuf_printf(sb, "},\n");
#endif
sbuf_printf(sb, "paused_thread_count = %d\n",
cnt_sleeping);
}

View File

@ -62,6 +62,7 @@ __FBSDID("$FreeBSD$");
#include "opt_sleepqueue_profiling.h"
#include "opt_ddb.h"
#include "opt_sched.h"
#include "opt_stack.h"
#include <sys/param.h>
#include <sys/systm.h>
@ -1042,6 +1043,7 @@ sleepq_abort(struct thread *td, int intrval)
* printed. Typically, this will equal the number of threads sleeping on the
* queue, but may be less if sb overflowed before all stacks were printed.
*/
#ifdef STACK
int
sleepq_sbuf_print_stacks(struct sbuf *sb, void *wchan, int queue,
int *count_stacks_printed)
@ -1149,6 +1151,7 @@ sleepq_sbuf_print_stacks(struct sbuf *sb, void *wchan, int queue,
return (error);
}
#endif
#ifdef SLEEPQUEUE_PROFILING
#define SLEEPQ_PROF_LOCATIONS 1024

View File

@ -107,9 +107,11 @@ int sleepq_type(void *wchan);
void sleepq_wait(void *wchan, int pri);
int sleepq_wait_sig(void *wchan, int pri);
#include <sys/sbuf.h>
#ifdef STACK
struct sbuf;
int sleepq_sbuf_print_stacks(struct sbuf *sb, void *wchan, int queue,
int *count_stacks_printed);
#endif
#endif /* _KERNEL */
#endif /* !_SYS_SLEEPQUEUE_H_ */