public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: cn_queue.c
Date: Fri, 01 Apr 2005 15:15:45 +0400	[thread overview]
Message-ID: <1112354145.9334.239.camel@uganda> (raw)
In-Reply-To: <1112353944.9334.236.camel@uganda>

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

On Fri, 2005-04-01 at 15:12 +0400, Evgeniy Polyakov wrote:

> > > cn_queue_wrapper() atomically increments cbq->cb->refcnt if runs, so it
> > > will
> > > be caught in 
> > > while (atomic_read(&cbq->cb->refcnt)) 
> > >   msleep(1000);
> > > in cn_queue_free_callback().
> > > If it does not run, then all will be ok.
> > 
> > But there's a time window on entry to cn_queue_wrapper() where the recsount
> > hasn't been incremented yet, and there's no locking.  If
> > cn_queue_free_callback() inspects the refcount in that window it will free
> > the cn_callback_entry() while cn_queue_wrapper() is playing with it?
> 
> If we already run cn_queue_wrapper() [even before refcnt incrementing,
> probably it is not even needed there], then cancel_delayed_work() will
> sleep,
> since appropriate timer will be deleted in del_timer_sync(), which 
> will wait untill it is finished on the different CPU.
> 
> > > Btw, it looks like comments for del_timer_sync() and cancel_delayed_work
> > > ()
> > > are controversial - del_timer_sync() says that pending timer
> > > can not run on different CPU after returning, 
> > > but cancel_delayed_work() says, that work to be cancelled still 
> > > can run after returning.
> > 
> > Not controversial - the timer can have expired and have been successfully
> > deleted but the work_struct which the timer handler scheduled is still
> > pending, or has just started to run.
> 
> Ugh, I see now.
> There are two levels of work deferring  - into cpu_workqueue_struct, 
> and, in case of delayed work, into work->timer.
> 
> 
> Yes, I need to place flush_workqueue() in cn_queue_free_callback();
> 

That actullay NULLifies above sentence about sleeping in
cancel_delayed_work().

-- 
        Evgeniy Polyakov

Crash is better than data corruption -- Arthur Grabowski

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

      reply	other threads:[~2005-04-01 11:09 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-01  1:32 cn_queue.c Andrew Morton
2005-04-01  7:40 ` cn_queue.c Evgeniy Polyakov
2005-04-01  7:57   ` cn_queue.c Andrew Morton
2005-04-01  8:40     ` cn_queue.c Evgeniy Polyakov
2005-04-01  8:48       ` cn_queue.c Andrew Morton
2005-04-01  9:34         ` cn_queue.c Evgeniy Polyakov
2005-04-01  9:50           ` cn_queue.c Andrew Morton
2005-04-01 10:36             ` cn_queue.c Evgeniy Polyakov
2005-04-01 10:43               ` cn_queue.c Andrew Morton
2005-04-01 11:12                 ` cn_queue.c Evgeniy Polyakov
2005-04-01 11:15                   ` Evgeniy Polyakov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1112354145.9334.239.camel@uganda \
    --to=johnpol@2ka.mipt.ru \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox