From: Chris Friesen <chris.friesen@windriver.com>
To: lkml <linux-kernel@vger.kernel.org>
Subject: help? usage of indirect per-cpu variables
Date: Tue, 27 Sep 2016 13:41:30 -0600 [thread overview]
Message-ID: <57EACB6A.608@windriver.com> (raw)
Hi,
I'm trying to wrap my head around indirect percpu variables, and I'm hoping
someone can school me on how they work.
For example, in mm/slub.c we have "struct kmem_cache *s". s->cpu_slab is a
per-cpu variable, so we access it with something like:
c = raw_cpu_ptr(s->cpu_slab);
and then a bit later on we do
object = c->freelist;
So far so good. Essentially the raw_cpu_ptr() macro applies a unique per-CPU
offset to s->cpu_slab to generate "c" which is a real pointer so we can
dereference it to get c->freelist.
What confuses me is how we can do something like this:
this_cpu_cmpxchg_double(s->cpu_slab->freelist,
s->cpu_slab->tid,
object, tid,
next_object, next_tid(tid))
If s->cpu_slab is a special pointer that needs to be accessed only via the
per-CPU macros, then how is it valid to specify "s->cpu_slab->freelist"? Since
s->cpuslab isn't actually a valid address, how can we dereference it?
Thanks,
Chris
reply other threads:[~2016-09-27 19:41 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=57EACB6A.608@windriver.com \
--to=chris.friesen@windriver.com \
--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;
as well as URLs for NNTP newsgroup(s).