All of lore.kernel.org
 help / color / mirror / Atom feed
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>,
	Dan Carpenter <dan.carpenter@oracle.com>
Subject: Re: xen/p2m: m2p_find_override: use list_for_each_entry_safe
Date: Fri, 20 Apr 2012 12:01:19 -0400	[thread overview]
Message-ID: <20120420160118.GA2291@phenom.dumpdata.com> (raw)
In-Reply-To: <alpine.DEB.2.00.1204201418400.26786@kaball-desktop>

On Fri, Apr 20, 2012 at 02:36:59PM +0100, Stefano Stabellini wrote:
> On Fri, 20 Apr 2012, Dan Carpenter wrote:
> > On Fri, Apr 20, 2012 at 12:23:21PM +0100, Stefano Stabellini wrote:
> > > On Fri, 20 Apr 2012, Dan Carpenter wrote:
> > > > Hi Stefano,
> > > > 
> > > > I had a question about 8f2854c74ff4: "xen/p2m: m2p_find_override: use
> > > > list_for_each_entry_safe".
> > > > 
> > > > I think there is a misunderstanding about what the
> > > > list_for_each_entry_safe() macro does.  It has nothing to do with
> > > > locking, so the spinlock is still needed.  Without the lock ->next could
> > > > point to an element which has been deleted in another thread.  Probably
> > > > the patch should be reverted.
> > > 
> > > I thought that list_for_each_entry_safe is safe against deletion, is it
> > > not?
> > > It doesn't matter whether we get up to date entries or old entries
> > > here as long as walking through the list doesn't break if a concurrent
> > > thread adds or removes items.
> > > 
> > 
> > It's safe against deletion in the same thread.  But not against
> > deletion from another thread.
> > 
> > At the beginning of the loop it stores a pointer to the next
> > element.  If you delete the element you are on, no problem because
> > you already have a pointer to the next one.  But if another thread
> > deletes the next element, now you have a pointer which is wrong.
> 
> The problem is not that the next element is wrong because we should be
> able to cope with that.
> The problem is that the next->next pointer would be set LIST_POISON1.
> 
> Maybe replacing our call to list_del with __list_del would be sufficient
> to solve the problem?
> Probably it is best to revert the patch at this stage.

ok, reverted.

      reply	other threads:[~2012-04-20 16:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-20 10:51 xen/p2m: m2p_find_override: use list_for_each_entry_safe Dan Carpenter
2012-04-20 11:23 ` Stefano Stabellini
2012-04-20 11:35   ` Dan Carpenter
2012-04-20 13:36     ` Stefano Stabellini
2012-04-20 16:01       ` Konrad Rzeszutek Wilk [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=20120420160118.GA2291@phenom.dumpdata.com \
    --to=konrad.wilk@oracle.com \
    --cc=dan.carpenter@oracle.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=xen-devel@lists.xensource.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.