Re: sysfs_notify & poll

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I am not sure but I had understanded that we need to implement the pool syscall, as described in ldd3 books, only for chardevices. For attributes in sysfs, the poll syscall is managed by the kernel/sysfs and we can simply use sysfs_notify on the kernel side. An event queue is managed for each attribute for this purprose.

But as I say before I am not clear with this. You can read this : http://lists.linuxcoding.com/kernel/2006-q1/msg28166.html or this from the kernel source:

/* Sysfs attribute files are pollable.  The idea is that you read
 * the content and then you use 'poll' or 'select' to wait for
 * the content to change.  When the content changes (assuming the
 * manager for the kobject supports notification), poll will
 * return POLLERR|POLLPRI, and select will return the fd whether
 * it is waiting for read, write, or exceptions.
 * Once poll/select indicates that the value has changed, you
 * need to close and re-open the file, as simply seeking and reading
 * again will not get new data, or reset the state of 'poll'.
 * Reminder: this only works for attributes which actively support
 * it, and it is not possible to test an attribute from userspace
 * to see if it supports poll (Nether 'poll' or 'select' return
 * an appropriate error code).  When in doubt, set a suitable timeout value.
 */


--- En date de : Mer 7.1.09, Belisko Marek <marek.belisko@xxxxxxxxx> a écrit :

> De: Belisko Marek <marek.belisko@xxxxxxxxx>
> Objet: Re: sysfs_notify & poll
> À: "PAtrick Gerber" <kpa_info@xxxxxxxx>
> Cc: kernelnewbies@xxxxxxxxxxxx
> Date: Mercredi 7 Janvier 2009, 15h09
> Hi,
> 
> On Wed, Jan 7, 2009 at 2:21 PM, PAtrick Gerber
> <kpa_info@xxxxxxxx> wrote:
> > Thanks for the information.
> >
> > I have tested with the example from
> http://linux.die.net/man/3/poll slightly modified (see the
> attached file).
> > If I test pool on the
> "/sys/module/systest/sections/.data" file it seems
> to work fine. But if I try the same test application with my
> attribute (/sys/kernel/kobject_example/bar) created with the
> example from linux sources
> (samples/kobject/kobject_example.c) the result is an event
> POLLERR.
> 
> >
> > Do you have any idea why ? Need I to add special code
> for support poll syscall in my driver ?
> Of course you should implement poll syscall in kernel
> driver. But for
> kobject-example it could be a problem
> because you don't have a file operations in this
> example. But thats
> only my feeling ;)
> Example for poll : (ldd3
> http://lwn.net/images/pdf/LDD3/ch06.pdf )
> >
> > Thanks in advance
> >
> > --- En date de : Mer 7.1.09, Belisko Marek
> <marek.belisko@xxxxxxxxx> a écrit :
> >
> >> De: Belisko Marek <marek.belisko@xxxxxxxxx>
> >> Objet: Re: sysfs_notify & poll
> >> À: "PAtrick Gerber"
> <kpa_info@xxxxxxxx>
> >> Date: Mercredi 7 Janvier 2009, 13h59
> >> Hi,
> >>
> >> On Wed, Jan 7, 2009 at 1:54 PM, PAtrick Gerber
> >> <kpa_info@xxxxxxxx> wrote:
> >> > Ok thanks. Usefull example. But I have
> another
> >> question:
> >> >
> >> > Need I to use poll or epoll ? I dont really
> understand
> >> the difference.
> >> epoll is a variant of poll that can be used either
> as Edge
> >> or Level
> >> Triggered interface and scales well to large
> numbers of
> >> watched fds.
> >> For beginnig you can use normal poll syscall.
> >>
> >> >
> >> > Thanks in advance for any help !
> >> >
> >> > On Wed, Jan 7, 2009 at 9:40 AM, PAtrick
> Gerber
> >> <kpa_info@xxxxxxxx> wrote:
> >> >> Hello,
> >> >>
> >> >> I would like to try to use sysfs_notify()
> / poll()
> >> mechanism from my
> >> > driver
> >> >> to notify some events to my application.
> I'm
> >> looking for a tiny
> >> > example
> >> >> showing the use of this mechanism.
> >> >>
> >> >> The driver side with sysfs_notify seems
> quite
> >> simple but I have absolutely
> >> >> no idea about the application side.
> >> >
> >> > Fo poll method you canfind good description
> and also
> >> example at:
> >> > http://linux.die.net/man/3/poll
> >> >
> >> >>
> >> >> Thanks in advance
> >> >>
> >> >> Patrick
> >> >>
> >> >
> >> > thanks,
> >> >
> >> > Marek
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >>
> >> thanks,
> >>
> >> Marek
> >>
> >> --
> >> as simple as primitive as possible
> >> ----------------------------------------------
> >> Marek Beliško - open-nandra
> >> Ruská Nová Ves 219
> >> 08005 Prešov
> >> Slovakia
> >> http://open-nandra.com
> >
> >
> >
> 
> thanks,
> 
> Marek
> 
> -- 
> as simple as primitive as possible
> ----------------------------------------------
> Marek Beliško - open-nandra
> Ruská Nová Ves 219
> 08005 Prešov
> Slovakia
> http://open-nandra.com


      

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux