Re: + proc-dont-lock-task_structs-indefinitely-cpuset-fix-2.patch added to -mm tree

Andrew Morton
2006-03-02T04:31:27Z

Paul Jackson <pj@sgi.com> wrote:
>
> Andrew wrote:
> > But Paul bisected it down to a particular not-merged patch,
> > gregkh-driver-allow-sysfs-attribute-files-to-be-pollable.patch, which I'll
> > admit doesn't look like it'll cause this.
>
> Verified.

All very strange. afaict that patch is a no-op. The changelog claims that
"This patch also uses sysfs_notify to allow /sys/block/md*/md/sync_action
to be pollable", except that part is AWOL.

It'd be interesting to see if just the data structure expansion:

--- gregkh-2.6.orig/fs/sysfs/file.c
+++ gregkh-2.6/fs/sysfs/file.c
@@ -6,6 +6,7 @@
#include <linux/fsnotify.h>
#include <linux/kobject.h>
#include <linux/namei.h>
+#include <linux/poll.h>
#include <asm/uaccess.h>
#include <asm/semaphore.h>

@@ -57,6 +58,7 @@ struct sysfs_buffer {
struct sysfs_ops * ops;
struct semaphore sem;
int needs_read_fill;
+ int event;
};

--- gregkh-2.6.orig/include/linux/kobject.h
+++ gregkh-2.6/include/linux/kobject.h
@@ -24,6 +24,7 @@
#include <linux/rwsem.h>
#include <linux/kref.h>
#include <linux/kernel.h>
+#include <linux/wait.h>
#include <asm/atomic.h>

#define KOBJ_NAME_LEN 20
@@ -56,6 +57,7 @@ struct kobject {
struct kset * kset;
struct kobj_type * ktype;
struct dentry * dentry;
+ wait_queue_head_t poll;
};

extern int kobject_set_name(struct kobject *, const char *, ...)
--- gregkh-2.6.orig/include/linux/sysfs.h
+++ gregkh-2.6/include/linux/sysfs.h
@@ -74,6 +74,7 @@ struct sysfs_dirent {
umode_t s_mode;
struct dentry * s_dentry;
struct iattr * s_iattr;
+ atomic_t s_event;
};

#define SYSFS_ROOT 0x0001

is sufficient to break it.

Somewhat OT, but why is that patch dinking around with the attribute's
\x10parent directory? Why not just poll the attribute's sysfs file directly?
<xenuflects>. Possibly because we want the poller to be woken when an
attribute actually gets instantiated within the directory?? Dunno.

And it's a bit sad that poll() on an unpollable attribute will just hang.
One would expect poll() to come back with -EINVAL.