Skip to contentSkip to conversation

closures: move to lib/

PATCH NAK Kent Overstreet 4 participants 9 messages Dec 19, 2013 – Dec 22, 2013

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

PATCH 1/1 closures: move to lib/

the closure code was never intended to be bcache specific - hopefully it can be useful elsewhere in the kernel.

Cc Tejun Heo <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Oleg Nesterov <[email protected]>
Cc Arjan van de Ven <[email protected]>
Cc Dan Williams <[email protected]>
---
 drivers/md/bcache/Kconfig   |   9 -
 drivers/md/bcache/Makefile  |   2 +-
 drivers/md/bcache/bcache.h  |   2 +-
 drivers/md/bcache/closure.c | 222 ----------------------
 drivers/md/bcache/closure.h | 453 --------------------------------------------
 drivers/md/bcache/util.h    |   3 +-
 include/linux/closure.h     | 451 +++++++++++++++++++++++++++++++++++++++++++
 lib/Kconfig.debug           |   8 +
 lib/Makefile                |   2 +-
 lib/closure.c               | 218 +++++++++++++++++++++
 10 files changed, 681 insertions(+), 689 deletions(-)
 delete mode 100644 drivers/md/bcache/closure.c
 delete mode 100644 drivers/md/bcache/closure.h
 create mode 100644 include/linux/closure.h
 create mode 100644 lib/closure.c
drivers/md/bcache/Kconfig +0 -9
index 2638417b19..d6d7f792cc 100644
@@ -16,15 +16,6 @@ config BCACHE_DEBUG
 	Enables extra debugging tools, allows expensive runtime checks to be
 	turned on.
 
-config BCACHE_CLOSURES_DEBUG
-	bool "Debug closures"
-	depends on BCACHE
-	select DEBUG_FS
-	---help---
-	Keeps all active closures in a linked list and provides a debugfs
-	interface to list them, which makes it possible to see asynchronous
-	operations that get stuck.
-
 # cgroup code needs to be updated:
 #
 #config CGROUP_BCACHE
drivers/md/bcache/Makefile +1 -1
index 0e9c82523b..17ab9adbdf 100644
@@ -2,6 +2,6 @@
 obj-$(CONFIG_BCACHE)	+= bcache.o
 
 bcache-y		:= alloc.o btree.o bset.o io.o journal.o writeback.o\
-	movinggc.o request.o super.o sysfs.o debug.o util.o trace.o stats.o closure.o
+	movinggc.o request.o super.o sysfs.o debug.o util.o trace.o stats.o
 
 CFLAGS_request.o	+= -Iblock
drivers/md/bcache/bcache.h +1 -1
index 9d062bc562..79f444a8b9 100644
@@ -179,6 +179,7 @@
 
 #include <linux/bcache.h>
 #include <linux/bio.h>
+#include <linux/closure.h>
 #include <linux/kobject.h>
 #include <linux/list.h>
 #include <linux/mutex.h>
@@ -188,7 +189,6 @@
 #include <linux/workqueue.h>
 
 #include "util.h"
