Skip to contentSkip to conversation

SLOW_WORK: Move slow_work's proc file to debugfs

PATCH In review David Howells 3 participants 5 messages Dec 1, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 SLOW_WORK: Move slow_work's proc file to debugfs

Move slow_work's debugging proc file to debugfs.

---

 Documentation/slow-work.txt |    4 -
 include/linux/slow-work.h   |    8 +-
 init/Kconfig                |    8 +-
 kernel/Makefile             |    2 
 kernel/slow-work-debugfs.c  |  227 +++++++++++++++++++++++++++++++++++++++++++
 kernel/slow-work-proc.c     |  227 -------------------------------------------
 kernel/slow-work.c          |   18 ++-
 kernel/slow-work.h          |    6 +
 8 files changed, 253 insertions(+), 247 deletions(-)
 create mode 100644 kernel/slow-work-debugfs.c
 delete mode 100644 kernel/slow-work-proc.c
Documentation/slow-work.txt +2 -2
index 52bc314..9dbf447 100644
@@ -279,9 +279,9 @@ The slow-work thread pool has a number of configurables:
 VIEWING EXECUTING AND QUEUED ITEMS
 ==================================
 
-If CONFIG_SLOW_WORK_PROC is enabled, a proc file is made available:
+If CONFIG_SLOW_WORK_DEBUG is enabled, a debugfs file is made available:
 
-	/proc/slow_work_rq
+	/sys/kernel/debug/slow_work/runqueue
 
 through which the list of work items being executed and the queues of items to
 be executed may be viewed.  The owner of a work item is given the chance to
include/linux/slow-work.h +4 -4
index 5035a26..13337bf 100644
@@ -20,7 +20,7 @@
 #include <linux/timer.h>
 
 struct slow_work;
-#ifdef CONFIG_SLOW_WORK_PROC
+#ifdef CONFIG_SLOW_WORK_DEBUG
 struct seq_file;
 #endif
 
@@ -42,8 +42,8 @@ struct slow_work_ops {
 	/* execute a work item */
 	void (*execute)(struct slow_work *work);
 
-#ifdef CONFIG_SLOW_WORK_PROC
-	/* describe a work item for /proc */
+#ifdef CONFIG_SLOW_WORK_DEBUG
+	/* describe a work item for debugfs */
 	void (*desc)(struct slow_work *work, struct seq_file *m);
 #endif
 };
@@ -64,7 +64,7 @@ struct slow_work {
 #define SLOW_WORK_DELAYED	5	/* item is struct delayed_slow_work with active timer */
 	const struct slow_work_ops *ops; /* operations table for this item */
 	struct list_head	link;	/* link in queue */
-#ifdef CONFIG_SLOW_WORK_PROC
+#ifdef CONFIG_SLOW_WORK_DEBUG
 	struct timespec		mark;	/* jiffies at which queued or exec begun */
 #endif
 };
init/Kconfig +4 -4
index ab5c648..39923cc 100644
@@ -1098,12 +1098,12 @@ config SLOW_WORK
 
 	  See Documentation/slow-work.txt.
 
-config SLOW_WORK_PROC
-	bool "Slow work debugging through /proc"
+config SLOW_WORK_DEBUG
+	bool "Slow work debugging through debugfs"
 	default n
-	depends on SLOW_WORK && PROC_FS
+	depends on SLOW_WORK && DEBUG_FS
 	help
-	  Display the contents of the slow work run queue through /proc,
+	  Display the contents of the slow work run queue through debugfs,
 	  including items currently executing.
 
 	  See Documentation/slow-work.txt.
kernel/Makefile +1 -1
index 776ffed..d7c13d2 100644
@@ -94,7 +94,7 @@ obj-$(CONFIG_X86_DS) += trace/
 obj-$(CONFIG_RING_BUFFER) += trace/
 obj-$(CONFIG_SMP) += sched_cpupri.o
 obj-$(CONFIG_SLOW_WORK) += slow-work.o
-obj-$(CONFIG_SLOW_WORK_PROC) += slow-work-proc.o
+obj-$(CONFIG_SLOW_WORK_DEBUG) += slow-work-debugfs.o
 obj-$(CONFIG_PERF_EVENTS) += perf_event.o
 
 ifneq ($(CONFIG_SCHED_OMIT_FRAME_POINTER),y)
kernel/slow-work-debugfs.c new file +227 -0

227 lines not on this page · raw message

kernel/slow-work-proc.c deleted +0 -227

227 lines not on this page · raw message

kernel/slow-work.c +12 -6
index b5c17f1..00889bd 100644
@@ -16,7 +16,7 @@
 #include <linux/kthread.h>
 #include <linux/freezer.h>
 #include <linux/wait.h>
-#include <linux/proc_fs.h>
+#include <linux/debugfs.h>
 #include "slow-work.h"
 
 static void slow_work_cull_timeout(unsigned long);
@@ -138,7 +138,7 @@ static void slow_work_clear_thread_processing(int id) {}
 /*
  * Data for tracking currently executing items for indication through /proc
  */
-#ifdef CONFIG_SLOW_WORK_PROC
+#ifdef CONFIG_SLOW_WORK_DEBUG
 struct slow_work *slow_work_execs[SLOW_WORK_THREAD_LIMIT];
 pid_t slow_work_pids[SLOW_WORK_THREAD_LIMIT];
 DEFINE_RWLOCK(slow_work_execs_lock);
@@ -823,7 +823,7 @@ static void slow_work_new_thread_execute(struct slow_work *work)
 static const struct slow_work_ops slow_work_new_thread_ops = {
 	.owner		= THIS_MODULE,
 	.execute	= slow_work_new_thread_execute,
-#ifdef CONFIG_SLOW_WORK_PROC
+#ifdef CONFIG_SLOW_WORK_DEBUG
 	.desc		= slow_work_new_thread_desc,
 #endif
 };
