* export of SEQNUM to userspace
@ 2004-08-29 20:35 Kay Sievers
2004-08-31 18:16 ` Greg KH
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: Kay Sievers @ 2004-08-29 20:35 UTC (permalink / raw)
To: linux-hotplug
Hi Greg,
we want to init HAL with the last emitted hotplug SEQNUM from the
kernel. I think of a sysfs file we can read. It would solve the problem
of the initial timeout, like we have with udevd too (the very first
event is delayed).
What is a proper place to live for this beast?
Thanks,
Kay
-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_idP47&alloc_id\x10808&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: export of SEQNUM to userspace
2004-08-29 20:35 export of SEQNUM to userspace Kay Sievers
@ 2004-08-31 18:16 ` Greg KH
2004-09-01 22:36 ` Kay Sievers
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Greg KH @ 2004-08-31 18:16 UTC (permalink / raw)
To: linux-hotplug
On Sun, Aug 29, 2004 at 10:35:23PM +0200, Kay Sievers wrote:
> Hi Greg,
> we want to init HAL with the last emitted hotplug SEQNUM from the
> kernel. I think of a sysfs file we can read. It would solve the problem
> of the initial timeout, like we have with udevd too (the very first
> event is delayed).
Ok, that sounds reasonable.
> What is a proper place to live for this beast?
I'm getting a lot of requests for odd stuff like this in sysfs. Things
that are "kernel" specific, and aren't associated with any one place
(things that would end up in /proc/sys/kernel if we didn't have sysfs.)
So, how about /sys/kernel?
thanks,
greg k-h
-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_idP47&alloc_id\x10808&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: export of SEQNUM to userspace
2004-08-29 20:35 export of SEQNUM to userspace Kay Sievers
2004-08-31 18:16 ` Greg KH
@ 2004-09-01 22:36 ` Kay Sievers
2004-09-02 8:10 ` Greg KH
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Kay Sievers @ 2004-09-01 22:36 UTC (permalink / raw)
To: linux-hotplug
On Tue, Aug 31, 2004 at 02:16:32PM -0400, Greg KH wrote:
> On Sun, Aug 29, 2004 at 10:35:23PM +0200, Kay Sievers wrote:
> > Hi Greg,
> > we want to init HAL with the last emitted hotplug SEQNUM from the
> > kernel. I think of a sysfs file we can read. It would solve the problem
> > of the initial timeout, like we have with udevd too (the very first
> > event is delayed).
>
> Ok, that sounds reasonable.
>
> > What is a proper place to live for this beast?
>
> I'm getting a lot of requests for odd stuff like this in sysfs. Things
> that are "kernel" specific, and aren't associated with any one place
> (things that would end up in /proc/sys/kernel if we didn't have sysfs.)
>
> So, how about /sys/kernel?
Sounds good!
Who should create the kset (or in this case it's a subsystem) for this?
Any hints?
Thanks,
Kay
-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_idP47&alloc_id\x10808&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: export of SEQNUM to userspace
2004-08-29 20:35 export of SEQNUM to userspace Kay Sievers
2004-08-31 18:16 ` Greg KH
2004-09-01 22:36 ` Kay Sievers
@ 2004-09-02 8:10 ` Greg KH
2004-09-03 0:21 ` Kay Sievers
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Greg KH @ 2004-09-02 8:10 UTC (permalink / raw)
To: linux-hotplug
On Thu, Sep 02, 2004 at 12:36:57AM +0200, Kay Sievers wrote:
> On Tue, Aug 31, 2004 at 02:16:32PM -0400, Greg KH wrote:
> > On Sun, Aug 29, 2004 at 10:35:23PM +0200, Kay Sievers wrote:
> > > Hi Greg,
> > > we want to init HAL with the last emitted hotplug SEQNUM from the
> > > kernel. I think of a sysfs file we can read. It would solve the problem
> > > of the initial timeout, like we have with udevd too (the very first
> > > event is delayed).
> >
> > Ok, that sounds reasonable.
> >
> > > What is a proper place to live for this beast?
> >
> > I'm getting a lot of requests for odd stuff like this in sysfs. Things
> > that are "kernel" specific, and aren't associated with any one place
> > (things that would end up in /proc/sys/kernel if we didn't have sysfs.)
> >
> > So, how about /sys/kernel?
>
> Sounds good!
> Who should create the kset (or in this case it's a subsystem) for this?
Hm, how about a new file in kernel/ ?
thanks,
greg k-h
-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_idP47&alloc_id\x10808&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: export of SEQNUM to userspace
2004-08-29 20:35 export of SEQNUM to userspace Kay Sievers
` (2 preceding siblings ...)
2004-09-02 8:10 ` Greg KH
@ 2004-09-03 0:21 ` Kay Sievers
2004-09-03 9:04 ` Greg KH
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Kay Sievers @ 2004-09-03 0:21 UTC (permalink / raw)
To: linux-hotplug
[-- Attachment #1: Type: text/plain, Size: 1333 bytes --]
On Thu, Sep 02, 2004 at 10:10:06AM +0200, Greg KH wrote:
> On Thu, Sep 02, 2004 at 12:36:57AM +0200, Kay Sievers wrote:
> > On Tue, Aug 31, 2004 at 02:16:32PM -0400, Greg KH wrote:
> > > On Sun, Aug 29, 2004 at 10:35:23PM +0200, Kay Sievers wrote:
> > > > Hi Greg,
> > > > we want to init HAL with the last emitted hotplug SEQNUM from the
> > > > kernel. I think of a sysfs file we can read. It would solve the problem
> > > > of the initial timeout, like we have with udevd too (the very first
> > > > event is delayed).
> > >
> > > Ok, that sounds reasonable.
> > >
> > > > What is a proper place to live for this beast?
> > >
> > > I'm getting a lot of requests for odd stuff like this in sysfs. Things
> > > that are "kernel" specific, and aren't associated with any one place
> > > (things that would end up in /proc/sys/kernel if we didn't have sysfs.)
> > >
> > > So, how about /sys/kernel?
> >
> > Sounds good!
> > Who should create the kset (or in this case it's a subsystem) for this?
>
> Hm, how about a new file in kernel/ ?
Something like this?
o /sys/kernel/hotplug_seqnum exports the current number
o lib/kobject.c's sequence_num is renamed to hotplug_seqnum and
exported by include/linux/kobject.h
o the source file ksysfs.c in kernel/ creates on init the
sybsystem "/sys/kernel/" in sysfs
Thanks,
Kay
[-- Attachment #2: ksysfs-01.patch --]
[-- Type: text/plain, Size: 3149 bytes --]
--- ./dev/null 1970-01-01 01:00:00.000000000 +0100
+++ ./kernel/ksysfs.c 2004-09-03 01:51:38.101622646 +0200
@@ -0,0 +1,63 @@
+/*
+ * kernel/ksysfs.c - sysfs attributes in /sys/kernel, which
+ * are not related to any other subsystem
+ *
+ * Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org>
+ *
+ * This file is release under the GPLv2
+ *
+ */
+
+#include <linux/config.h>
+#include <linux/kobject.h>
+#include <linux/string.h>
+#include <linux/sysfs.h>
+#include <linux/init.h>
+
+#define KERNEL_ATTR_RO(_name) \
+static struct subsys_attribute _name##_attr = { \
+ .attr = { \
+ .name = __stringify(_name), \
+ .mode = 0444, \
+ }, \
+ .show = _name##_show, \
+}
+
+#define KERNEL_ATTR_RW(_name) \
+static struct subsys_attribute _name##_attr = { \
+ .attr = { \
+ .name = __stringify(_name), \
+ .mode = 0644, \
+ }, \
+ .show = _name##_show, \
+ .store = _name##_store, \
+}
+
+static ssize_t hotplug_seqnum_show(struct subsystem * subsys, char * page)
+{
+ return sprintf(page, "%lu\n", hotplug_seqnum);
+}
+KERNEL_ATTR_RO(hotplug_seqnum);
+
+
+decl_subsys(kernel, NULL, NULL);
+
+static struct attribute * g[] = {
+ &hotplug_seqnum_attr.attr,
+ NULL
+};
+
+static struct attribute_group attr_group = {
+ .attrs = g,
+};
+
+static int __init ksysfs_init(void)
+{
+ int error = subsystem_register(&kernel_subsys);
+ if (!error)
+ error = sysfs_create_group(&kernel_subsys.kset.kobj,&attr_group);
+
+ return error;
+}
+
+core_initcall(ksysfs_init);
===== include/linux/kobject.h 1.31 vs edited =====
--- 1.31/include/linux/kobject.h 2004-09-02 01:24:31 +02:00
+++ edited/include/linux/kobject.h 2004-09-03 01:51:17 +02:00
@@ -26,6 +26,9 @@
#define KOBJ_NAME_LEN 20
+/* counter to tag the hotplug event, also available through sysfs */
+extern unsigned long hotplug_seqnum;
+
struct kobject {
char * k_name;
char name[KOBJ_NAME_LEN];
===== kernel/Makefile 1.42 vs edited =====
--- 1.42/kernel/Makefile 2004-08-31 09:55:12 +02:00
+++ edited/kernel/Makefile 2004-09-03 01:46:09 +02:00
@@ -7,7 +7,7 @@ obj-y = sched.o fork.o exec_domain.o
sysctl.o capability.o ptrace.o timer.o user.o \
signal.o sys.o kmod.o workqueue.o pid.o \
rcupdate.o intermodule.o extable.o params.o posix-timers.o \
- kthread.o
+ kthread.o ksysfs.o
obj-$(CONFIG_FUTEX) += futex.o
obj-$(CONFIG_GENERIC_ISA_DMA) += dma.o
===== lib/kobject.c 1.45 vs edited =====
--- 1.45/lib/kobject.c 2004-08-25 21:30:25 +02:00
+++ edited/lib/kobject.c 2004-09-03 01:51:02 +02:00
@@ -122,7 +122,7 @@ char * kobject_get_path(struct kset *kse
#define BUFFER_SIZE 1024 /* should be enough memory for the env */
#define NUM_ENVP 32 /* number of env pointers */
-static unsigned long sequence_num;
+unsigned long hotplug_seqnum;
static spinlock_t sequence_lock = SPIN_LOCK_UNLOCKED;
static void kset_hotplug(const char *action, struct kset *kset,
@@ -178,7 +178,7 @@ static void kset_hotplug(const char *act
scratch += sprintf(scratch, "ACTION=%s", action) + 1;
spin_lock(&sequence_lock);
- seq = sequence_num++;
+ seq = hotplug_seqnum++;
spin_unlock(&sequence_lock);
envp [i++] = scratch;
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: export of SEQNUM to userspace
2004-08-29 20:35 export of SEQNUM to userspace Kay Sievers
` (3 preceding siblings ...)
2004-09-03 0:21 ` Kay Sievers
@ 2004-09-03 9:04 ` Greg KH
2004-09-03 9:22 ` Kay Sievers
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Greg KH @ 2004-09-03 9:04 UTC (permalink / raw)
To: linux-hotplug
On Fri, Sep 03, 2004 at 02:21:06AM +0200, Kay Sievers wrote:
> Something like this?
>
> o /sys/kernel/hotplug_seqnum exports the current number
> o lib/kobject.c's sequence_num is renamed to hotplug_seqnum and
> exported by include/linux/kobject.h
> o the source file ksysfs.c in kernel/ creates on init the
> sybsystem "/sys/kernel/" in sysfs
Nice, I like it. How about this, smaller version instead. I just
changed your code to use the __ATTR* macros and named a few variables a
bit better, no "g" variables for me :)
Is this ok with you?
thanks,
greg k-h
------
diff -Nru a/include/linux/kobject.h b/include/linux/kobject.h
--- a/include/linux/kobject.h 2004-09-03 11:00:55 +02:00
+++ b/include/linux/kobject.h 2004-09-03 11:00:55 +02:00
@@ -24,6 +24,9 @@
#define KOBJ_NAME_LEN 20
+/* counter to tag the hotplug event, read only except for the kobject core */
+extern unsigned long hotplug_seqnum;
+
struct kobject {
char * k_name;
char name[KOBJ_NAME_LEN];
diff -Nru a/kernel/Makefile b/kernel/Makefile
--- a/kernel/Makefile 2004-09-03 11:00:55 +02:00
+++ b/kernel/Makefile 2004-09-03 11:00:55 +02:00
@@ -7,7 +7,7 @@
sysctl.o capability.o ptrace.o timer.o user.o \
signal.o sys.o kmod.o workqueue.o pid.o \
rcupdate.o intermodule.o extable.o params.o posix-timers.o \
- kthread.o
+ kthread.o ksysfs.o
obj-$(CONFIG_FUTEX) += futex.o
obj-$(CONFIG_GENERIC_ISA_DMA) += dma.o
diff -Nru a/kernel/ksysfs.c b/kernel/ksysfs.c
--- /dev/null Wed Dec 31 16:00:00 196900
+++ b/kernel/ksysfs.c 2004-09-03 11:00:55 +02:00
@@ -0,0 +1,52 @@
+/*
+ * kernel/ksysfs.c - sysfs attributes in /sys/kernel, which
+ * are not related to any other subsystem
+ *
+ * Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org>
+ *
+ * This file is release under the GPLv2
+ *
+ */
+
+#include <linux/config.h>
+#include <linux/kobject.h>
+#include <linux/string.h>
+#include <linux/sysfs.h>
+#include <linux/module.h>
+#include <linux/init.h>
+
+#define KERNEL_ATTR_RO(_name) \
+static struct subsys_attribute _name##_attr = __ATTR_RO(_name)
+
+#define KERNEL_ATTR_RW(_name) \
+static struct subsys_attribute _name##_attr = \
+ __ATTR(_name, 0644, _name##_show, _name##_store)
+
+static ssize_t hotplug_seqnum_show(struct subsystem *subsys, char *page)
+{
+ return sprintf(page, "%lu\n", hotplug_seqnum);
+}
+KERNEL_ATTR_RO(hotplug_seqnum);
+
+
+static decl_subsys(kernel, NULL, NULL);
+
+static struct attribute * kernel_attrs[] = {
+ &hotplug_seqnum_attr.attr,
+ NULL
+};
+
+static struct attribute_group kernel_attr_group = {
+ .attrs = kernel_attrs,
+};
+
+static int __init ksysfs_init(void)
+{
+ int error = subsystem_register(&kernel_subsys);
+ if (!error)
+ error = sysfs_create_group(&kernel_subsys.kset.kobj, &kernel_attr_group);
+
+ return error;
+}
+
+core_initcall(ksysfs_init);
diff -Nru a/lib/kobject.c b/lib/kobject.c
--- a/lib/kobject.c 2004-09-03 11:00:55 +02:00
+++ b/lib/kobject.c 2004-09-03 11:00:55 +02:00
@@ -120,7 +120,7 @@
#define BUFFER_SIZE 1024 /* should be enough memory for the env */
#define NUM_ENVP 32 /* number of env pointers */
-static unsigned long sequence_num;
+unsigned long hotplug_seqnum;
static spinlock_t sequence_lock = SPIN_LOCK_UNLOCKED;
static void kset_hotplug(const char *action, struct kset *kset,
@@ -176,7 +176,7 @@
scratch += sprintf(scratch, "ACTION=%s", action) + 1;
spin_lock(&sequence_lock);
- seq = sequence_num++;
+ seq = hotplug_seqnum++;
spin_unlock(&sequence_lock);
envp [i++] = scratch;
-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_idP47&alloc_id\x10808&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: export of SEQNUM to userspace
2004-08-29 20:35 export of SEQNUM to userspace Kay Sievers
` (4 preceding siblings ...)
2004-09-03 9:04 ` Greg KH
@ 2004-09-03 9:22 ` Kay Sievers
2004-09-03 13:49 ` Kay Sievers
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Kay Sievers @ 2004-09-03 9:22 UTC (permalink / raw)
To: linux-hotplug
On Fri, Sep 03, 2004 at 11:04:02AM +0200, Greg KH wrote:
> On Fri, Sep 03, 2004 at 02:21:06AM +0200, Kay Sievers wrote:
> > Something like this?
> >
> > o /sys/kernel/hotplug_seqnum exports the current number
> > o lib/kobject.c's sequence_num is renamed to hotplug_seqnum and
> > exported by include/linux/kobject.h
> > o the source file ksysfs.c in kernel/ creates on init the
> > sybsystem "/sys/kernel/" in sysfs
>
> Nice, I like it. How about this, smaller version instead. I just
> changed your code to use the __ATTR* macros and named a few variables a
> bit better, no "g" variables for me :)
>
> Is this ok with you?
Sure, looks perfect.
Thanks a lot,
Kay
-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_idP47&alloc_id\x10808&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: export of SEQNUM to userspace
2004-08-29 20:35 export of SEQNUM to userspace Kay Sievers
` (5 preceding siblings ...)
2004-09-03 9:22 ` Kay Sievers
@ 2004-09-03 13:49 ` Kay Sievers
2004-09-03 17:21 ` Greg KH
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Kay Sievers @ 2004-09-03 13:49 UTC (permalink / raw)
To: linux-hotplug
[-- Attachment #1: Type: text/plain, Size: 1074 bytes --]
On Fri, Sep 03, 2004 at 11:22:03AM +0200, Kay Sievers wrote:
> On Fri, Sep 03, 2004 at 11:04:02AM +0200, Greg KH wrote:
> > On Fri, Sep 03, 2004 at 02:21:06AM +0200, Kay Sievers wrote:
> > > Something like this?
> > >
> > > o /sys/kernel/hotplug_seqnum exports the current number
> > > o lib/kobject.c's sequence_num is renamed to hotplug_seqnum and
> > > exported by include/linux/kobject.h
> > > o the source file ksysfs.c in kernel/ creates on init the
> > > sybsystem "/sys/kernel/" in sysfs
> >
> > Nice, I like it. How about this, smaller version instead. I just
> > changed your code to use the __ATTR* macros and named a few variables a
> > bit better, no "g" variables for me :)
> >
> > Is this ok with you?
>
> Sure, looks perfect.
Oops, too fast. New patch. Forgot the unusal CONFIG_* combinations.
!CONFIG_SYSFS goes with:
obj-$(CONFIG_SYSFS) += ksysfs.o
and
!CONFIG_HOTPLUG needs the ifdef's in ksysfs.c and kobject.h or is
there any better way?
Tested compilation of all four combinations and booted with:
CONFIG_SYSFS + !CONFIG_HOTPLUG.
Kay
[-- Attachment #2: ksysfs-02.patch --]
[-- Type: text/plain, Size: 3496 bytes --]
Add /sys/kernel subsystem to sysfs and export current hotplug SEQUNUM
o /sys/kernel/hotplug_seqnum exports the current number¶
o lib/kobject.c's sequence_num is renamed to hotplug_seqnum and¶
exported by include/linux/kobject.h¶
o the source file ksysfs.c in kernel/ creates on init the¶
sybsystem "/sys/kernel/" in sysfs¶
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
diff -Nru a/include/linux/kobject.h b/include/linux/kobject.h
--- a/include/linux/kobject.h 2004-09-03 15:12:57 +02:00
+++ b/include/linux/kobject.h 2004-09-03 15:12:57 +02:00
@@ -26,6 +26,11 @@
#define KOBJ_NAME_LEN 20
+#ifdef CONFIG_HOTPLUG
+/* counter to tag the hotplug event, read only except for the kobject core */
+extern unsigned long hotplug_seqnum;
+#endif
+
struct kobject {
char * k_name;
char name[KOBJ_NAME_LEN];
diff -Nru a/kernel/Makefile b/kernel/Makefile
--- a/kernel/Makefile 2004-09-03 15:12:57 +02:00
+++ b/kernel/Makefile 2004-09-03 15:12:57 +02:00
@@ -24,6 +24,7 @@
obj-$(CONFIG_AUDIT) += audit.o
obj-$(CONFIG_AUDITSYSCALL) += auditsc.o
obj-$(CONFIG_KPROBES) += kprobes.o
+obj-$(CONFIG_SYSFS) += ksysfs.o
ifneq ($(CONFIG_IA64),y)
# According to Alan Modra <alan@linuxcare.com.au>, the -fno-omit-frame-pointer is
diff -Nru a/kernel/ksysfs.c b/kernel/ksysfs.c
--- /dev/null Wed Dec 31 16:00:00 196900
+++ b/kernel/ksysfs.c 2004-09-03 15:12:57 +02:00
@@ -0,0 +1,55 @@
+/*
+ * kernel/ksysfs.c - sysfs attributes in /sys/kernel, which
+ * are not related to any other subsystem
+ *
+ * Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org>
+ *
+ * This file is released under the GPLv2
+ *
+ */
+
+#include <linux/config.h>
+#include <linux/kobject.h>
+#include <linux/string.h>
+#include <linux/sysfs.h>
+#include <linux/module.h>
+#include <linux/init.h>
+
+#define KERNEL_ATTR_RO(_name) \
+static struct subsys_attribute _name##_attr = __ATTR_RO(_name)
+
+#define KERNEL_ATTR_RW(_name) \
+static struct subsys_attribute _name##_attr = \
+ __ATTR(_name, 0644, _name##_show, _name##_store)
+
+#ifdef CONFIG_HOTPLUG
+static ssize_t hotplug_seqnum_show(struct subsystem *subsys, char *page)
+{
+ return sprintf(page, "%lu\n", hotplug_seqnum);
+}
+KERNEL_ATTR_RO(hotplug_seqnum);
+#endif
+
+static decl_subsys(kernel, NULL, NULL);
+
+static struct attribute * kernel_attrs[] = {
+#ifdef CONFIG_HOTPLUG
+ &hotplug_seqnum_attr.attr,
+#endif
+ NULL
+};
+
+static struct attribute_group kernel_attr_group = {
+ .attrs = kernel_attrs,
+};
+
+static int __init ksysfs_init(void)
+{
+ int error = subsystem_register(&kernel_subsys);
+ if (!error)
+ error = sysfs_create_group(&kernel_subsys.kset.kobj, &kernel_attr_group);
+
+ return error;
+}
+
+core_initcall(ksysfs_init);
diff -Nru a/lib/kobject.c b/lib/kobject.c
--- a/lib/kobject.c 2004-09-03 15:12:57 +02:00
+++ b/lib/kobject.c 2004-09-03 15:12:57 +02:00
@@ -122,7 +122,7 @@
#define BUFFER_SIZE 1024 /* should be enough memory for the env */
#define NUM_ENVP 32 /* number of env pointers */
-static unsigned long sequence_num;
+unsigned long hotplug_seqnum;
static spinlock_t sequence_lock = SPIN_LOCK_UNLOCKED;
static void kset_hotplug(const char *action, struct kset *kset,
@@ -178,7 +178,7 @@
scratch += sprintf(scratch, "ACTION=%s", action) + 1;
spin_lock(&sequence_lock);
- seq = sequence_num++;
+ seq = hotplug_seqnum++;
spin_unlock(&sequence_lock);
envp [i++] = scratch;
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: export of SEQNUM to userspace
2004-08-29 20:35 export of SEQNUM to userspace Kay Sievers
` (6 preceding siblings ...)
2004-09-03 13:49 ` Kay Sievers
@ 2004-09-03 17:21 ` Greg KH
2004-10-08 14:43 ` David Zeuthen
2004-10-08 21:05 ` Greg KH
9 siblings, 0 replies; 11+ messages in thread
From: Greg KH @ 2004-09-03 17:21 UTC (permalink / raw)
To: linux-hotplug
On Fri, Sep 03, 2004 at 03:49:18PM +0200, Kay Sievers wrote:
> Oops, too fast. New patch. Forgot the unusal CONFIG_* combinations.
>
> !CONFIG_SYSFS goes with:
> obj-$(CONFIG_SYSFS) += ksysfs.o
>
> and
> !CONFIG_HOTPLUG needs the ifdef's in ksysfs.c and kobject.h or is
> there any better way?
>
> Tested compilation of all four combinations and booted with:
> CONFIG_SYSFS + !CONFIG_HOTPLUG.
Hm, we also need to change this:
> - seq = sequence_num++;
> + seq = hotplug_seqnum++;
To this:
seq = ++hotplug_seqnum;
to show the last used sequence number.
I'll make that change and test out the different config options.
thanks,
greg k-h
-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_idP47&alloc_id\x10808&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: export of SEQNUM to userspace
2004-08-29 20:35 export of SEQNUM to userspace Kay Sievers
` (7 preceding siblings ...)
2004-09-03 17:21 ` Greg KH
@ 2004-10-08 14:43 ` David Zeuthen
2004-10-08 21:05 ` Greg KH
9 siblings, 0 replies; 11+ messages in thread
From: David Zeuthen @ 2004-10-08 14:43 UTC (permalink / raw)
To: linux-hotplug
Hi,
On Sun, 2004-08-29 at 22:35 +0200, Kay Sievers wrote:
> Hi Greg,
> we want to init HAL with the last emitted hotplug SEQNUM from the
> kernel. I think of a sysfs file we can read. It would solve the problem
> of the initial timeout, like we have with udevd too (the very first
> event is delayed).
>
> What is a proper place to live for this beast?
>
Is this yet integrated?
Another thing, I was thinking, for this to be really useful I guess what
we need is not (only?) the last emitted hotplug SEQNUM but instead the
"maximum SEQNUM ever emitted". Because with the "last SEQNUM emitted"
the kernel may emit this sequence of hotplug events
1004
1003
1002 <-- udevd starts; reads "last seqnum emitted is 1002"
1001 <-- udevd discards this hotplug event
1005 <-- udevd blocks/timeouts waiting for 1002
1006
1007
...
and we're as screwed as we are today. With "maximum SEQNUM ever emitted"
it will work; proof is by contradiction.
Thoughts? Should we have both?
Thanks,
David
-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: export of SEQNUM to userspace
2004-08-29 20:35 export of SEQNUM to userspace Kay Sievers
` (8 preceding siblings ...)
2004-10-08 14:43 ` David Zeuthen
@ 2004-10-08 21:05 ` Greg KH
9 siblings, 0 replies; 11+ messages in thread
From: Greg KH @ 2004-10-08 21:05 UTC (permalink / raw)
To: linux-hotplug
On Fri, Oct 08, 2004 at 10:43:19AM -0400, David Zeuthen wrote:
>
> Hi,
>
> On Sun, 2004-08-29 at 22:35 +0200, Kay Sievers wrote:
> > Hi Greg,
> > we want to init HAL with the last emitted hotplug SEQNUM from the
> > kernel. I think of a sysfs file we can read. It would solve the problem
> > of the initial timeout, like we have with udevd too (the very first
> > event is delayed).
> >
> > What is a proper place to live for this beast?
> >
>
> Is this yet integrated?
It's in the -mm tree, I'm waiting for 2.6.9 to come out before sending
it for inclusion in the main kernel tree.
> Another thing, I was thinking, for this to be really useful I guess what
> we need is not (only?) the last emitted hotplug SEQNUM but instead the
> "maximum SEQNUM ever emitted". Because with the "last SEQNUM emitted"
> the kernel may emit this sequence of hotplug events
>
> 1004
> 1003
> 1002 <-- udevd starts; reads "last seqnum emitted is 1002"
No, the read will read '1004', not 1002.
> 1001 <-- udevd discards this hotplug event
> 1005 <-- udevd blocks/timeouts waiting for 1002
> 1006
> 1007
> ...
>
> and we're as screwed as we are today. With "maximum SEQNUM ever emitted"
> it will work; proof is by contradiction.
The sysfs file will always show the "max SEQNUM" due to locking within
the kernel keeping the order always correct.
Hope this helps,
greg k-h
-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2004-10-08 21:05 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-08-29 20:35 export of SEQNUM to userspace Kay Sievers
2004-08-31 18:16 ` Greg KH
2004-09-01 22:36 ` Kay Sievers
2004-09-02 8:10 ` Greg KH
2004-09-03 0:21 ` Kay Sievers
2004-09-03 9:04 ` Greg KH
2004-09-03 9:22 ` Kay Sievers
2004-09-03 13:49 ` Kay Sievers
2004-09-03 17:21 ` Greg KH
2004-10-08 14:43 ` David Zeuthen
2004-10-08 21:05 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).