mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@osdl.org>
To: johnpol@2ka.mipt.ru
Cc: linux-kernel@vger.kernel.org
Subject: Re: cn_queue.c
Date: Fri, 1 Apr 2005 00:48:04 -0800	[thread overview]
Message-ID: <20050401004804.52519e17.akpm@osdl.org> (raw)
In-Reply-To: <1112344811.9334.146.camel@uganda>

Evgeniy Polyakov <johnpol@2ka.mipt.ru> wrote:
>
>  New object has 0 reference counter when created.
>  If some work is appointed to the object, then it's counter is atomically
>  incremented. It is decremented when the work is finished.
>  If object is supposed to be removed while some work
>  may be appointed to it, core ensures that no work _is_ appointed, 
>  and atomically disallows[for example removing workqueue, removing
>  callback, all with appropriate locks being hold] 
>  any other work appointment for the given object.
>  After it [when no work can be appointed to the object] if object
>  still has pending work [and thus has it's refcounter not zero], 
>  removing path waits untill appropriate refcnt hits zero. 
>  Since no _new_ work can be appointed at that level it is just
>  while (atomic_read(refcnt) != 0)
>    msleep();

More like:

	while (atomic_read(&obj->refcnt))
		msleep();
	kfree(obj);

which introduces the possibility of someone grabbing a new ref on the
object just before the kfree().  If there is no means by which any other
actor can acquire a ref to this object then OK, no race.

But it's rather surprising that such a thing can be achieved without any
locking.  What happens if another CPU has just entered
cn_queue_del_callback(), for example?  It has a live cn_callback_entry in
`cbq' which has a zero refcount - cn_queue_free_dev() can throw it away.


  reply	other threads:[~2005-04-01  8:49 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       ` Andrew Morton [this message]
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                   ` cn_queue.c Evgeniy Polyakov

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=20050401004804.52519e17.akpm@osdl.org \
    --to=akpm@osdl.org \
    --cc=johnpol@2ka.mipt.ru \
    --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

all inboxes | Powered by JetHome®