@@ -1055,9 +1055,15 @@ static int __init init_slow_work(void)
 	if (slow_work_max_max_threads < nr_cpus * 2)
 		slow_work_max_max_threads = nr_cpus * 2;
 #endif
-#ifdef CONFIG_SLOW_WORK_PROC
-	proc_create("slow_work_rq", S_IFREG | 0400, NULL,
-		    &slow_work_runqueue_fops);
+#ifdef CONFIG_SLOW_WORK_DEBUG
+	{
+		struct dentry *dbdir;
+
+		dbdir = debugfs_create_dir("slow_work", NULL);
+		if (dbdir && !IS_ERR(dbdir))
+			debugfs_create_file("runqueue", S_IFREG | 0400, dbdir,
+					    NULL, &slow_work_runqueue_fops);
+	}
 #endif
 	return 0;
 }
kernel/slow-work.h +3 -3
index 3c2f007..321f3c5 100644
@@ -19,7 +19,7 @@
 /*
  * slow-work.c
  */
-#ifdef CONFIG_SLOW_WORK_PROC
+#ifdef CONFIG_SLOW_WORK_DEBUG
 extern struct slow_work *slow_work_execs[];
 extern pid_t slow_work_pids[];
 extern rwlock_t slow_work_execs_lock;
@@ -30,9 +30,9 @@ extern struct list_head vslow_work_queue;
 extern spinlock_t slow_work_queue_lock;
 
 /*
- * slow-work-proc.c
+ * slow-work-debugfs.c
  */
-#ifdef CONFIG_SLOW_WORK_PROC
+#ifdef CONFIG_SLOW_WORK_DEBUG
 extern const struct file_operations slow_work_runqueue_fops;
 
 extern void slow_work_new_thread_desc(struct slow_work *, struct seq_file *);
#1 lore raw
Quoted 5 lines · David Howells

Move slow_work's debugging proc file to debugfs.

---

Quoted 11 lines
 Documentation/slow-work.txt |    4 -
 include/linux/slow-work.h   |    8 +-
 init/Kconfig                |    8 +-
 kernel/Makefile             |    2 
 kernel/slow-work-debugfs.c  |  227 +++++++++++++++++++++++++++++++++++++++++++
 kernel/slow-work-proc.c     |  227 -------------------------------------------
 kernel/slow-work.c          |   18 ++-
 kernel/slow-work.h          |    6 +
 8 files changed, 253 insertions(+), 247 deletions(-)
 create mode 100644 kernel/slow-work-debugfs.c
 delete mode 100644 kernel/slow-work-proc.c

Nice - thanks for doing this so quickly! It might sound like nitpicking but /proc ABIs tend to be a lot harder to get rid of than debugfs interfaces.

Ingo

#2 lore raw
Quoted 4 lines · Ingo Molnar

Nice - thanks for doing this so quickly! It might sound like nitpicking but /proc ABIs tend to be a lot harder to get rid of than debugfs interfaces.

Ok, I applied it, so we'll not switch interfaces (even if they are just for debugging) across releases.

Btw David, for things like this, it's _really_ nice to use git rename detection. The diffstat (w/ summary) with rename detection looks like this:

 Documentation/slow-work.txt                      |    4 ++--
 include/linux/slow-work.h                        |    8 ++++----
 init/Kconfig                                     |    8 ++++----
 kernel/Makefile                                  |    2 +-
 kernel/{slow-work-proc.c => slow-work-debugfs.c} |    4 ++--
 kernel/slow-work.c                               |   18 ++++++++++++------
 kernel/slow-work.h                               |    6 +++---
 7 files changed, 28 insertions(+), 22 deletions(-)
 rename kernel/{slow-work-proc.c => slow-work-debugfs.c} (97%)

which makes it obvious that the changes were really just about renaming. Compare to the non-rename-aware one:

 Documentation/slow-work.txt |    4 +-
 include/linux/slow-work.h   |    8 +-
 init/Kconfig                |    8 +-
 kernel/Makefile             |    2 +-
 kernel/slow-work-debugfs.c  |  227 +++++++++++++++++++++++++++++++++++++++++++
 kernel/slow-work-proc.c     |  227 -------------------------------------------
 kernel/slow-work.c          |   18 +++-
 kernel/slow-work.h          |    6 +-
 8 files changed, 253 insertions(+), 247 deletions(-)
 create mode 100644 kernel/slow-work-debugfs.c
 delete mode 100644 kernel/slow-work-proc.c

where you can kind of guess that slow-work-[proc|debugfs].c are largely the same, but you don't actually _see_ that it only has four lines of changes (and the patch then shows that the changes are just to comments).

Linus

#3 lore raw
Quoted 10 lines · Linus Torvalds
Quoted 4 lines · Ingo Molnar

Nice - thanks for doing this so quickly! It might sound like nitpicking but /proc ABIs tend to be a lot harder to get rid of than debugfs interfaces.

Ok, I applied it, so we'll not switch interfaces (even if they are just for debugging) across releases.

I gave it some testing as well on the tree you pushed out - there's no failures on x86 nor on any of the non-x86 cross-builds i tried.

Thanks,

Ingo

#4 lore raw
In reply to Linus Torvalds
Quoted 3 lines · Linus Torvalds

Btw David, for things like this, it's _really_ nice to use git rename detection. The diffstat (w/ summary) with rename detection looks like this:

Yeah... I upgraded to F12 and now StGIT is fighting Exim when I try to mail patches, so I'm having to do my patches my hand until I fix it:-(

David