aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2009-11-19 13:10:51 -0500
committerDavid Howells <dhowells@redhat.com>2009-11-19 13:10:51 -0500
commit8fba10a42d191de612e60e7009c8f0313f90a9b3 (patch)
tree1e772fcc7ad3eb5bb3ca1c6cd156171295e6db25
parent6b8268b17a1ffc942bc72d7d00274e433d6b6719 (diff)
SLOW_WORK: Allow the work items to be viewed through a /proc file
Allow the executing and queued work items to be viewed through a /proc file for debugging purposes. The contents look something like the following: THR PID ITEM ADDR FL MARK DESC === ===== ================ == ===== ========== 0 3005 ffff880023f52348 a 952ms FSC: OBJ17d3: LOOK 1 3006 ffff880024e33668 2 160ms FSC: OBJ17e5 OP60d3b: Write1/Store fl=2 2 3165 ffff8800296dd180 a 424ms FSC: OBJ17e4: LOOK 3 4089 ffff8800262c8d78 a 212ms FSC: OBJ17ea: CRTN 4 4090 ffff88002792bed8 2 388ms FSC: OBJ17e8 OP60d36: Write1/Store fl=2 5 4092 ffff88002a0ef308 2 388ms FSC: OBJ17e7 OP60d2e: Write1/Store fl=2 6 4094 ffff88002abaf4b8 2 132ms FSC: OBJ17e2 OP60d4e: Write1/Store fl=2 7 4095 ffff88002bb188e0 a 388ms FSC: OBJ17e9: CRTN vsq - ffff880023d99668 1 308ms FSC: OBJ17e0 OP60f91: Write1/EnQ fl=2 vsq - ffff8800295d1740 1 212ms FSC: OBJ16be OP4d4b6: Write1/EnQ fl=2 vsq - ffff880025ba3308 1 160ms FSC: OBJ179a OP58dec: Write1/EnQ fl=2 vsq - ffff880024ec83e0 1 160ms FSC: OBJ17ae OP599f2: Write1/EnQ fl=2 vsq - ffff880026618e00 1 160ms FSC: OBJ17e6 OP60d33: Write1/EnQ fl=2 vsq - ffff880025a2a4b8 1 132ms FSC: OBJ16a2 OP4d583: Write1/EnQ fl=2 vsq - ffff880023cbe6d8 9 212ms FSC: OBJ17eb: LOOK vsq - ffff880024d37590 9 212ms FSC: OBJ17ec: LOOK vsq - ffff880027746cb0 9 212ms FSC: OBJ17ed: LOOK vsq - ffff880024d37ae8 9 212ms FSC: OBJ17ee: LOOK vsq - ffff880024d37cb0 9 212ms FSC: OBJ17ef: LOOK vsq - ffff880025036550 9 212ms FSC: OBJ17f0: LOOK vsq - ffff8800250368e0 9 212ms FSC: OBJ17f1: LOOK vsq - ffff880025036aa8 9 212ms FSC: OBJ17f2: LOOK In the 'THR' column, executing items show the thread they're occupying and queued threads indicate which queue they're on. 'PID' shows the process ID of a slow-work thread that's executing something. 'FL' shows the work item flags. 'MARK' indicates how long since an item was queued or began executing. Lastly, the 'DESC' column permits the owner of an item to give some information. Signed-off-by: David Howells <dhowells@redhat.com>
-rw-r--r--Documentation/slow-work.txt60
-rw-r--r--include/linux/slow-work.h11
-rw-r--r--init/Kconfig10
-rw-r--r--kernel/Makefile1
-rw-r--r--kernel/slow-work-proc.c227
-rw-r--r--kernel/slow-work.c44
-rw-r--r--kernel/slow-work.h72
7 files changed, 413 insertions, 12 deletions
diff --git a/Documentation/slow-work.txt b/Documentation/slow-work.txt
index a9d1b0ffdded..f120238e70fe 100644
--- a/Documentation/slow-work.txt
+++ b/Documentation/slow-work.txt
@@ -149,7 +149,8 @@ ITEM OPERATIONS
149=============== 149===============
150 150
151Each work item requires a table of operations of type struct slow_work_ops. 151Each work item requires a table of operations of type struct slow_work_ops.
152Only ->execute() is required, getting and putting of a reference are optional. 152Only ->execute() is required; the getting and putting of a reference and the
153describing of an item are all optional.
153 154
154 (*) Get a reference on an item: 155 (*) Get a reference on an item:
155 156
@@ -179,6 +180,16 @@ Only ->execute() is required, getting and putting of a reference are optional.
179 This should perform the work required of the item. It may sleep, it may 180 This should perform the work required of the item. It may sleep, it may
180 perform disk I/O and it may wait for locks. 181 perform disk I/O and it may wait for locks.
181 182
183 (*) View an item through /proc:
184
185 void (*desc)(struct slow_work *work, struct seq_file *m);
186
187 If supplied, this should print to 'm' a small string describing the work
188 the item is to do. This should be no more than about 40 characters, and
189 shouldn't include a newline character.
190
191 See the 'Viewing executing and queued items' section below.
192
182 193
183================== 194==================
184POOL CONFIGURATION 195POOL CONFIGURATION
@@ -203,3 +214,50 @@ The slow-work thread pool has a number of configurables:
203 is bounded to between 1 and one fewer than the number of active threads. 214 is bounded to between 1 and one fewer than the number of active threads.
204 This ensures there is always at least one thread that can process very 215 This ensures there is always at least one thread that can process very
205 slow work items, and always at least one thread that won't. 216 slow work items, and always at least one thread that won't.
217
218
219==================================
220VIEWING EXECUTING AND QUEUED ITEMS
221==================================
222
223If CONFIG_SLOW_WORK_PROC is enabled, a proc file is made available:
224
225 /proc/slow_work_rq
226
227through which the list of work items being executed and the queues of items to
228be executed may be viewed. The owner of a work item is given the chance to
229add some information of its own.
230
231The contents look something like the following:
232
233 THR PID ITEM ADDR FL MARK DESC
234 === ===== ================ == ===== ==========
235 0 3005 ffff880023f52348 a 952ms FSC: OBJ17d3: LOOK
236 1 3006 ffff880024e33668 2 160ms FSC: OBJ17e5 OP60d3b: Write1/Store fl=2
237 2 3165 ffff8800296dd180 a 424ms FSC: OBJ17e4: LOOK
238 3 4089 ffff8800262c8d78 a 212ms FSC: OBJ17ea: CRTN
239 4 4090 ffff88002792bed8 2 388ms FSC: OBJ17e8 OP60d36: Write1/Store fl=2
240 5 4092 ffff88002a0ef308 2 388ms FSC: OBJ17e7 OP60d2e: Write1/Store fl=2
241 6 4094 ffff88002abaf4b8 2 132ms FSC: OBJ17e2 OP60d4e: Write1/Store fl=2
242 7 4095 ffff88002bb188e0 a 388ms FSC: OBJ17e9: CRTN
243 vsq - ffff880023d99668 1 308ms FSC: OBJ17e0 OP60f91: Write1/EnQ fl=2
244 vsq - ffff8800295d1740 1 212ms FSC: OBJ16be OP4d4b6: Write1/EnQ fl=2
245 vsq - ffff880025ba3308 1 160ms FSC: OBJ179a OP58dec: Write1/EnQ fl=2
246 vsq - ffff880024ec83e0 1 160ms FSC: OBJ17ae OP599f2: Write1/EnQ fl=2
247 vsq - ffff880026618e00 1 160ms FSC: OBJ17e6 OP60d33: Write1/EnQ fl=2
248 vsq - ffff880025a2a4b8 1 132ms FSC: OBJ16a2 OP4d583: Write1/EnQ fl=2
249 vsq - ffff880023cbe6d8 9 212ms FSC: OBJ17eb: LOOK
250 vsq - ffff880024d37590 9 212ms FSC: OBJ17ec: LOOK
251 vsq - ffff880027746cb0 9 212ms FSC: OBJ17ed: LOOK
252 vsq - ffff880024d37ae8 9 212ms FSC: OBJ17ee: LOOK
253 vsq - ffff880024d37cb0 9 212ms FSC: OBJ17ef: LOOK
254 vsq - ffff880025036550 9 212ms FSC: OBJ17f0: LOOK
255 vsq - ffff8800250368e0 9 212ms FSC: OBJ17f1: LOOK
256 vsq - ffff880025036aa8 9 212ms FSC: OBJ17f2: LOOK
257
258In the 'THR' column, executing items show the thread they're occupying and
259queued threads indicate which queue they're on. 'PID' shows the process ID of
260a slow-work thread that's executing something. 'FL' shows the work item flags.
261'MARK' indicates how long since an item was queued or began executing. Lastly,
262the 'DESC' column permits the owner of an item to give some information.
263
diff --git a/include/linux/slow-work.h b/include/linux/slow-work.h
index b245b9a9cc0b..f41485145ed1 100644
--- a/include/linux/slow-work.h
+++ b/include/linux/slow-work.h
@@ -20,6 +20,9 @@
20#include <linux/timer.h> 20#include <linux/timer.h>
21 21
22struct slow_work; 22struct slow_work;
23#ifdef CONFIG_SLOW_WORK_PROC
24struct seq_file;
25#endif
23 26
24/* 27/*
25 * The operations used to support slow work items 28 * The operations used to support slow work items
@@ -38,6 +41,11 @@ struct slow_work_ops {
38 41
39 /* execute a work item */ 42 /* execute a work item */
40 void (*execute)(struct slow_work *work); 43 void (*execute)(struct slow_work *work);
44
45#ifdef CONFIG_SLOW_WORK_PROC
46 /* describe a work item for /proc */
47 void (*desc)(struct slow_work *work, struct seq_file *m);
48#endif
41}; 49};
42 50
43/* 51/*
@@ -56,6 +64,9 @@ struct slow_work {
56#define SLOW_WORK_DELAYED 5 /* item is struct delayed_slow_work with active timer */ 64#define SLOW_WORK_DELAYED 5 /* item is struct delayed_slow_work with active timer */
57 const struct slow_work_ops *ops; /* operations table for this item */ 65 const struct slow_work_ops *ops; /* operations table for this item */
58 struct list_head link; /* link in queue */ 66 struct list_head link; /* link in queue */
67#ifdef CONFIG_SLOW_WORK_PROC
68 struct timespec mark; /* jiffies at which queued or exec begun */
69#endif
59}; 70};
60 71
61struct delayed_slow_work { 72struct delayed_slow_work {
diff --git a/init/Kconfig b/init/Kconfig
index 9e03ef8b311e..ab5c64801fe5 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1098,6 +1098,16 @@ config SLOW_WORK
1098 1098
1099 See Documentation/slow-work.txt. 1099 See Documentation/slow-work.txt.
1100 1100
1101config SLOW_WORK_PROC
1102 bool "Slow work debugging through /proc"
1103 default n
1104 depends on SLOW_WORK && PROC_FS
1105 help
1106 Display the contents of the slow work run queue through /proc,
1107 including items currently executing.
1108
1109 See Documentation/slow-work.txt.
1110
1101endmenu # General setup 1111endmenu # General setup
1102 1112
1103config HAVE_GENERIC_DMA_COHERENT 1113config HAVE_GENERIC_DMA_COHERENT
diff --git a/kernel/Makefile b/kernel/Makefile
index b8d4cd8ac0b9..776ffed1556d 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -94,6 +94,7 @@ obj-$(CONFIG_X86_DS) += trace/
94obj-$(CONFIG_RING_BUFFER) += trace/ 94obj-$(CONFIG_RING_BUFFER) += trace/
95obj-$(CONFIG_SMP) += sched_cpupri.o 95obj-$(CONFIG_SMP) += sched_cpupri.o
96obj-$(CONFIG_SLOW_WORK) += slow-work.o 96obj-$(CONFIG_SLOW_WORK) += slow-work.o
97obj-$(CONFIG_SLOW_WORK_PROC) += slow-work-proc.o
97obj-$(CONFIG_PERF_EVENTS) += perf_event.o 98obj-$(CONFIG_PERF_EVENTS) += perf_event.o
98 99
99ifneq ($(CONFIG_SCHED_OMIT_FRAME_POINTER),y) 100ifneq ($(CONFIG_SCHED_OMIT_FRAME_POINTER),y)
diff --git a/kernel/slow-work-proc.c b/kernel/slow-work-proc.c
new file mode 100644
index 000000000000..3988032571f5
--- /dev/null
+++ b/kernel/slow-work-proc.c
@@ -0,0 +1,227 @@
1/* Slow work debugging
2 *
3 * Copyright (C) 2009 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
10 */
11
12#include <linux/module.h>
13#include <linux/slow-work.h>
14#include <linux/fs.h>
15#include <linux/time.h>
16#include <linux/seq_file.h>
17#include "slow-work.h"
18</