-#include "closure.h"
 
 struct bucket {
 	atomic_t	pin;
drivers/md/bcache/closure.c deleted +0 -222

222 lines not on this page · raw message

drivers/md/bcache/closure.h deleted +0 -453

453 lines not on this page · raw message

drivers/md/bcache/util.h +1 -2
index 1030c6020e..c51605d34b 100644
@@ -2,6 +2,7 @@
 #ifndef _BCACHE_UTIL_H
 #define _BCACHE_UTIL_H
 
+#include <linux/closure.h>
 #include <linux/errno.h>
 #include <linux/kernel.h>
 #include <linux/llist.h>
@@ -9,8 +10,6 @@
 #include <linux/vmalloc.h>
 #include <linux/workqueue.h>
 
-#include "closure.h"
-
 #define PAGE_SECTORS		(PAGE_SIZE / 512)
 
 struct closure;
include/linux/closure.h new file +451 -0

451 lines not on this page · raw message

lib/Kconfig.debug +8 -0
index db25707aa4..0d1dbbf07a 100644
@@ -1240,6 +1240,14 @@ config DEBUG_BLOCK_EXT_DEVT
 
 	  Say N if you are unsure.
 
+config CLOSURE_DEBUG
+	bool "Debug closures"
+	select DEBUG_FS
+	---help---
+	Keeps all active closures in a linked list and provides a debugfs
+	interface to list them, which makes it possible to see asynchronous
+	operations that get stuck.
+
 config NOTIFIER_ERROR_INJECTION
 	tristate "Notifier error injection"
 	depends on DEBUG_KERNEL
lib/Makefile +1 -1
index a459c31e8c..907c11b788 100644
@@ -26,7 +26,7 @@ obj-y += bcd.o div64.o sort.o parser.o halfmd4.o debug_locks.o random32.o \
 	 bust_spinlocks.o hexdump.o kasprintf.o bitmap.o scatterlist.o \
 	 gcd.o lcm.o list_sort.o uuid.o flex_array.o iovec.o clz_ctz.o \
 	 bsearch.o find_last_bit.o find_next_bit.o llist.o memweight.o kfifo.o \
-	 percpu-refcount.o percpu_ida.o
+	 percpu-refcount.o percpu_ida.o closure.o
 obj-y += string_helpers.o
 obj-$(CONFIG_TEST_STRING_HELPERS) += test-string_helpers.o
 obj-y += kstrtox.o
lib/closure.c new file +218 -0

218 lines not on this page · raw message

Signature · 1 line
1.8.5.1
#1 lore raw
Quoted 9 lines · Kent Overstreet

the closure code was never intended to be bcache specific - hopefully it can be useful elsewhere in the kernel.

Cc Tejun Heo <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Oleg Nesterov <[email protected]>
Cc Arjan van de Ven <[email protected]>
Cc Dan Williams <[email protected]>
Quoted 16 lines
---
 drivers/md/bcache/Kconfig   |   9 -
 drivers/md/bcache/Makefile  |   2 +-
 drivers/md/bcache/bcache.h  |   2 +-
 drivers/md/bcache/closure.c | 222 ----------------------
 drivers/md/bcache/closure.h | 453 --------------------------------------------
 drivers/md/bcache/util.h    |   3 +-
 include/linux/closure.h     | 451 +++++++++++++++++++++++++++++++++++++++++++
 lib/Kconfig.debug           |   8 +
 lib/Makefile                |   2 +-
 lib/closure.c               | 218 +++++++++++++++++++++
 10 files changed, 681 insertions(+), 689 deletions(-)
 delete mode 100644 drivers/md/bcache/closure.c
 delete mode 100644 drivers/md/bcache/closure.h
 create mode 100644 include/linux/closure.h
 create mode 100644 lib/closure.c

This would be smaller to review with git diff -M

#2 lore raw
Quoted 27 lines · Dan Williams
Quoted 9 lines · Kent Overstreet

the closure code was never intended to be bcache specific - hopefully it can be useful elsewhere in the kernel.

Cc Tejun Heo <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Oleg Nesterov <[email protected]>
Cc Arjan van de Ven <[email protected]>
Cc Dan Williams <[email protected]>
Quoted 16 lines
---
 drivers/md/bcache/Kconfig   |   9 -
 drivers/md/bcache/Makefile  |   2 +-
 drivers/md/bcache/bcache.h  |   2 +-
 drivers/md/bcache/closure.c | 222 ----------------------
 drivers/md/bcache/closure.h | 453 --------------------------------------------
 drivers/md/bcache/util.h    |   3 +-
 include/linux/closure.h     | 451 +++++++++++++++++++++++++++++++++++++++++++
 lib/Kconfig.debug           |   8 +
 lib/Makefile                |   2 +-
 lib/closure.c               | 218 +++++++++++++++++++++
 10 files changed, 681 insertions(+), 689 deletions(-)
 delete mode 100644 drivers/md/bcache/closure.c
 delete mode 100644 drivers/md/bcache/closure.h
 create mode 100644 include/linux/closure.h
 create mode 100644 lib/closure.c
Quoted 1 line

This would be smaller to review with git diff -M

I forgot to mention - this is on top of other stuff I have queued up which deletes a fair amount of code in closure.[ch] (finally got rid of some stuff Tejun hated).

#3 lore raw
In reply to Kent Overstreet
Quoted 2 lines · Kent Overstreet

the closure code was never intended to be bcache specific - hopefully it can be useful elsewhere in the kernel.

They are not. They aren't closures in the CS sense, and they are an ugly mess. Please work on removing them instead.

#4 lore raw
Quoted 5 lines · Christoph Hellwig
Quoted 2 lines · Kent Overstreet

the closure code was never intended to be bcache specific - hopefully it can be useful elsewhere in the kernel.

They are not. They aren't closures in the CS sense,

If you consider the key thing behind CS closures to be spaghetti stacks, then actually these kind of are.

Quoted 2 lines

and they are an
ugly mess. Please work on removing them instead.

That's not really the kind of technical objection one can respond to. If you think there's a better way of doing this kind of asynchronous stuff, or a better mechanism already in the kernel (ha!) - please, by all means, enlighten us.

#5 lore raw
Quoted 4 lines · Kent Overstreet

That's not really the kind of technical objection one can respond to. If you think there's a better way of doing this kind of asynchronous stuff, or a better mechanism already in the kernel (ha!) - please, by all means, enlighten us.

Show the actual use, and it shouldn't be hard to find something better.

#6 lore raw
Quoted 7 lines · Christoph Hellwig
Quoted 4 lines · Kent Overstreet

That's not really the kind of technical objection one can respond to. If you think there's a better way of doing this kind of asynchronous stuff, or a better mechanism already in the kernel (ha!) - please, by all means, enlighten us.

Show the actual use, and it shouldn't be hard to find something better.

Grep through drivers/md/bcache/...

Nacked-by NAK
#8 lore raw
In reply to Christoph Hellwig

Hello,

Quoted 6 lines · Christoph Hellwig
Quoted 2 lines · Kent Overstreet

the closure code was never intended to be bcache specific - hopefully it can be useful elsewhere in the kernel.

They are not. They aren't closures in the CS sense, and they are an ugly mess. Please work on removing them instead.

I pretty much agree with Christoph here. Compared to all other generic utilities we have, the proposed mechanism is giant in its conceptual complexity. This is a lot worse than semaphores. I personally think inclusion of it in the upstream kernel at all was a bad idea.

Thanks.

Signature · 1 line
tejun
#7 lore raw
In reply to Kent Overstreet
Quoted 1 line · Kent Overstreet

Grep through drivers/md/bcache/...

While that will require a fair amount of work I'm pretty sure we could untangle that mess as well. But what I meant was whatever piece of code that motivated you to move the code to lib/.