Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2032649ybl; Tue, 3 Dec 2019 17:08:25 -0800 (PST) X-Google-Smtp-Source: APXvYqyDKANiWrARXVkv5okfJw35P7+VDSu4bpGEIX74jLI0v2tr/r1ZxBancMJdDvpNMYe9d9gk X-Received: by 2002:a05:6808:b1c:: with SMTP id s28mr562627oij.2.1575421705063; Tue, 03 Dec 2019 17:08:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575421705; cv=none; d=google.com; s=arc-20160816; b=JSmbGa1e8ymxS6/9taxoLG44a6m1Nn2Z1BiqOdsO7c+pz6c2yGCRCme3pOdvPC99Go joLXHICWpRpcQEyMNGeN37kB92MN7OSg6VWVCwimNfi9p5tb9ZBWqO21GqpJ5DJ5iRZJ VOVhlTisnGdD57jwr0WNn8EcMwJ0M8SK7oX/AjsTVcmRf4rlzk/R+lsvhVotyjIjxduQ QcWmEqkDTNidVfpmDOxVobEZPN7xCGeNSWKqEvrfMKlXsPR4khdWhocJdtiBIn8/xAuf lypulG1mLbaJjCkv83CADYLa7NqqwMtBO7I6g6Hwo4NmlkOnyVK15HRpy0JdRYHjvGS7 y+8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=BUhWP41gAQ+u6lqrVAb//FnSSw9Q7UZjagkqlU3jNOs=; b=TwC7/Q+51Cq7uS3aRvBJVuqM2uZMi2EVnNjV4TndXvQ/cPLV+6gIH96wOh3A1kWAYH ID4PIulUBzIzHX1VZCzdiEtAAn8DJTOAk/538u8gExf9NeU8rkJxy6+4InDDPr570riW TzDm+Kg6/gZuBO0aomLafFLACCm08z+SiPevPiy3cFlGmGk/p12SAMFjRQn5nnzlo7kR 9Z32D0x7+O1qsCZVrRC57xSFgG1xnBamlJH2VxV7IjXzbxnbIyd3V/hZlMDLau7Qq92w UF6sbP1HNl+1G8UG1osl+5wBv2sqMwn+gCiCFYHPJwThaZMwj+1k0A0Hqzoy4NO+S3rc svTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=r26EnM3T; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w4si2296048otl.214.2019.12.03.17.08.12; Tue, 03 Dec 2019 17:08:25 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=r26EnM3T; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726661AbfLDBGm (ORCPT + 99 others); Tue, 3 Dec 2019 20:06:42 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:35688 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726086AbfLDBGl (ORCPT ); Tue, 3 Dec 2019 20:06:41 -0500 Received: by mail-wr1-f66.google.com with SMTP id g17so6509317wro.2 for ; Tue, 03 Dec 2019 17:06:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=BUhWP41gAQ+u6lqrVAb//FnSSw9Q7UZjagkqlU3jNOs=; b=r26EnM3TD+cn4FCMQ0z4rvYXPIYxZgjzo5RSNJ3thwWSK52RbjKhiP5xmWbX52dCIl Fj1PCIwJkfcpqjEXezfZzlhlKZZ9MDznT7iAN2TcP4iVX6luTwlL/RgiVNbArnAhhKHF /LlaBRq7RpN26BnEhK9zZxFsa7w+hGQVCrXKMZophce/83Ui7OeTzO1i7V4J1cJ4uHZl mAywlg/kNTs8kSFHaZCZictQX9A9Oz9473ire8c4FPt8g9bekgLY33b0fvV/ZnsLW+ME eX2FIHy+SrUV7gLIfU9YRqaGwFgsXl7/h5RZD1zT4Qac05aDdVo94Z8xyC2eNuhjrCq2 MZvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=BUhWP41gAQ+u6lqrVAb//FnSSw9Q7UZjagkqlU3jNOs=; b=Yv9y289hW6P7a7RDHnG14O+vsXLqJN+7ccffGR5nT2Ai2DShAAfqLyZ6hcnZfH+bvj KAmnbkvCn/orwocOQAQkaati9j1QvoPVZgVJQMeGRvFn0dMNZQHTembZ6WOhXDSl9XFj d06nHeb31t06wi8YJuCW+v17Ace+QGXWy8M0tbKp5qJBFgImjSxsRa/VgktJCz5oXucJ YPQk3AApHvo+YYoBSWxkDRinjkJ3OgMb+HdKHlSyIrXwfMrgZ2ncE/SUGsodI+wn06v5 kD/wnen9NaJgEftU0qQx9D2tZDHvf6DWsZDeXy90WuUJiVC076Z5JA3IeuTIVXKn+veZ aYAw== X-Gm-Message-State: APjAAAXiEQaN5IRuZTmUObmjyKSy3Ds7e9rQAYDyE0NX2UyGFn2NEyp+ iN+gLlGUBUYI5U/8Kc9PENg= X-Received: by 2002:adf:e3c7:: with SMTP id k7mr1024751wrm.80.1575421599971; Tue, 03 Dec 2019 17:06:39 -0800 (PST) Received: from localhost.localdomain ([2a02:a03f:404e:f500:a9e5:6fa:6c43:150b]) by smtp.gmail.com with ESMTPSA id t13sm5024147wmt.23.2019.12.03.17.06.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2019 17:06:38 -0800 (PST) From: Luc Van Oostenryck To: Dennis Zhou Cc: linux-kernel@vger.kernel.org, Luc Van Oostenryck , Christoph Lameter , Tejun Heo , Nicholas Piggin , Ben Dooks Subject: [PATCH v2] fix __percpu annotation in asm-generic Date: Wed, 4 Dec 2019 02:06:23 +0100 Message-Id: <20191204010623.65384-1-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.24.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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