Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753475Ab0AZCKt (ORCPT ); Mon, 25 Jan 2010 21:10:49 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753184Ab0AZCKs (ORCPT ); Mon, 25 Jan 2010 21:10:48 -0500 Received: from ey-out-2122.google.com ([74.125.78.25]:5263 "EHLO ey-out-2122.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753075Ab0AZCKr (ORCPT ); Mon, 25 Jan 2010 21:10:47 -0500 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; b=BmB554uMwng8dm2yOIRaHm6+gpZi+5BO05YR9cp7FooJU+82LXqdFo6H82sV8mwMGv o+WQuyZUXdKK9Tq52RqJ+qHRmLSlB37DOOURk8mFAntUNnd7GtgKNfbk6DLYej1VHnDQ ghA9I2N5CWFgR4wd5DXvrD69jQ7NpVfX6QPbY= Date: Tue, 26 Jan 2010 03:10:42 +0100 From: Frederic Weisbecker To: Tejun Heo Cc: linux-kernel@vger.kernel.org, axboe@kernel.dk, rusty@rustcorp.com.au, akpm@linux-foundation.org, ebiederm@xmission.com, tytso@mit.edu, Trond.Myklebust@netapp.com, aelder@sgi.com, hch@infradead.org, viro@zeniv.linux.org.uk, davem@davemloft.net, netdev@vger.kernel.org, x86@kernel.org, mingo@redhat.com, dan.j.williams@intel.com, borislav.petkov@amd.com, ying.huang@intel.com, lenb@kernel.org, neilb@suse.de, cl@linux-foundation.org Subject: Re: [PATCH 7/8] percpu: add __percpu sparse annotations to hw_breakpoint Message-ID: <20100126021041.GN5087@nowhere> References: <1264432935-10453-1-git-send-email-tj@kernel.org> <1264432935-10453-8-git-send-email-tj@kernel.org> <20100126001901.GI5087@nowhere> <4B5E3BED.6030705@kernel.org> <20100126010239.GK5087@nowhere> <4B5E4308.8020105@kernel.org> <20100126020113.GM5087@nowhere> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20100126020113.GM5087@nowhere> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2468 Lines: 77 On Tue, Jan 26, 2010 at 03:01:14AM +0100, Frederic Weisbecker wrote: > On Tue, Jan 26, 2010 at 10:19:04AM +0900, Tejun Heo wrote: > > Hello, > > > > On 01/26/2010 10:02 AM, Frederic Weisbecker wrote: > > > Well, sorry I must be missing something obvious, but is it impossible > > > to make per_cpu(var, cpu) returning something cast in: > > > > > > (typeof(var) __force) > > > > > > Or I guess you did that already and it is not working with static > > > arrays, or? > > > > Yeap, the definition looks like > > > > #define SHIFT_PERCPU_PTR(__p, __offset) ({ \ > > __verify_pcpu_ptr((__p)); \ > > RELOC_HIDE((typeof(*(__p)) __kernel __force *)(__p), (__offset)); \ > > }) > > > > #define per_cpu(var, cpu) \ > > (*SHIFT_PERCPU_PTR(&(var), per_cpu_offset(cpu))) > > > > but it just ends up putting the __force at the wrong layer. It seems > > that (typeof(var) __kernel __force) tell sparse var is in the kernel > > address space but not its members. > > > So, may be it considers you are applying the address space overriding > to the pointer to the type and not to the type itself. > > Consider: > > int __percpu i; > > What you do above *might* be considered as if SHIFT_PERCPU_PTR > returns something of a type: > > int * __percpu i; > > So the pointer is in the normal address space, but its content is in > __percpu address space. > > What if you do this: > > > #define SHIFT_PERCPU_PTR(__p, __offset) ({ \ > __verify_pcpu_ptr((__p)); \ > RELOC_HIDE((__p), (__offset)); \ > }) > > #define per_cpu(var, cpu) \ > (typeof(var) __kernel __force)(*SHIFT_PERCPU_PTR(&(var), per_cpu_offset(cpu))) > > This should work because &(var) should be dereferencable directly, since > it is not of type "__force t" but of type "*__force t" > > And you're not doing anymore this: > > *(int * __kernel __force) i; > but > *(int __kernel __force *) i; The above is perhaps a bit confusing. To be more clear, in the first case you only cast the pointer to the type, which gives you a pointer valid in kernel space to data valid in percpu space. The second case gives you something valid in kernel space for both. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/