From patchwork Mon May 27 05:51:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Dobriyan X-Patchwork-Id: 13674586 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 6621FC25B74 for ; Mon, 27 May 2024 05:51:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AEDC66B0083; Mon, 27 May 2024 01:51:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A9E236B0085; Mon, 27 May 2024 01:51:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 966346B0088; Mon, 27 May 2024 01:51:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 787B26B0085 for ; Mon, 27 May 2024 01:51:24 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 1839CA31B2 for ; Mon, 27 May 2024 05:51:24 +0000 (UTC) X-FDA: 82163103288.09.9BC8320 Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.52]) by imf10.hostedemail.com (Postfix) with ESMTP id 680F3C0009 for ; Mon, 27 May 2024 05:51:22 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=k+htRQol; spf=pass (imf10.hostedemail.com: domain of adobriyan@gmail.com designates 209.85.208.52 as permitted sender) smtp.mailfrom=adobriyan@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1716789082; 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-type:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=xmlh/k2WHauxbSWk4/FE9456r3ldOyI85ufPrI3sKsc=; b=ZAq8szJYpku2nzd8QfgNC9Om+zLfsyiRFvctb54TFl550J+zaq6eOJLy9cJld3jLZc5GOt VY2kYWWrH0l3PmZq0icmBEYrVRzfk+oaKXz7Cazn/BNLAuBdWRzhTdkqMcm33wZfrITA01 jSFdcIxILFFV41t3c6dQF1N86QZfdXc= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=k+htRQol; spf=pass (imf10.hostedemail.com: domain of adobriyan@gmail.com designates 209.85.208.52 as permitted sender) smtp.mailfrom=adobriyan@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716789082; a=rsa-sha256; cv=none; b=hV2kniW3KipAZuSlyc3tfkQvZI2wKXtA0bwbFpiJmBGn6n+//LxBHITPhibtzDksCzMz9k DxnJgGM9zlMXTQdLKthbUmunimW7g3+koMTckgy7pQq2eZNJtpuOalAcX9dM0haZv+r9bE XkbYTPVbSCc1b/DswhYzISCpCDTnuOA= Received: by mail-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-57857e0f45eso2019308a12.0 for ; Sun, 26 May 2024 22:51:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716789081; x=1717393881; darn=kvack.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=xmlh/k2WHauxbSWk4/FE9456r3ldOyI85ufPrI3sKsc=; b=k+htRQolOigac67VNsiIb27NTG94ven2RHGUPvAxmgDx2W3Vpk1FLMV92N9EEQQoNH uTNArXcx7IQskeS4IUCI5WAb8oaQCM+m83+FTUy8S+QYY5CfyGNSuHu79urphHJ/r2Ya V4S2Q0NV4FGzD+3HYYVkEU9QA3xtkSbqgHSQ27UAfbLzKmZjM6gt7XrEMSLU7WSHYHEB 8N8IS0GaA2y2bdb0UBmsWu22WvnKkS6WSbUIkbOhdUFMsiLtPjh21sALnSyOjfegMiOw IROZ5MW4JIm+pL2r/f8uzGH5rd0dGqk27Pa6Wx2ccz1ENhqedZVinpMHN+4OiaaMMilO X9lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716789081; x=1717393881; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=xmlh/k2WHauxbSWk4/FE9456r3ldOyI85ufPrI3sKsc=; b=w0gvO+SPN5NZPqRThZpljYARn3OvVrRd3Rhc5L+HM+8ZhRdKra4ICfHsvXvsgNcj9X qyOKE1VRaqEc6HbYuZxdouBHYHSR4dV71zPlfOeOAGe/wPZdMPACHtqnqrfWJVkm6w/9 bf+ST3OXuK8jJB1b319YpFfNc/qVHUOOtKebN2U8O5SyNmpZ/m1b2n1AlrfgQ/p7N55I UcM7yx168vOv3tQKk/PS16aC4CcD3wxKyMZZ1l2cWcZXGTdjsRv/qip0+o/YgW5fWIzc o7sRrhpu5qrvat1X7CzB5ewDlEoImpucg8J5zZrLi9MCtWuvIyhLc8HUDVSxkbZEMzPH yZsQ== X-Gm-Message-State: AOJu0Yw1dGVXfUmMxwK8TM64cVQKcX17ruHJl9FHW2AFUrZEusCvYpkt wGKNzaKXkLrYp53iVZPwA8XmuoG0nJrWy0Mr+wvUhRsndIj0H0U= X-Google-Smtp-Source: AGHT+IHpKQ4G8mPdFx3KsuEFuJI9OrX8x66aKHeJ/VGCTkqxMNNjzI1Bm75kSkUtsLpaErPEQzF8OQ== X-Received: by 2002:a17:906:6b1b:b0:a52:6159:5064 with SMTP id a640c23a62f3a-a6265119d80mr931098666b.52.1716789080396; Sun, 26 May 2024 22:51:20 -0700 (PDT) Received: from p183 ([46.53.253.56]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a626cda6cdcsm449917466b.209.2024.05.26.22.51.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 May 2024 22:51:19 -0700 (PDT) Date: Mon, 27 May 2024 08:51:17 +0300 From: Alexey Dobriyan To: dennis@kernel.org, tj@kernel.org, cl@linux.com Cc: linux-mm@kvack.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com Subject: [PATCH] x86/percpu: fix cast in __pcpu_cast_* macros Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 680F3C0009 X-Stat-Signature: umq6mko1pg4i74mqasqgy7qqnnypsi47 X-HE-Tag: 1716789082-779587 X-HE-Meta: U2FsdGVkX19ZAlLTLYGLYJWdnm+kV12XeTdbd93xhPw6yr96PcvqcCC/IrHNj6FfSgARqcHP+d3xbjukm6jRqkqI0O8sEroATqiCkK2vp8djuhTEa0HCZWimG2t2u4cYeTgpjHXZ7m1mslDVm0fK+YSYV54/tGNQwUeEU1V5mHGoQck3HPIeFGErzQXaWq6qDgYzROMfdTbsyzvkWZjip0UbBoZGK826JqMPtSJQPJrVBt5e1IhSxQBnhjR5FGGWI8FRoBHniCarFpA5jD+GYTbWQ1oWT5ioOclt9lhaiXdtJMBKezer/jwtMjp99iEm7frRajOrbAGlvSzOxjQvByuouuy/BqGjCv68CqpoALCWuS/MPEV8ySgeX/frsQ3NUt4B7mVPNDt89Y0qDjuqqMRsioRd1uRQ29uzi4DfVg6MuXVnPL5C4/y51D77aAAp+faHJWlF7Wl4KswJ6XisVU+v7iMyUchM/sdCtaX3wdywbVr6qokb+ynaLhePqyhpI2ieBSemswPVR9WSK6Ubilb1Bs0lFiQ1Z3If2PSvAVRzJZE3WOiFr309N9o5fQ0/QjCdk6ebgut5xEshntfT7OYZHEZigy1G6JOC/sz1X+EtCo/XzzDSqyqGR7JdhOzIndMPDj7n6lEBdMOac8ABFut2or08gy/V9BtbQszg3Y9hFeSteIwdQbJ0TyAL3nv65N3Qd6FOwcPW5X563WIOQH5T77cam1asu4XNZUuWFjk547P3Gfz0FjGyMVUAszb9Sva36iVrj0gyWzZJ5DTZ/o1wZzajOgjjE/EuimJI79xTSzjvSylPHiBK4SA3vjs8esF3ggf2kvnBW0sW//icsuy0ZZB57MyQVsvPM/8iImhsXbmDPujlLeimi9hnIFWpoWY2htOKDXUSq6tqd2ZIjXYZjQSJJX3DFMCV4chl2zi2Wv3J/xoQ0USONsJx7QFg4T+OLDMp6HBlDyTUNnJ y/UI1+tT lJHu9BytRDH32wHfEA+B29xepyN62MA0K3UlahLkM5CVG4p+B3Pp+JP0C/+h8Eoy/o6wHzY7d9T4G7lcR7ESY1QuZpoDU3vCMXDyHtyrFwbDUhDAyfUY2ac2U4Hw+cSbcgkdd4z8NSnGYwXCFahVtdD08J2eTGIm5JXavfpD5FCk6AkJ24SKBBHGp2x9wgAHXiT7jG2Wh3gBTPbKghY/O8SNEMfXvM+9KRbX9nV50q/9BnFT4q32RWLNyTnLmsjYyGLr+lYQudCyZG7lxQOQGQjtsUAILhXjV8VR/nGe6c+OOfTXxNMO+c6P2JL/LHCfN0Rx5xa8cfdNdyCy2wYTRCw3q6HCHdgH2P335BrkXHcrZHrA8LnUPyTAk0LrTwZAkAz7GD7zNboGx4wSBws8QOuNAehQqfcVZPozPR4JANQmJRaPf4zdqznuURcpEZVqPaCVkoW5FlQAgEBBJ/H9bnTGDO39PorvwRGUhALBnv6Gblpbocrl1tkILfg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000104, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Fix compile failure this_cpu_add(*p, x = 1); kernel/test.c:7:29: error: lvalue required as left operand of assignment 7 | this_cpu_add(*p, x = 1); | ^ arch/x86/include/asm/percpu.h:134:51: note: in definition of macro '__pcpu_cast_1' 134 | #define __pcpu_cast_1(val) ((u8)(((unsigned long) val) & 0xff)) This pattern is almost always wrong: #define M(x) ((T)x) also because it can't be used with assignment expressions: cast makes left part of it non-lvalue and assignment to non-lvalue has to break compilation. Signed-off-by: Alexey Dobriyan --- arch/x86/include/asm/percpu.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/arch/x86/include/asm/percpu.h +++ b/arch/x86/include/asm/percpu.h @@ -119,9 +119,9 @@ #define __pcpu_type_4 u32 #define __pcpu_type_8 u64 -#define __pcpu_cast_1(val) ((u8)(((unsigned long) val) & 0xff)) -#define __pcpu_cast_2(val) ((u16)(((unsigned long) val) & 0xffff)) -#define __pcpu_cast_4(val) ((u32)(((unsigned long) val) & 0xffffffff)) +#define __pcpu_cast_1(val) ((u8)((unsigned long)(val) & 0xff)) +#define __pcpu_cast_2(val) ((u16)((unsigned long)(val) & 0xffff)) +#define __pcpu_cast_4(val) ((u32)((unsigned long)(val) & 0xffffffff)) #define __pcpu_cast_8(val) ((u64)(val)) #define __pcpu_op1_1(op, dst) op "b " dst