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+Hvj3lXjrejnlm0jLYa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lrkB3n23NBDg6AgqaRIukw1QXcdgT/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)