Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp4639490ybc; Tue, 26 Nov 2019 12:08:18 -0800 (PST) X-Google-Smtp-Source: APXvYqwyvTTlDvgPBreR8/oAzmlBC6uuQrWBUF6BfWmjhFVWOLHpz7SQ592TUDwegowPBCa1ZnNl X-Received: by 2002:aa7:d5ce:: with SMTP id d14mr27519268eds.64.1574798897936; Tue, 26 Nov 2019 12:08:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574798897; cv=none; d=google.com; s=arc-20160816; b=M59ULtNclcUvuyy8wQP307r8wVhZTPQ4zWg2XcB3+Tpi++wYPW+kJoGczLrG9ffHT+ ZIn7R6E12Ok5xIKlzQG+S8RwlRY8QoX4ikKFxALFIPayxX4onkETdtBZdQss3O/Qnkwe k1SKqGPedNoygcJ+DrV8XM9w2gqH4SLIP9QbsnuX3pMKgSj6spnB5Tt16XZwxgAiMjtN ixovmhb/LuIpj7c1rH+O7SPD+gPwNgd3XJREuVKAc3pL7gLCzXPI61gNABNlPQTy0o9z fee1A7ilGr8mKQdLFL5FU7wf/kC4qp+1d+s+lJXN5+P3z3gjSEpyxYn50zP/TWekHsTe qFng== 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=+b+NNqbOQ+HR3F7WJkh1g/uLtoPIfDf6gFrchEKK20Y=; b=lpz3PaIqyPaHXdIgF5sVnwqfGuOPqecbeuWwaUOBEoKUWbU/tOagXor/o3RJEZZ6O7 nxpVMHvxNM8leLUyvbzEld6OYhpaQWzCJTvlMwt97uyGHib+Et+AivoZww9nnC9yKYPu JUudjkFibtBOMvHq0Byq72Ls5PXcSd5KRI0KtOpjAPQeNTvtWDGraCtOUAhMQBmJn+A3 3WhlGzzPPek5gL3U+MTWbY6te4K/XDYrIFywumNLtClKlGlq8VeiceU3q0p9QlvNoRN1 4G5xv3uIhSCx7eTavdNBaXHLL/aOhlrtQHGyl1/ZUHzmdeqIg3S28bz9zIk5NjtwrAzb Gv4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=aKmqPxE4; 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 cx12si9608675edb.184.2019.11.26.12.07.53; Tue, 26 Nov 2019 12:08:17 -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=aKmqPxE4; 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 S1726200AbfKZUGb (ORCPT + 99 others); Tue, 26 Nov 2019 15:06:31 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:51258 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725970AbfKZUGb (ORCPT ); Tue, 26 Nov 2019 15:06:31 -0500 Received: by mail-wm1-f65.google.com with SMTP id g206so4606512wme.1; Tue, 26 Nov 2019 12:06:29 -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=+b+NNqbOQ+HR3F7WJkh1g/uLtoPIfDf6gFrchEKK20Y=; b=aKmqPxE4zIAdduzRXnIUY21W9nSOe8k6KRd48MpoAU20mxNwrJXZNK4vEAEFOGGeQh WW+Ylag3O6N/yRHqMWnFMEGopbNbN8SkOeM+UpM4vrWMXtn6qi8irrbTEAPx62Ad+PGp amu8scDh/uVEQH2bgfSiDFap4zQnJo24z4ib0dwWMcO7shGwNMhW5Up+u/+Bwo/FBWrB BuQsLzmWau0FzArJ2NZSvboeLRnGXVwBgS0OfvMo9GcmeY3XwnAJekXoInVgZGjEj0Lj ElNUAKiPjzARWuXOOk7PbMY2mxU93uZgwUl/vf2qEZWhknHcvy0BnrQ1BNgNaqLDJTu4 auzw== 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=+b+NNqbOQ+HR3F7WJkh1g/uLtoPIfDf6gFrchEKK20Y=; b=Hhyp0VLTAVD0bVO7IakCg44QN7rv44Lo/n9dMpvmgu1a3ZsZh18XJwPMAI3uvVEZ32 LOAdRBkZi+dZks14IsLtEOqzIw5WivJEJa4gQT5kNbV6OeBvroEm7g5mfcR3/JyPKee3 m8vCjq4UrrHEmR4i5jprQIfxxW/q11Q+uknyFsFXH/6ZMIm95zPUmVqv+tuyS9cU6I+G HwdDLeRE4cAP2QBeA2FfU1/zX1xO2Fb0Bdy5UrJ8OxzYZzOTzsq13zbEh/dhilERpeOI jJsepg/0Nla6t1lo0dNJDvkLjshau4tr1bL6KKovtYGhQ6j+1gqqQTbmXI7XTOH/34Rb E1aQ== X-Gm-Message-State: APjAAAWnQrQxoB8bgblN+d/NIbD+/hum8XG/hZb2D3hKINAL5XlZvTgz Ml3fVNIz5W5FiN9P12Z7BtouvLCa X-Received: by 2002:a1c:2846:: with SMTP id o67mr791140wmo.7.1574798788866; Tue, 26 Nov 2019 12:06:28 -0800 (PST) Received: from localhost.localdomain ([2a02:a03f:404e:f500:ac14:4c10:6104:457f]) by smtp.gmail.com with ESMTPSA id b3sm4134274wmj.44.2019.11.26.12.06.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Nov 2019 12:06:27 -0800 (PST) From: Luc Van Oostenryck To: Dennis Zhou Cc: Ben Dooks , linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, Luc Van Oostenryck , Tejun Heo , Christoph Lameter , Nicholas Piggin , Arnd Bergmann Subject: [PATCH] fix __percpu annotation in asm-generic Date: Tue, 26 Nov 2019 21:06:19 +0100 Message-Id: <20191126200619.63348-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) the 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 its address. Same for raw_cpu_generic_xchg(), raw_cpu_generic_cmpxchg() & raw_cpu_generic_cmpxchg_double(). This remove 209 warnings on ARM, 460 on x86 & 2600+ on ppc64. Cc: Dennis Zhou Cc: Tejun Heo Cc: Christoph Lameter Cc: Nicholas Piggin Cc: Arnd Bergmann Reported-by: Ben Dooks Signed-off-by: Luc Van Oostenryck --- 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..4ae5f89a0e61 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) __kernel __force *__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) __kernel __force *__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) __kernel __force *__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) __kernel __force *__p1 = raw_cpu_ptr(&(pcp1)); \ + typeof(pcp2) __kernel __force *__p2 = raw_cpu_ptr(&(pcp2)); \ int __ret = 0; \ if (*__p1 == (oval1) && *__p2 == (oval2)) { \ *__p1 = nval1; \ -- 2.24.0