Re: Re: Hotplug events during sleep transition

Nigel Cunningham
2005-12-23T22:57:31Z

[-- Attachment #1: Type: text/plain, Size: 2291 bytes --]

Hi.

On Sat, 2005-12-24 at 08:48, Pavel Machek wrote:
> On So 24-12-05 08:40:31, Nigel Cunningham wrote:
> > On Sat, 2005-12-24 at 08:31, Pavel Machek wrote:
>
> > > > > > > Well, if you can find some elegant solution in the core, I think thats
> > > > > > > the best way.
> > > > > > >
> > > > > > > You could set system_state to "suspending" or something like that, and
> > > > > > > just if() out notifications in that case.
> > > > > >
> > > > > > How about simply adding a call to try_to_freeze() somewhere inside
> > > > > > kernel/kmod.c:____call_usermodehelper()? That ought to do pretty much
> > > > > > what I want, in theory. The hotplug processes would get frozen before
> > > > > > /sbin/hotplug is exec'ed.
> > > > >
> > > > > On modern distros, /sbin/hotplug is set to NULL, so this isn't an issue.
> > > > > We use netlink to send the data out, so this might not even be a problem
> > > > > anymore...
> > > >
> > > > At resume time, prior to copying back the original kernel data, events
> > > > can and do occur.
> > > >
> > > > FWIW, I've been using "if(freezer_is_on()) return 0" for a while in
> > > > call_usermodehelper_keys, to good effect.
> > >
> > > Can we have a patch?
> >
> > Well the version I'm using depends on my changes to the freezer, so I
> > can't give you one straight off, and I'm not likely to get around to it
> > today, so I was hoping someone else would run with the concept :)
>
> Ahha, ok. Forget it, then. Or just send a patch without the
> refrigerator changes, so Alan knows where to hack. It does not have to
> work in order to be useful :-).
> Pavel

Fair enough. Here's what I'm using, FWIW.

By the way, hope you all have a great Christmas and festive season in
general!

Regards,

Nigel

diff -ruN linux-2.6.15-rc6/kernel/kmod.c build-2.6.15-rc6/kernel/kmod.c
--- linux-2.6.15-rc6/kernel/kmod.c 2005-12-20 19:46:36.000000000 +1000
+++ build-2.6.15-rc6/kernel/kmod.c 2005-12-21 10:18:39.000000000 +1000
@@ -36,6 +36,7 @@
#include <linux/mount.h>
#include <linux/kernel.h>
#include <linux/init.h>
+#include <linux/freezer.h>
#include <asm/uaccess.h>

extern int max_threads;
@@ -249,6 +250,9 @@
if (!khelper_wq)
return -EBUSY;

+ if (freezer_is_on())
+ return 0;
+
if (path[0] == '\0')
return 0;