Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp981279ybl; Wed, 4 Dec 2019 14:30:19 -0800 (PST) X-Google-Smtp-Source: APXvYqzOrSoQPV3C5QKaqV2Vjj5OD4ifHFcGry+qHVHPq3iGK0JofvGzE3rBIoN6CThXvxXfV+cx X-Received: by 2002:aca:6006:: with SMTP id u6mr4768082oib.137.1575498618922; Wed, 04 Dec 2019 14:30:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575498618; cv=none; d=google.com; s=arc-20160816; b=g6g3iKNcsAOI9A7Q3BAevpyMXKqO3CAgDCUaN3UCLd2mJcnHBs4iTLbgF6pGnX+qo/ qB7oILVPM90zhiiBBFt4/fjvUnGJBSrA25lNRTSu3XCL6xkt2ELQnlGmQJiCb8PTccmr 6p2Eqxf0naS3plISX8RoCEhaSnktx7OyA+ER9diG9OcbtOkPBxry9qe6yjlrbJs8W3L3 M93DW95ykzEf6yAKD8wv1iAFAuBFHRT69d+1W2Rs9ftYnBIPIFspiyDzRKi0PKx7SRiF d1a5vxHsJv4ctqU/kvKiNxcKwWSW9rRS3Zc7ftwwKza3A9dWfV3AzeUFADSOVeDYIQvW fhSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=HEYQS05MAbHQwQXy7WM1nS2KzK94OdilVdY0KXKLqkE=; b=s6m1RtPfvRN8uw5baN2ubNS1fp/SGHibIUy3NuyWmkAzsP9V2UUNxk+7Hpcw4JJONx hMkgVcfG0iyeYz22Mue8kxV2DBQBqRNJJPBUWqGKG/w6NhlYzc6E/Xb9h2BIhvpiHPV2 zMAHfIKWImlqjpPl7CkhyRPIqb6lZVdmQ3TMw7tfLAyA0aW4OAKXZoa2iZOWPit3qpSZ 0VM11Axf657OExuwfdKdv8odHK5IC4+VTq/MpCWMUxJ67FoiKoWIas+p2QAJmQtTwW2v +LAfnBK227XkDrh/40wD3IYpcOVAOjyyEIR/PvzS/3Ktkj3hhfnDrMEjvu9Aae9fjfv/ LnBQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c195si4011779oib.266.2019.12.04.14.30.06; Wed, 04 Dec 2019 14:30:18 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728330AbfLDW2k (ORCPT + 99 others); Wed, 4 Dec 2019 17:28:40 -0500 Received: from mail-qt1-f194.google.com ([209.85.160.194]:32939 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728053AbfLDW2k (ORCPT ); Wed, 4 Dec 2019 17:28:40 -0500 Received: by mail-qt1-f194.google.com with SMTP id d5so1499410qto.0 for ; Wed, 04 Dec 2019 14:28:40 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=HEYQS05MAbHQwQXy7WM1nS2KzK94OdilVdY0KXKLqkE=; b=nBBqCbSsH0vcRIuqTjqwqF/EPv2RAANnvUThDsrRZBrruFYliF8PrDiOf6Scgm0RY2 DJPg2KOtzdwA/U2nGZskH7q7Z7mhcfHO2GFWW11I3RSBKgYud2CT6Nt7+XA3Lgtdl/Ch UKw9GK4ulIcQUY+toc/6lnj69rW84l7LM30IwsJhLWCeDAfU5uJ3sTwyvRz/67d/7vPX nkGWFWdwJOYYmXs81hND0MONdW0epBMFL7PT9n3QLBqAoSJhrf2OEmOWbyc+sDhjbYZ/ pffBWpsN+rlsMM9ozBiZ+tPF0JgTM9aWm0x+3x8KYqDZpJaQb7u9bbvZSWCVgyw456GV 3ZbQ== X-Gm-Message-State: APjAAAXARjCs8N2cz2aeAhx9hahbzrgWYxGHIagbm88VFtgPm5O14zpo XFyLvf8Fsf2nzpQZUmONexg= X-Received: by 2002:ac8:259c:: with SMTP id e28mr4999167qte.323.1575498519587; Wed, 04 Dec 2019 14:28:39 -0800 (PST) Received: from dennisz-mbp ([2620:10d:c091:500::f69c]) by smtp.gmail.com with ESMTPSA id d6sm4345036qkb.103.2019.12.04.14.28.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Dec 2019 14:28:38 -0800 (PST) Date: Wed, 4 Dec 2019 17:28:37 -0500 From: Dennis Zhou To: Luc Van Oostenryck Cc: Dennis Zhou , linux-kernel@vger.kernel.org, Christoph Lameter , Tejun Heo , Nicholas Piggin , Ben Dooks Subject: Re: [PATCH v2] fix __percpu annotation in asm-generic Message-ID: <20191204222837.GA51250@dennisz-mbp> References: <20191204010623.65384-1-luc.vanoostenryck@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191204010623.65384-1-luc.vanoostenryck@gmail.com> User-Agent: Mutt/1.12.2 (2019-09-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Dec 04, 2019 at 02:06:23AM +0100, Luc Van Oostenryck wrote: > The generic implementation of raw_cpu_generic_add_return() is: > > #define raw_cpu_generic_add_return(pcp, val) \ > ({ \ > typeof(&(pcp)) __p = raw_cpu_ptr(&(pcp)); \ > \ > *__p += val; \ > *__p; \ > }) > > where the 'pcp' argument is a __percpu lvalue. > There, the variable '__p' is declared as a __percpu pointer > the type of the address of 'pcp') but: > 1) the value assigned to it, the return value of raw_cpu_ptr(), is > a plain (__kernel) pointer, not a __percpu one. > 2) this variable is dereferenced just after while a __percpu > pointer is implicitly __noderef. > > So, fix the declaration of the 'pcp' variable to its correct type: > the plain (non-percpu) pointer corresponding to pcp's address, > using the fact that typeof() ignores the address space and the > 'noderef' attribute of its agument. > > Same for raw_cpu_generic_xchg(), raw_cpu_generic_cmpxchg() & > raw_cpu_generic_cmpxchg_double(). > > This removes 209 warnings on ARM, 525 on ARM64, 220 on x86 & > more than 2600 on ppc64 (all of them with the default config). > > Cc: Dennis Zhou > Cc: Christoph Lameter > Cc: Tejun Heo > Cc: Nicholas Piggin > Reported-by: Ben Dooks > Signed-off-by: Luc Van Oostenryck > --- > > Change since v1: > * use the fact that typeof() ignore the address space of its argument. > > include/asm-generic/percpu.h | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/include/asm-generic/percpu.h b/include/asm-generic/percpu.h > index c2de013b2cf4..35e4a53b83e6 100644 > --- a/include/asm-generic/percpu.h > +++ b/include/asm-generic/percpu.h > @@ -74,7 +74,7 @@ do { \ > > #define raw_cpu_generic_add_return(pcp, val) \ > ({ \ > - typeof(&(pcp)) __p = raw_cpu_ptr(&(pcp)); \ > + typeof(pcp) *__p = raw_cpu_ptr(&(pcp)); \ > \ > *__p += val; \ > *__p; \ > @@ -82,7 +82,7 @@ do { \ > > #define raw_cpu_generic_xchg(pcp, nval) \ > ({ \ > - typeof(&(pcp)) __p = raw_cpu_ptr(&(pcp)); \ > + typeof(pcp) *__p = raw_cpu_ptr(&(pcp)); \ > typeof(pcp) __ret; \ > __ret = *__p; \ > *__p = nval; \ > @@ -91,7 +91,7 @@ do { \ > > #define raw_cpu_generic_cmpxchg(pcp, oval, nval) \ > ({ \ > - typeof(&(pcp)) __p = raw_cpu_ptr(&(pcp)); \ > + typeof(pcp) *__p = raw_cpu_ptr(&(pcp)); \ > typeof(pcp) __ret; \ > __ret = *__p; \ > if (__ret == (oval)) \ > @@ -101,8 +101,8 @@ do { \ > > #define raw_cpu_generic_cmpxchg_double(pcp1, pcp2, oval1, oval2, nval1, nval2) \ > ({ \ > - typeof(&(pcp1)) __p1 = raw_cpu_ptr(&(pcp1)); \ > - typeof(&(pcp2)) __p2 = raw_cpu_ptr(&(pcp2)); \ > + typeof(pcp1) *__p1 = raw_cpu_ptr(&(pcp1)); \ > + typeof(pcp2) *__p2 = raw_cpu_ptr(&(pcp2)); \ > int __ret = 0; \ > if (*__p1 == (oval1) && *__p2 == (oval2)) { \ > *__p1 = nval1; \ > -- > 2.24.0 > I've applied this for-5.6. Thanks, Dennis