[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: kobject_uevent() and sysfs attribute sync
BTW, If I have two or more kobject_uevent() that notify different
situations, how the user space could know from what kobject_uevent()
the signal is generated ?
BR,
Mauricio Lin.
--- Mauricio Lin <mauriciolin2000@xxxxxxxxxxxx> escreveu:
> Hi Greg,
>
> --- Greg KH <greg@xxxxxxxxx> escreveu:
>
> > On Tue, Dec 05, 2006 at 08:57:48PM +0000, Mauricio Lin wrote:
> > > Hi all,
> > >
> > > I implemented a module that sends signals to user space using
> > > kobject_uevent() when some conditions happen. That step is
> working.
> > >
> > > When the signal is sent, a sysfs attribute is also changed
> (switch
> > from
> > > 0 to 1 or vice-versa). This means that the corresponding file
> under
> > > /sys/ has its contents modified as well (using
> "_name"_show(struct
> > > subsystem *subsys, char *page) function) .
> > >
> > > The user space when receives the signal (sent by
> kobject_uevent())
> > it
> > > tries to read the file under /sys (that was changed to 1 when the
> > > signal was sent), but the value is always 0. IMHO there is a sync
> > > problem, because when user space gets the signal and it reads the
> > file
> > > under /sys, the value set to 1 (notify moment) could be changed
> > back to
> > > 0 (read moment) later.
> >
> > Then userspace isn't getting there fast enough it seems :)
>
> Yes, that's right.
>
> >
> > > So is there any way to send a signal and guarantee that the
> > attribute
> > > will be read by user space before being changed by subsequent
> > actions?
> > > Is sysfs_notify() a possible solution for that?
> >
> > How about just poll() on the sysfs file? That way your program
> gets
> > woken up, and you read the proper data.
>
> Humm, is it efficient? It must be something that does not consume
> much
> memory.
>
> >
> > But what is the real thing you are trying to do here? It seems you
> > are
> > trying to use sysfs in an odd way, perhaps you might want to do
> > something else?
>
> Humm, you gave me an idea. I have just to send the signal when the
> attribute is changed to 1 and not 0, so there is no need to include
> an
> additional read from user space to check if the value is 1 again.
>
> Let me check the code again :)
>
> Thanks,
>
> Mauricio Lin.
>
> >
> > thanks,
> >
> > greg k-h
> >
>
>
>
>
>
>
>
>
>
> _______________________________________________________
> Você quer respostas para suas perguntas? Ou você sabe muito e quer
> compartilhar seu conhecimento? Experimente o Yahoo! Respostas !
> http://br.answers.yahoo.com/
>
> --
> Kernelnewbies: Help each other learn about the Linux kernel.
> Archive: http://mail.nl.linux.org/kernelnewbies/
> FAQ: http://kernelnewbies.org/faq/
>
>
_______________________________________________________
O Yahoo! está de cara nova. Venha conferir!
http://br.yahoo.com
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/