From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755406AbcI0Tlm (ORCPT ); Tue, 27 Sep 2016 15:41:42 -0400 Received: from mail1.windriver.com ([147.11.146.13]:51881 "EHLO mail1.windriver.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751496AbcI0Tld (ORCPT ); Tue, 27 Sep 2016 15:41:33 -0400 Message-ID: <57EACB6A.608@windriver.com> Date: Tue, 27 Sep 2016 13:41:30 -0600 From: Chris Friesen User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: lkml Subject: help? usage of indirect per-cpu variables Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [172.25.39.2] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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