public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: mark.rutland@arm.com (Mark Rutland)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] arm64: percpu: Make this_cpu accessors pre-empt safe
Date: Thu, 19 Mar 2015 16:11:44 +0000	[thread overview]
Message-ID: <20150319161143.GE25967@leverpostej> (raw)
In-Reply-To: <20150319160008.GA4751@arm.com>

On Thu, Mar 19, 2015 at 04:00:09PM +0000, Will Deacon wrote:
> On Thu, Mar 19, 2015 at 03:44:36PM +0000, Mark Rutland wrote:
> > On Thu, Mar 19, 2015 at 02:52:31PM +0000, Steve Capper wrote:
> > > this_cpu operations were implemented for arm64 in:
> > >  5284e1b arm64: xchg: Implement cmpxchg_double
> > >  f97fc81 arm64: percpu: Implement this_cpu operations
> > > 
> > > Unfortunately, it is possible for pre-emption to take place between
> > > address generation and data access. This can lead to cases where data
> > > is being manipulated by this_cpu for a different CPU than it was
> > > called on. Which effectively breaks the spec.
> > > 
> > > This patch disables pre-emption for the this_cpu operations
> > > guaranteeing that address generation and data manipulation.
> > 
> > Shouldn't that last sentence end with "occur on the same CPU", or
> > something like that?
> > 
> > [...]
> > 
> > > +/*
> > > + * Modules aren't allowed to use preempt_enable_no_resched, and it is
> > > + * undef'ed. If we are unable to use preempt_enable_no_resched, then
> > > + * fallback to the standard preempt_enable.
> > > + */
> > > +#ifdef preempt_enable_no_resched
> > > +#define __pcp_preempt_enable()	preempt_enable_no_resched()
> > > +#else
> > > +#define __pcp_preempt_enable()	preempt_enable()
> > > +#endif /* preempt_enable_no_resched */
> > 
> > I think it would be worth mentioning in the comment why we want to use
> > preempt_enable_no_resched where possible (e.g. read-modify-cmpxchg
> > sequences where we want to have as few retries as possible).
> 
> Hmm, I'm not sure I agree with that. In the interest of throughput, I can
> understand that you want to minimise the retries but since preempt kernels
> are all about minimising latency then actually scheduling when a cmpxchg
> loop fail sounds pretty ideal to me.

I'm on about scheduling at the end of the read, before the cmpxchg. It's
basically asking for another thread to make the read stale (and hence
the cmpxchg is very likely to fail).

Scheduling after the cmpxchg is fine.

Mark.

  reply	other threads:[~2015-03-19 16:11 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-19 14:52 [PATCH] arm64: percpu: Make this_cpu accessors pre-empt safe Steve Capper
2015-03-19 15:44 ` Mark Rutland
2015-03-19 15:55   ` Steve Capper
2015-03-19 16:23     ` Mark Rutland
2015-03-19 16:00   ` Will Deacon
2015-03-19 16:11     ` Mark Rutland [this message]
2015-03-19 16:27       ` Will Deacon
2015-03-19 16:39         ` Mark Rutland
2015-03-20 18:02           ` Will Deacon
2015-03-22 14:51             ` [PATCH V2] " Steve Capper
2015-03-23 10:17               ` Will Deacon

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=20150319161143.GE25967@leverpostej \
    --to=mark.rutland@arm.com \
    --cc=linux-arm-kernel@lists.infradead.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