From patchwork Mon Oct 21 08:07:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 13843712 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 E42B3D0E6C1 for ; Mon, 21 Oct 2024 08:09:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5B31F6B0083; Mon, 21 Oct 2024 04:09:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 564016B0088; Mon, 21 Oct 2024 04:09:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 451C96B0089; Mon, 21 Oct 2024 04:09:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 2A0A86B0083 for ; Mon, 21 Oct 2024 04:09:05 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 43DB8416A7 for ; Mon, 21 Oct 2024 08:08:56 +0000 (UTC) X-FDA: 82696883052.09.D5E737E Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) by imf17.hostedemail.com (Postfix) with ESMTP id B4B8E4000E for ; Mon, 21 Oct 2024 08:08:51 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=bimxO+A6; spf=pass (imf17.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.167.41 as permitted sender) smtp.mailfrom=ubizjak@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=1729498067; 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=MgLMq6LBoZI6oopSlHmO6YDXt32997TqTP5A06Xl6xg=; b=OnDfStZiQxzJ5U/1y7YaMVWrMF02zcqfGqJLKTPSyhtng1UbCK2oR1066/opF4OJZp3djS KDIN+pOa2FUptGrqFe55QRVVIdmT2iEh8bmwGe6/FtezLd+xkABgtnbtu1wFbGG7vE75xE DOGTS+CmOfbM7jnC5zKzhfOorGbrrAc= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=bimxO+A6; spf=pass (imf17.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.167.41 as permitted sender) smtp.mailfrom=ubizjak@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729498067; a=rsa-sha256; cv=none; b=jcCpXMgXFog2voUZgw0FYCMdG0wxbdgvVkjbqQRBJZfdzKw7nTQNmwRjuCkKY9YssuWGFg 7i+iDWTLpKuxqGmvRqEht5M700iRqpCEd5ZOOPr7CKDFbLA3t1yJ5g8D6WiQyTpgrBCp9L GWl0viVh/I7Ebpdkwlt0tTwlvuVZhes= Received: by mail-lf1-f41.google.com with SMTP id 2adb3069b0e04-53a0c160b94so2110347e87.2 for ; Mon, 21 Oct 2024 01:09:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729498140; x=1730102940; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=MgLMq6LBoZI6oopSlHmO6YDXt32997TqTP5A06Xl6xg=; b=bimxO+A6ACHCocUrmGfS3K5lq0w7/jdvlGYvmAPLJfwVBAonP0zqoBJ/dKerQqnEFI U6n8ryrYTGqSwDQr24ptWSMnMlOO1nackduXpRIB18/EwvRXtQ2z+FxcT3BocRW4YA0h 3JFIom2mwkwkRVChHKYgWCM6QYmBBGfy94hsBKy1jTtqOWjljETWPVLPY5KIPG21nnqm m+EZwVSkVmZ5QBVygm4M+T+CJb+7nhMOA2LA1+aDeGfay3JW4MwF1j1PaA2AtEYtRfah Y7NOR81YdGo5gbyNC6UbwepbB381fe7ImFhyqEimuf+CZezYUrVOf030kobMbSdlqffO T/eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729498140; x=1730102940; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=MgLMq6LBoZI6oopSlHmO6YDXt32997TqTP5A06Xl6xg=; b=YTh9TbxWYvTxMkbpJWQY/MDVZIWLGIY15VtozFDakf1bnLCcJKpMKejoZuo4cBKSl/ /kD0hQqlDppCKSvN4+268ZCaRgcj0XnBTSRNHzrT9ynDAPCu19IwWIbpMT/kxTdUpYUh /s/cJT/HCTNAAOsUsvW9JC08kG8qJBQPfiEwVRcjIpyXAeZTUUBhEq9nD7ElVRSOKDuS TEiZTknY+rUVeTAsoCQQZW24KmGk3yrtp7V61Tdt9DskSZyWmHwWP/Am1QrDVBEc02h3 T1xkJ8TRcL/mN8yCuisnrpQQebNE/p7tzoIGFuTYMgIdUWp1jelMLry+qo2taSGGbPqf yg2w== X-Gm-Message-State: AOJu0YwXorQOG9P33lBoKq/ZUT7m3ar7vktWIgHSzTSwfDlrN6KukCdQ /YgzdcwdmIfdTzAqHF3hLEZccx5irdT0jdzOiSVdpqJdzkm09Yp8Zk4o3Byg X-Google-Smtp-Source: AGHT+IGm0I9oGoA3OhrkX1KUADo64ViH/3eQUSQekHaiP/bGYrIQVdLkfV11y0l2rlbfKlc95r5Daw== X-Received: by 2002:a05:6512:3da2:b0:536:54df:bff2 with SMTP id 2adb3069b0e04-53a1546fda4mr5124132e87.54.1729498140061; Mon, 21 Oct 2024 01:09:00 -0700 (PDT) Received: from fedora.iskraemeco.si ([193.77.86.230]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9a913706a7sm175925366b.141.2024.10.21.01.08.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2024 01:08:59 -0700 (PDT) From: Uros Bizjak To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Uros Bizjak , Dennis Zhou , Tejun Heo , Christoph Lameter , Andrew Morton Subject: [PATCH 1/3] percpu: Merge VERIFY_PERCPU_PTR() into its only user Date: Mon, 21 Oct 2024 10:07:36 +0200 Message-ID: <20241021080856.48746-1-ubizjak@gmail.com> X-Mailer: git-send-email 2.47.0 MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: B4B8E4000E X-Stat-Signature: q5wox6twnphejwdbb7memqkquc8xpcw6 X-HE-Tag: 1729498131-22086 X-HE-Meta: U2FsdGVkX18abezQlycR0k+CQZvzL/WMIlLP1D1/+MmIXJvlzvhGYmghV7DvSk87LWgWLBUFnf49CDCZ0yfCZCUBW1Qf4mMsHNvQqPQtDHrlTdbFOA8E0j6KAGktzG7ozU0rBfWhA5ob4P8tZ9FXyqOSCuK6FnjF+ECuuabycMr9vu8CbZ9zeZXQD7IRAryPWvLRSCDVHP8e+sNZ1lS0y4hrFIMozSybQEzDf2kyz75AjUpTXBDM2oepeSTJ6ikYKwTTSPqgossloIOuRiD21vcRDU7JW0JT6XiosceKv0ZsdPzAbnT3BtZ51UCOvR0gN5MMmSHAK4e0dRsdZqIK847cbHcO6E51zDR3RwbMWcoLZU4+j5AjAz9U8sL+UU90DmB6iU9pbfVK1Qpbf0DtwbOSJ4Mt/pvQ884v5n3wskmP3iBe3eSr2SQma0D6+xjlzqhNabPAM08Rj3Pm2UlZIKQK04X6K+ak9TUEFn6kMviKJKeGOshejWdZw+jvtWjm1O6VFktmHvrlHnjN7BnGjkJ0bUev/YBtyRlmp532t7fPjRbDqAo7CrWKoEjQSrt5uZlKqK1BvVhro0scLX9nSrWnHQ9IqnmuumNqbfYp22PWjhhbVjBmHp1/AgZNRClZmOuZNkMeeOHqwc5yDoFRZmPE0wFxEEwgZhupP+OKkLWStARi929i7ZhjkbCIPryERUDU84S8075ffhO6pxmGUkihxshn3zbCeWVuEPkUuTD8UOSZe8mR4+WvsBmC3LD0MXcv3/9szmcNKAiZ/ZnvGqN225RGCD1pJ0xj+zci+LSjvhT59xJtn0X/P51qSyUsRYKSCC7WxjuiCE45iMqRRqI0Rl5NWTsIkO5/NS2UyJ8sC2/wd2rxd78Whc2hh6lw4kG+T0nnGzHsccx/ivLJ+7R+XnfXYm0ncW36GCg24ncvPq2CWg7b4mzFwkgVdfR9NY173CmvGSYCTqYCSVG BMDBdF5S vIaUGIUxc1SDpQZt2KGZu/lNBrm5yVEe2z7OOcdksQNglprv+2WQM+pAfKQio897048jHeAbg3NrRBPXHBF/spEBKBEOAE9Fw193PTpo4J5fX16SrGycIuJe8LexIc2px7qMsKexFHPx26TZ9xVybAPJef1Ap9J3TVpNqI9azAl3Puz/PBPs1hO/5Wcuvbe967cQ9qGq1hA/sb0092yRC0xRRkT7TtrF8JNeEP5LRKJz0bHRppXuZCJc0HPKL30alKsaFvv/Kl9Jl7GxME1UrWPGUKmtpybe3l4KqPzkCdM51te8qjmOMIrBSOEuvPCIHsqHGKd0j5BZ821hrlAFv10kTdDxaf8CRwLhsRngQ/pH48NCU8pb0lJKYG3slSEPGT/sLinMlPWsmQ2OcrybPrHW54h1ipP+iIwbh5eo7DtilClsIOR5Gji1NQLBdt9CX6ToHoX5Rc5nITLQWCA5YgVk0HPog8rIIaqSaYeDVy2YARx8zVlamrEUQAdX9jrXqf86ILNxex3g2SYMr3JM0ytv1PmEsqnPzmHzV4IJWYbShk2FTXn7AoqAnXg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000003, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Merge VERIFY_PERCPU_PTR() into non-CONFIG_SMP per_cpu_ptr() to make macro similar to CONFIG_SMP per_cpu_ptr(). This will allow a follow-up patch to refactor common code to a macro. No functional changes, non-CONFIG_SMP per_cpu_ptr() was the only user of VERIFY_PERCPU_PTR(). Signed-off-by: Uros Bizjak Cc: Dennis Zhou Cc: Tejun Heo Cc: Christoph Lameter Cc: Andrew Morton --- include/linux/percpu-defs.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/linux/percpu-defs.h b/include/linux/percpu-defs.h index 8efce7414fad..7fa88c5f4b26 100644 --- a/include/linux/percpu-defs.h +++ b/include/linux/percpu-defs.h @@ -254,13 +254,13 @@ do { \ #else /* CONFIG_SMP */ -#define VERIFY_PERCPU_PTR(__p) \ +#define per_cpu_ptr(ptr, cpu) \ ({ \ - __verify_pcpu_ptr(__p); \ - (typeof(*(__p)) __kernel __force *)(__p); \ + (void)(cpu); \ + __verify_pcpu_ptr(ptr); \ + (typeof(*(ptr)) __kernel __force *)(ptr); \ }) -#define per_cpu_ptr(ptr, cpu) ({ (void)(cpu); VERIFY_PERCPU_PTR(ptr); }) #define raw_cpu_ptr(ptr) per_cpu_ptr(ptr, 0) #define this_cpu_ptr(ptr) raw_cpu_ptr(ptr) From patchwork Mon Oct 21 08:07:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 13843713 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 1A9ACD0E6C7 for ; Mon, 21 Oct 2024 08:09:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 827676B0089; Mon, 21 Oct 2024 04:09:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7D5586B008A; Mon, 21 Oct 2024 04:09:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 600E06B008C; Mon, 21 Oct 2024 04:09:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 394AC6B0089 for ; Mon, 21 Oct 2024 04:09:06 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 0FA5F141691 for ; Mon, 21 Oct 2024 08:08:50 +0000 (UTC) X-FDA: 82696883346.25.50F0644 Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.44]) by imf06.hostedemail.com (Postfix) with ESMTP id 7AAA518000A for ; Mon, 21 Oct 2024 08:08:53 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=fajedcXf; spf=pass (imf06.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.218.44 as permitted sender) smtp.mailfrom=ubizjak@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=1729497994; 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:in-reply-to:references:references:dkim-signature; bh=rTgNpqhipVGwhNAGQddK2AXXajHj1yP80Vug7RbRg/Y=; b=eATncBk3TZFc7cJmXRJg66gX4aT1zsKzjAdAqGbByR27W8L6DxMXZ4pvuaB+lftFIr3OVA ddUzGPuvz1MzerVWL4h+3tGVGc5FTK/PlfA7s9I7I9DsH0DspEWc9abrkXZaIu/nyPtdDf tOIDdEufRVnTF4V5zsP9JIaD7LXeM40= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729497994; a=rsa-sha256; cv=none; b=VbRKmTDms3zFCdqUmA4k9Xh1q4u8AXxpEWgDMkrTrK/k+rER82Ko6tvSvkvjHzc0rbIjTr lLdYR+YsdKhai4htKfXY+SlTI0hm0oVIPXFR/+XPD9u59POD1/90sXp49KC4lyRKkjrzdZ wxdM+chzODLRKyd/HCAVuqi3Zgwu9AE= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=fajedcXf; spf=pass (imf06.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.218.44 as permitted sender) smtp.mailfrom=ubizjak@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-ej1-f44.google.com with SMTP id a640c23a62f3a-a9a3dc089d8so575878366b.3 for ; Mon, 21 Oct 2024 01:09:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729498141; x=1730102941; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rTgNpqhipVGwhNAGQddK2AXXajHj1yP80Vug7RbRg/Y=; b=fajedcXfLV1R40U72TMy2manSwFTWU+eoWmtGeXfy/izzNcNQpGXflll0OhwOykzu1 4GzFPIUnU7k8hAhNJQ25ALW9whwSeyDevwFdjSvcwJ5offgDI4LcWjs0xELCYzhvcj96 QJXqLVjG6+ucRnp+q77qOBzUxjSWs69YMMNSzp+TiFQWgeLrS6+r/QmdsTrtWGPX/51L CPqAtilYxym7Xn7XIYbhiCNe+n+uJImt1zR2gEcOFkY3BoNjstivJgh18U3+WFKYaPyL YH6aNxhb2HOdKtF3+oPrTyNEy2Ll3h8m+gUMEhQK68L2QDzii0YgdnQBNrHrr9gnS9of OE0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729498141; x=1730102941; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rTgNpqhipVGwhNAGQddK2AXXajHj1yP80Vug7RbRg/Y=; b=UCIs9cknlgg3Mm3CLmxCkECfRfbVVyYQclixh7gqkKPLt0fKrrxDlbgpvAD6kdkS1a VPSv+XvWYouVztWLV1iPYkLzkGneTRBgiH2zi+9D2B+EVRkSSw3v+UPOBaZtqHtb+1fN uTsZ+jHTI5ygOmjkRIfh7Oe/TFB+VWpjomav0a/EwxCkNz8yWyu0n76qnGw4Fp9blNXf P6VcCULNedPCVz8lPT9j+fBelJzLd07OF82GgLkxiiMU6Hek/Eg2xBo1GmKctDI7yYt2 xyzTRd1VpCvxk5vzITaqu03z2bbM4IRlAQhFlDnBkBG1XQyyd17Mg8izvgB8VeTCHoAz GL2A== X-Gm-Message-State: AOJu0Yz35iDsnXXmNPyDmgr7wX/D7jbSqglf794Ip1xS3t788Z0zmnhg XYUaKRoCRHx46RBHuNApdETtXMSLczouy+nxsT7mK0a9lrBHD6PRH3eqxWtv X-Google-Smtp-Source: AGHT+IFr6qF5yVsAlRtiA6VJhMs6VUjMqn5VZl2LAiGXV+yzR5IZMR5hiN+C58YaTrZuTIRNejvYIQ== X-Received: by 2002:a17:906:c150:b0:a9a:a32:bbe4 with SMTP id a640c23a62f3a-a9a69773838mr978103766b.12.1729498140818; Mon, 21 Oct 2024 01:09:00 -0700 (PDT) Received: from fedora.iskraemeco.si ([193.77.86.230]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9a913706a7sm175925366b.141.2024.10.21.01.09.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2024 01:09:00 -0700 (PDT) From: Uros Bizjak To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Uros Bizjak , Dennis Zhou , Tejun Heo , Christoph Lameter , Andrew Morton Subject: [PATCH 2/3] percpu: Introduce PERCPU_PTR() macro Date: Mon, 21 Oct 2024 10:07:37 +0200 Message-ID: <20241021080856.48746-2-ubizjak@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241021080856.48746-1-ubizjak@gmail.com> References: <20241021080856.48746-1-ubizjak@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 7AAA518000A X-Stat-Signature: n1x1gn78q8kxyzb4xrtubn5irw677orq X-HE-Tag: 1729498133-399788 X-HE-Meta: U2FsdGVkX19ZGi3uxhbw2YkWnkemCX7xOIarYAOKm30YEDv9mg3P2TT97CI80pUIqg0i0GNnDfx/so4ZtgTCzOTX69QFUPHKNwylh/odgEZO0eclur6MLyWzDKolCKuV7TIWFKQ3ZBkh8QV5TqzbtwWnIwCbbRFDhbCGXMY1MxBsKCoBxp4gNN0EvLkpy8U0eqMrg26Y9V8uWRujexOnk6Mtz96osVbGnp4u2eJaHtJT/7SpT2useTvEflQqShkKfWnj1GAiJeyRUB+H9axgjq51rgHVpjDJaVe+AZkdMIS20JvbSCKm7IXbhf+wF2xlsOCo8jVs7GXEZQstsFm5iuzNEjIDVOuvtNARGmFKG9JufwIGXn+Dc1tJavnccJMlinOjB0S7daiTkvxZ1aO65R2zxSV6z+i8LszRrgTaO+Hvj3lXjrejnlm0jLYaE+uDCV9m3Tm58HvVuM0fmkkwNUprjZZ8TZLaqYz1L0ANzi2uo4zmmJCWTExEXcb2NZCY2jhO5czngip9U+U9P7hwmTRCtOmkQHtdHUIpDAut/Gd+1xwYjxxH6Z8XAWGLUb6wvTN+KTDSquEVJDG5EjY/bkZd7bcdmEBfKuAEi7UK5x7dWPVHzTTVoz5DegY0zqM6hTjbVr12NivXR3QPAlXt5mjA4LF528iK0O6yQIl9y7oHse/kyO7YCIrNvCLjLwiAa4QW22Go7HKVwQCsSKi4wlPJMTr9w9GTRA01SBoxoSoksftLBUkjsnM+WM8tpHrIWhsf2tp85cz+NCNLVSfQqBFTYTeHK8QlLR28UUsuI9WkV/Mu1540dzLOraXrWQOWadCU3hISF7r4BxbBkk7X9Wfzo1603pmQrhCHEYaRJMEawCJtU6u8ygjzlsIHVM5pcIggwaOCuRHHy43thRiYTmdERt7jAzJYGgoDwXjkaMhcoj5P3Bo8tJKV/6RSEIDNekpuOD0VpIjFlHDQUKu dXAXrZii j6idQ+10mGAeRcNcPRGKRs/UsKdVFtLMDtR6wrDr2ZSUogysu176PtDVMUPos+Q60NLGHD5ei0MfM6KTvIJ6vusxbbfIE/8lzwMALlcXf9ofjDCy9wdEC8cfS1L+KRUqkpBKmCqc+zHBfyYK3SEzEYipaNKMBzzwLyDzvpJx3lzKRC0uBnk3dmJ1637GnsTpgpW6ke2kzXhPZH+Re5nQ8wtTR4f9w58mkqvvxOolHJjRN+OeX78ZZ0AGG7QkBRthh/+6cFLzVLcb8Y9ewfwgkS3dpJQpf1xFEUCEFT4k2W8TVJa0xWgBc8KbVqU8KTRSDohZHCFKe8wTsEnwS1q6nvFS2LrK3N0MBLfUZmg5yNlCbIheHJqHS9eQH7GIVX0nzyiPSj/Hy1/vUQ3RHn+A3Em9fx8EE/D/fVgcZ+74rrmQE+a9DNvfw7P4aymu4ViE95cQBBddKhrzmr94SgkXVYPuvGYjqAXPWhUcfh9mWMLXkpza1LFWK+1rmCVaIHQy62Ug9kkXxlrkB3n23NBDg6AgqaRIukw1QXcdgT/oID2J5dfOk27SdopfrHw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000003, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Introduce PERCPU_PTR() macro to cast the percpu pointer from the percpu address space to a generic (kernel) address space. Use it in per_cpu_ptr() and related SHIFT_PERCPU_PTR() macros. Also remove common knowledge from SHIFT_PERCPU_PTR() comment, "weird cast" is just a standard way to inform sparse of a cast from the percpu address space to a generic address space. Signed-off-by: Uros Bizjak Cc: Dennis Zhou Cc: Tejun Heo Cc: Christoph Lameter Cc: Andrew Morton Acked-by: Christoph Lameter --- include/linux/percpu-defs.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/include/linux/percpu-defs.h b/include/linux/percpu-defs.h index 7fa88c5f4b26..e1cf7982424f 100644 --- a/include/linux/percpu-defs.h +++ b/include/linux/percpu-defs.h @@ -220,15 +220,17 @@ do { \ (void)__vpp_verify; \ } while (0) +#define PERCPU_PTR(__p) \ + (typeof(*(__p)) __force __kernel *)(__p); + #ifdef CONFIG_SMP /* - * Add an offset to a pointer but keep the pointer as-is. Use RELOC_HIDE() - * to prevent the compiler from making incorrect assumptions about the - * pointer value. The weird cast keeps both GCC and sparse happy. + * Add an offset to a pointer. Use RELOC_HIDE() to prevent the compiler + * from making incorrect assumptions about the pointer value. */ #define SHIFT_PERCPU_PTR(__p, __offset) \ - RELOC_HIDE((typeof(*(__p)) __kernel __force *)(__p), (__offset)) + RELOC_HIDE(PERCPU_PTR(__p), (__offset)) #define per_cpu_ptr(ptr, cpu) \ ({ \ @@ -258,7 +260,7 @@ do { \ ({ \ (void)(cpu); \ __verify_pcpu_ptr(ptr); \ - (typeof(*(ptr)) __kernel __force *)(ptr); \ + PERCPU_PTR(ptr); \ }) #define raw_cpu_ptr(ptr) per_cpu_ptr(ptr, 0) From patchwork Mon Oct 21 08:07:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 13843714 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 01756D0E6C1 for ; Mon, 21 Oct 2024 08:09:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D64CE6B0092; Mon, 21 Oct 2024 04:09:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D11976B008C; Mon, 21 Oct 2024 04:09:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B347B6B0092; Mon, 21 Oct 2024 04:09:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 9844F6B008A for ; Mon, 21 Oct 2024 04:09:07 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id A6AE4121691 for ; Mon, 21 Oct 2024 08:08:53 +0000 (UTC) X-FDA: 82696883304.08.ABEC8F9 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) by imf29.hostedemail.com (Postfix) with ESMTP id 1470012000E for ; Mon, 21 Oct 2024 08:08:45 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=jbW8wNWh; spf=pass (imf29.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.128.50 as permitted sender) smtp.mailfrom=ubizjak@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=1729497995; 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:in-reply-to:references:references:dkim-signature; bh=dGYDCgTegQahGt6W0OyeaxxuCRjXY1E2wgBMnm57zms=; b=SiVuwp9No19PEA92H/zgUPm7gKumZkpk50+6Xa6zQRL+j11UiITPDGVQskIbWukw5XMsvQ fIRrVTQbpKTQOhvlJGgRX8xcH8DNXgz87JHbgkaTLcsmau73EcEmPNQeZK6J6C2lvcnAUi VEUBwWDZ1EQ1mQbkLR/oZhXoTz5ELoQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729497995; a=rsa-sha256; cv=none; b=0kdzPSFNh4HZOioeCt+U/2Js3jtbZ9/raKLxG6ICyidGZ4dzEv/PjDd5ZKplooFLPRpmWC Tq8AFBV4QPZa1prQ33bwME9r/6rR1GtwRfpOCtSjSPvZVxnBVbiT8w/scDz6rbXtuV2GZz wiyYLKYPIdyJ4G1kuBfd8JSnsoNY9A4= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=jbW8wNWh; spf=pass (imf29.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.128.50 as permitted sender) smtp.mailfrom=ubizjak@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-4314f38d274so57345965e9.1 for ; Mon, 21 Oct 2024 01:09:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729498143; x=1730102943; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dGYDCgTegQahGt6W0OyeaxxuCRjXY1E2wgBMnm57zms=; b=jbW8wNWhUUJmxIuYwd4hYRBy1VEj0EpWiCbSLoU5TYuv7xwkKUn8hEfCtJEpn/kA9a 01mNa8BcpcFU0421bu5SrrXNcVr4mL8HBxus9nQ+jEtebh+Ui8v0MgjlZtaqCbhU+f1a lQwH02YDtSULwvBxqGbf45qu/HDj1yiFftBRovx/nEsv74U3utx/OQXGc4mmpbP6etZ7 RY4yc3a49pHJZlQEwl5Mx4wE4xYsj3esEX+HP+/sUHVpVD+i3xlmCB1AgQgfD27amqFM 8sT5NhUSejKAyeXUXaAcaLHorWdkBh5oWVvDr+T7mFnMBnT2imUGOvYSg01wHdssb5Uv Qylw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729498143; x=1730102943; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dGYDCgTegQahGt6W0OyeaxxuCRjXY1E2wgBMnm57zms=; b=SHJUu2oyYv4FJMxfyKmI1i3MwT9/hkDwGOJFWrr02DDT6dQzVEfxh4PGi5YKtRsYLe zDmOXRTiKzPuloJ9/m/hn3rI8r2zVjx4e+w9cnRL2Qu0YA9PsyVh5EPWuZISxcn+X7xK kdFqezk9F5EKLdjoZvlxsHq2GIg7iTNGsEI4N7l+PCqKcooRnpugzrjEi6UAr8AQdLTW PrCg266mv/ics7Psxg5ECkMyzXropSrpxF4XnuvIFMcQtkG9wzjlL0ma2g1oMDqnEzA6 Hhkg6TTSu2WvK4PnV/9HkvAolvAwLvVRqomm4RPRXCdJvVSh6KvuJ3sB2qRLuxXdRksc zkhQ== X-Gm-Message-State: AOJu0YxhwZRRFof6HuREMNOMBzDh3ovCB3rj7A80zniAt9hRIK6z3TPc DrSydNTMZ7f/czShimJei35G4ooxWBN77OZSGN53KynndpDe+FUUC35Ve1c4 X-Google-Smtp-Source: AGHT+IHFQByHjFNMRT59cjPcxA3RcXY5ZiMSkbh1QNihsbwHAb2N9O3yUVyeBVPBGs/Ass4ZkQ+uMA== X-Received: by 2002:adf:f9cb:0:b0:37c:d1ea:f1ce with SMTP id ffacd0b85a97d-37eab2e303amr11142282f8f.25.1729498143150; Mon, 21 Oct 2024 01:09:03 -0700 (PDT) Received: from fedora.iskraemeco.si ([193.77.86.230]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9a913706a7sm175925366b.141.2024.10.21.01.09.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2024 01:09:01 -0700 (PDT) From: Uros Bizjak To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Uros Bizjak , Dennis Zhou , Tejun Heo , Christoph Lameter , Andrew Morton Subject: [PATCH 3/3] percpu: Cast percpu pointer in PERCPU_PTR() via unsigned long Date: Mon, 21 Oct 2024 10:07:38 +0200 Message-ID: <20241021080856.48746-3-ubizjak@gmail.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241021080856.48746-1-ubizjak@gmail.com> References: <20241021080856.48746-1-ubizjak@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 1470012000E X-Stat-Signature: 55nwkr3rhy1hf5jww3kxyo1xxo6xyds9 X-HE-Tag: 1729498125-950717 X-HE-Meta: U2FsdGVkX18WrGskn3hA0qmHQBVA1tXAz4ty0Ko1E/aBn6FViLLHvqSaT0tbHMx0eYuUgZwUIa1NsdjASLpx5FAaEnAgUed2k47zF37PYKR4Ss4CbjCQFPwCw9R2AjT+ddTByOFP/7P3oFQuV4pZN25Xo3yLBaJACn9qmacN/RC5JTq4ffODcsnBMrXb/6wnYZJIkoaD3t61AOpDtJfb76Xu81jyfIuR+KP2nrvfttC7mHJjRqDB3Td1K2ICS4WoJgk9h8e3vm4dNI5crtGUTr2ECyvv2b9/x36Z5pHnh9rlM4uMT2qjkVehnNH9l3cIxZoi6gmxzxC345833bLuOLXR2JNxius7+6+3LM77mOylQxamEfQx57pi0SZo6JaRxkN7EijLbi9+TS/Q6Ef6y6FS+StGZpPF1lcpyk/rJeTSLDD4PtRROKJoUfxJCyue01nj6BHxziqzsb5SQzxePuoH5bVPiL6GA5KSm8/duvgZLO4IheB5xBzq+A4yMgK4kpHFRfqPelqw/rfuDg7d2yJs+GJLDyBpkuYuLOLXubEpvtJ21spo8r+/w936bYnoNGK08Fae2bYvKyDz8RGPXucDanNxC+MKF0Ix4SFAhtXi/6q0GLtCu+6OR7UkWEWCLzjnX/l10/ZlGzFKkkzoSsUW37wOxltdfQvAt7k+a70PmIoPK0l6aZc/cr9n/nSJ07goNIrylk752Jjg8InR9uEvq2rxVm0dGtqJymogG94YaQmeIj8RfrWvubKRpiccZX5ai2n7qDKJSDdq3K2DA5cin8I1NieTTnFgBufWSvTqL3L073b4F9SYqB8J80n2xWQeA4HtGHNWiQzL1qHIdRz3WO9z5K6BpoFC6an81//0DSwg2AQOSXldECpD+UH8hGqM7kDS3hNuDmNtPfwtokJwNVz3Q/0Tw1owTN50FnJXqV6fhH7ml+/D01fGZgBjN6QZuR1pFLK2izrR0KR yq5M6O4Y dBsZle47dx2N2ooRR0insCceMUOOhiV++Ay6nenUv1545MuDnX6/E6b0lLW1+daT4lKAukTLb9BnR4h4Ax0q/Vy6afeDZAxoDEmX4IIK1W8fFRsRhdOPHLNPJG/JZuovBYpKdu/8VzCdbIOUj4gmOaUHJc1b5koYcUixwjAcQP0+DbYXg/IxSsIr5BQS+rZNBRJkKmpDQ3PhAbDZPRKfOG0Lqi4uT4RQzxcl3r0u3zQr0ir7+umk4fdVIq6HGO2MBoAjHKhr8/rNvhVB2Zoc7Lj8mTXmvIEWwWzjD2TNi6IkyoDKE++G/ms9RQBbHQjKfgc9QWTkmpFzKPbUP1JcSVOUBNTQ4HLBtuqoMxDThseIx8SRmk7JJjK5VVN+dCvSLZQnvAWExd1HO+XfxkrqRXYkWnepCnVVjqC5uL8Tdt0/rnAk4RwrEmBFtF6x4ktLdPhlt99DfOWqjDtUUbZKF2OfUqoyqjfw32yGh8a8T8MqPsUDF/30Gkc5VYx/CB0V0aaKQeNYNVw1uu6TezhD1EMLi0+8Qkf2k62tV9I7K4JhSQJ1VbRO/On4+xntutdxGcj/G+rr0Wr2QpfqePQ7LklqVDP8W2pP8dt2+ 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: Cast pointer from percpu address space to generic (kernel) address space in PERCPU_PTR() macro via unsigned long intermediate cast [1]. This intermediate cast is also required to avoid build failure when GCC's strict named address space checks for x86 targets [2] are enabled. Found by GCC's named address space checks. [1] https://sparse.docs.kernel.org/en/latest/annotations.html#address-space-name [2] https://gcc.gnu.org/onlinedocs/gcc/Named-Address-Spaces.html#x86-Named-Address-Spaces Signed-off-by: Uros Bizjak Cc: Dennis Zhou Cc: Tejun Heo Cc: Christoph Lameter Cc: Andrew Morton --- include/linux/percpu-defs.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/linux/percpu-defs.h b/include/linux/percpu-defs.h index e1cf7982424f..35842d1e3879 100644 --- a/include/linux/percpu-defs.h +++ b/include/linux/percpu-defs.h @@ -221,7 +221,10 @@ do { \ } while (0) #define PERCPU_PTR(__p) \ - (typeof(*(__p)) __force __kernel *)(__p); +({ \ + unsigned long __pcpu_ptr = (__force unsigned long)(__p); \ + (typeof(*(__p)) __force __kernel *)(__pcpu_ptr); \ +}) #ifdef CONFIG_SMP