From patchwork Thu Sep 5 17:03:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13792745 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1FB29CD6E58 for ; Thu, 5 Sep 2024 17:04:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B074B6B0092; Thu, 5 Sep 2024 13:04:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A8E176B0093; Thu, 5 Sep 2024 13:04:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 908166B0095; Thu, 5 Sep 2024 13:04:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 70A696B0092 for ; Thu, 5 Sep 2024 13:04:11 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 0859B1208D4 for ; Thu, 5 Sep 2024 17:04:11 +0000 (UTC) X-FDA: 82531307502.19.9682350 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) by imf14.hostedemail.com (Postfix) with ESMTP id B7B02100018 for ; Thu, 5 Sep 2024 17:04:07 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=M+rUUY6i; spf=none (imf14.hostedemail.com: domain of andriy.shevchenko@linux.intel.com has no SPF policy when checking 198.175.65.10) smtp.mailfrom=andriy.shevchenko@linux.intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725555823; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=ECZKg2iS6/ewxSy/9wu4EBspbUiLSW05f2/NXqCfxRY=; b=C764VE2I9433l3GipUmmAT8OpmOUCY7P7j/zXx2sVktpTQnInFnPIS4lNiIKN8Ew9ovspj AoOzR5jhs15NKUBOGbtaqcV7KE1QGzJj28HwwOUYh/Hcz275gUIM8W52pqEPK80pk1SyVx fOQyFXtNrjgCSr2M4n6j+Gr4upBV1B8= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=M+rUUY6i; spf=none (imf14.hostedemail.com: domain of andriy.shevchenko@linux.intel.com has no SPF policy when checking 198.175.65.10) smtp.mailfrom=andriy.shevchenko@linux.intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725555823; a=rsa-sha256; cv=none; b=F2UqU3fQBZU0um6BDvDP1ZLSIKUaH4TrZrMTNKAiAUQ0wGHVjWhRqe4Sg2h3hzHRcbgFpF xxzIdKB4chtRE0AIadfpAoceJEb1R6wYEQmXgHWNoA1E8+sfs9NOMdNI3myQrHOCoiTXUk 0vOGymQlKsElEsBEI2mPTku8rSouGGQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1725555848; x=1757091848; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=je+24oM+vGkAb1L4ZYV6lFCDT8JiS8JKuowtm9MBI5E=; b=M+rUUY6imTlL0Wuryv5FBY94HBX6N+PIvOY6mQaxjPoQExfOGe1t7F1h NEnJvE+Vs5F2Bhsbe6P0xiLc/fkeT028vUrV472WbKgsd6/ujUAX2Gidw Z213zu+hbM/Hi202rW9XUtBe2UqNHU3uqorgsTGV8CXnvTQqlzGP21Ikk DDB1ooPgG2l4NwEDxE/0X3bnVeJUZl9chuMtFzzu5Uwu5vfAI8bscLESi OqPBhuNI46R5AaTcnyiGUAd1WDKkKDPFG694Xh0yOteXCZZFJXoR5tcXB HF/Mu9s1ElQKqX4GAZA9DOXkWH+5gmMn96QqM/tQKsv0oh9OyCSlhyaaF Q==; X-CSE-ConnectionGUID: csCRGh4sSs6x016XsDLMXA== X-CSE-MsgGUID: Cw3Bg/CNSN26f7dBc3nx9g== X-IronPort-AV: E=McAfee;i="6700,10204,11186"; a="41768504" X-IronPort-AV: E=Sophos;i="6.10,205,1719903600"; d="scan'208";a="41768504" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Sep 2024 10:04:06 -0700 X-CSE-ConnectionGUID: TKnBCRQUTi6EZs+5cC5WTg== X-CSE-MsgGUID: XPdBFsaiRWepUjq4r3nKxg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,205,1719903600"; d="scan'208";a="65678413" Received: from black.fi.intel.com ([10.237.72.28]) by orviesa009.jf.intel.com with ESMTP; 05 Sep 2024 10:04:00 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id B66AF31E; Thu, 05 Sep 2024 20:03:58 +0300 (EEST) From: Andy Shevchenko To: Ingo Molnar , Uros Bizjak , linux-mm@kvack.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev Cc: Dennis Zhou , Tejun Heo , Christoph Lameter , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Andy Shevchenko Subject: [PATCH v1 1/1] x86/percpu: Cast -1 to argument type when comparing in percpu_add_op() Date: Thu, 5 Sep 2024 20:03:56 +0300 Message-ID: <20240905170356.260300-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: niwbmby996prcupn677rso6p577j5hyj X-Rspamd-Queue-Id: B7B02100018 X-Rspamd-Server: rspam11 X-HE-Tag: 1725555847-503765 X-HE-Meta: U2FsdGVkX18sjzWlHDIwR1h/q59EhL3uRudyOyxxqs+sV8J6KMhytubouO4R00peEX+JzyySi/Wy9ZHorJ3VL6rymkPMduGaXewfC2aM1L3bHKLg5pq1p0A3wgY0bngc8dMP4WnxsRJw3eq+EF1DOQMK3skla+LbAE+C55+IntqUY4G0ZzI9s+TooitSCJWgq3x3a8TNl41IuUsrCbOluWRrwEyiosCNlZLSS6cU2IUHSnzehh2f7bMPfrVMmQAUEg00OdgZXVK8PryQuDcOQHb1AzOp+xfAUe83HfNkVzCD2mvi/jEMCiFx+ruXhHcGwzVHnGH0QZqnxV0FPEj96uC8/x0SDJlTF4RuUFQJ768M9YAJ7OpDPNHwf5LgMCPqHyCEZ/4O+DldF8epayyB7j9GGKEiFlO5V4wGSfQps3HYSyrFPiiWBkeiRzrwAApsacksRL+NbFUb9DbHVy8DjzbnWgoWXu+HssIpPybUKa85Lnu3uk9khkoi5BT2lNLB75sPPCGoLG80rk3lbzJa5JFzS0Jz5ALTGFKvtgiUwhx1azfIXwdd512B+ferZlCNYKiPGKF1MJzqgGO1BKrxzMEqNqxha8MIPbvgYeiiyulv1Z7FG+DkloLVldVCUhk3Il/Lug4rMPMET3ieOE9xO/pvoKoGtCAfaBBLhGOj7y/u5AjKYlC/1mzupJFIh7m6v8FDFkE+0l1nTBEGPG3ldrsejsEZ0Is9nAqxmfk8zNYwD+vSNlGP6sS1xilIx3cm7POmMgHIP8q7Tj5cGaTIigT4x+KeonBJrc7YrtIFg2UjpWKz94aGcUeJKyAGWXxZI9OjnHFmZ+KXTDgnhMU0o1cajHjiRfFGQOlI0pmdI5QT4TvctzSKREp1gaDgnfY3Z61eYJ6RUckWBxOVzJqU/g5XWcck+bJwIKmAT1Rupd+vKp3cT5hUiAItfTVUBBIUs+Hv409gGV2Wdjq/ZlC blI99K/+ tjyxgrJGEWcGgnImHcnBtMaM5GIyA/my8Tu6OfTF+6p5gpO/b6kpaNcLIZwNgA0LtA/kXoOvhYDde8QYgIfYYC8N6mPlfte5Etd4WpsJo2GNwqibXMVAeZ3/+6ivKuRkDS3zQRDFDsLe/6DKyRymtY+28cueQdIYJLBr64bIiyObg//67Zrn8dsP/Epr7CCXMlqkXcYXiFByr5DYoKy2BrNKeckwdoot03BTy/vt8SrPB6jOMaKdGYkaTGMS/b4M0K2Bp X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: When percpu_add_op() is used with unsigned argument, it prevents kernel builds with clang, `make W=1` and CONFIG_WERROR=y: net/ipv4/tcp_output.c:187:3: error: result of comparison of constant -1 with expression of type 'u8' (aka 'unsigned char') is always false [-Werror,-Wtautological-constant-out-of-range-compare] 187 | NET_ADD_STATS(sock_net(sk), LINUX_MIB_TCPACKCOMPRESSED, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 188 | tp->compressed_ack); | ~~~~~~~~~~~~~~~~~~~ ... arch/x86/include/asm/percpu.h:238:31: note: expanded from macro 'percpu_add_op' 238 | ((val) == 1 || (val) == -1)) ? \ | ~~~~~ ^ ~~ Fix this by casting -1 to the type of the parameter and then compare. Signed-off-by: Andy Shevchenko --- arch/x86/include/asm/percpu.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h index c55a79d5feae..e525cd85f999 100644 --- a/arch/x86/include/asm/percpu.h +++ b/arch/x86/include/asm/percpu.h @@ -234,9 +234,10 @@ do { \ */ #define percpu_add_op(size, qual, var, val) \ do { \ - const int pao_ID__ = (__builtin_constant_p(val) && \ - ((val) == 1 || (val) == -1)) ? \ - (int)(val) : 0; \ + const int pao_ID__ = \ + (__builtin_constant_p(val) && \ + ((val) == 1 || \ + (val) == (typeof(val))-1)) ? (int)(val) : 0; \ \ if (0) { \ typeof(var) pao_tmp__; \