dazuko-devel
[Top][All Lists]
Advanced

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

Re: [Dazuko-devel] dazukofs-3.0.0 interrupted system calls


From: Frantisek Hrbata
Subject: Re: [Dazuko-devel] dazukofs-3.0.0 interrupted system calls
Date: Fri, 27 Feb 2009 12:37:28 +0100

On Fri, 27 Feb 2009 09:06:05 +0100
John Ogness <address@hidden> wrote:

> On 2009-02-27, John Ogness <address@hidden> wrote:
> > +    sigset_t sigset;
> > +
> > +    /* catch TERM,INT,HUP signals */
> > +    signal(SIGTERM, sigterm);
> > +    signal(SIGINT, sigterm);
> > +    signal(SIGHUP, sigterm);
> 
> Sorry, I forgot to include:
> 
>        signal(SIGUSR1, sigterm);
> 
> which must also be set up from main(). (I'm having copy/paste issues
> today.)
> 
> John Ogness
> 

Ok, I found the problem. It is dazukofs issue. There is a code flow. 

process 1                                 process 2

dazukofs_group_read                       dazukofs_group_read
        |                                           |
        v                                           v
dazukofs_get_event                        dazukofs_get_event
        |                                           |
        v                                           v
wait_event_freezable                      wait_event_freezable
        |                                           |
        v                                           v
wait_event_interruptible                  wait_event_interruptible
        |                                           |
        v                                           v
 now ONE new event is available and both processes are waken up
        |                                           |
        v                                           |
here else if (!(condition))                         |
in wait_event_interruptible                         |
is true so you will get back                        |
to dazukofs_get_event                        during this time
        |                                    precess can sleep
        v                                     e.g. preemted
claim_event                                         |
here the event is removed from the                  |
todo list so the condition is no                    |
longer true                                         |
        |                                           v
        v                                     here the extra condition
read is ok and user space program will        check if(!(condition)) in
get requested event                           wait_event_interruptible
                                              is false and it returns
                                              -ERESTARTSYS
                                                    |
                                                    v
                                              read failed and user
                                              space program will get
                                              -EINTR due to the
                                              if (err == -ERESTARTSYS)
                                                   return -EINTR;
                                              in dazukofs_group_read

So basically there is a race between extra condition check in
wait_event_freezable and claim_event.

Note you are calling wake_up in assign_event_to_groups and since you
are not using exclusive waits all processes on grp->queue will be woken
up.

I am using preemptive kernel with CONFIG_FREEZER enabled so this is why
I am getting -EINTR errors.

When I replace wait_event_freezable with wait_event_interruptible
everything is working fine because in the second process the
claim_event will return NULL and thanks to the while(1) it will go back
to wait for event.

-FH




reply via email to

[Prev in Thread] Current Thread [Next in Thread]