From: Herbert Xu <herbert@gondor.apana.org.au>
To: Christoph Lameter <cl@linux.com>
Cc: Shan Wei <shanwei88@gmail.com>,
steffen.klassert@secunet.com, David Miller <davem@davemloft.net>,
NetDev <netdev@vger.kernel.org>,
Kernel-Maillist <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 3/9] net: xfrm: use this_cpu_ptr per-cpu helper
Date: Thu, 1 Nov 2012 11:41:36 +0800 [thread overview]
Message-ID: <20121101034136.GA27343@gondor.apana.org.au> (raw)
In-Reply-To: <0000013ab7e4a640-60bd5b38-a1fc-4730-b918-4109211ffea0-000000@email.amazonses.com>
On Wed, Oct 31, 2012 at 05:35:46PM +0000, Christoph Lameter wrote:
> On Wed, 31 Oct 2012, Shan Wei wrote:
>
> > -
> > list_for_each_entry(pos, &ipcomp_tfms_list, list) {
> > struct crypto_comp *tfm;
> >
> > tfms = pos->tfms;
> > - tfm = *per_cpu_ptr(tfms, cpu);
> > +
> > + /* This can be any valid CPU ID so we don't need locking. */
> > + tfm = *this_cpu_ptr(tfms);
>
> It would be better to use
>
> this_cpu_read(tfms)
>
> since that would also make it atomic vs interrupts. The above code (both
> original and modified) could determine a pointer to a per cpu structure
> and then take an interrupt which would move the task. On return we would
> be accessing the per cpu variable of another processor.
Please refer to the comment in the patch above.
But I think the patch is wrong anyway because it would introduce
a warning, no?
Thanks,
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
next prev parent reply other threads:[~2012-11-01 3:41 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-31 11:22 [PATCH 3/9] net: xfrm: use this_cpu_ptr per-cpu helper Shan Wei
2012-10-31 17:35 ` Christoph Lameter
2012-11-01 3:41 ` Herbert Xu [this message]
2012-11-01 9:00 ` Shan Wei
2012-11-01 8:56 ` Shan Wei
2012-11-01 9:18 ` Steffen Klassert
2012-11-01 12:15 ` David Laight
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=20121101034136.GA27343@gondor.apana.org.au \
--to=herbert@gondor.apana.org.au \
--cc=cl@linux.com \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=shanwei88@gmail.com \
--cc=steffen.klassert@secunet.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).