Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1492128 > unrolled thread

help? usage of indirect per-cpu variables

Started byChris Friesen <chris.friesen@windriver.com>
First post2016-09-27 21:50 +0200
Last post2016-09-27 21:50 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel


Contents

  help?  usage of indirect per-cpu variables Chris Friesen <chris.friesen@windriver.com> - 2016-09-27 21:50 +0200

#1492128 — help? usage of indirect per-cpu variables

FromChris Friesen <chris.friesen@windriver.com>
Date2016-09-27 21:50 +0200
Subjecthelp? usage of indirect per-cpu variables
Message-ID<sm6y5-5bY-1@gated-at.bofh.it>
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

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web