From patchwork Sun Aug 18 21:01:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 13767622 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 18CEDC52D7C for ; Sun, 18 Aug 2024 21:02:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 358B96B0093; Sun, 18 Aug 2024 17:02:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 307166B00A7; Sun, 18 Aug 2024 17:02:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1CF686B00E8; Sun, 18 Aug 2024 17:02:51 -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 F1ACF6B0093 for ; Sun, 18 Aug 2024 17:02:50 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 8F3D1C0DAF for ; Sun, 18 Aug 2024 21:02:50 +0000 (UTC) X-FDA: 82466590500.15.25D5D79 Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) by imf20.hostedemail.com (Postfix) with ESMTP id CFDBE1C000B for ; Sun, 18 Aug 2024 21:02:48 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=lIw2GjIg; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf20.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.218.45 as permitted sender) smtp.mailfrom=ubizjak@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724014883; 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=33O1tYB6ZBAM92pkyxt8k+zeN401oztTnBh5GARjIPw=; b=GmfzLH86ovG3T/k2ZHasZnn/mSjoHLcp7yyabZ+H+VOIOcLXP9kUMiV+PYwaq7TpTfsxS2 ULQxH99zDHPRqu78OQRDZJGhG3x4y1t94eF+KVtsQIOdzGtQEzE4inqy3IpQX37Ma9WKp9 aKDsaf3CmvJu1L8FgGftCBZaiaxZRmA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724014883; a=rsa-sha256; cv=none; b=s8u5mkGVHrUYP8a5uD+mTlPYE7/9E+psUNnQl9Z8OKUN5NzEdHP504HUxW9ogdvs95u0OK 6/OKgrm9eCTtmCvAoYHsw/o3VQUTllcR3u5seKVK606fc6WZ5A1gI7X/IsQic++YnCMJ7I qteu9cvqinhSNwRgiIC3PB8z8lmHoWc= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=lIw2GjIg; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf20.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.218.45 as permitted sender) smtp.mailfrom=ubizjak@gmail.com Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-a7aac70e30dso397518066b.1 for ; Sun, 18 Aug 2024 14:02:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724014966; x=1724619766; 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=33O1tYB6ZBAM92pkyxt8k+zeN401oztTnBh5GARjIPw=; b=lIw2GjIgm3wKa/0gOP5bi+hvwMHL1hyO/IdcbAQAulNrTP22uH6ShYCyB44HYsJ0LJ npQSKT9Hmge8RIduGJ3DSoeFVvUb3PN27Hj4g5Gmjy8hKuG6iPnnQfs9I3EaQJHSCs4I wvcOncXzFueCA7QC67D/CCkWOaLx/Zt+SeKaVeh6SG94rB4O7kRrgmjvArpwyQ9djbCf UzVaH9YVLi1Ban7Xum6fkHRnT+Kv6aH//3HZW4rIttqduvpGeUdmOwt6DoWWMWcyuDQ1 1OFlSkMUZ2YJ12uKaEtVIbcSnCYFxeSC4e+ebwq28weZk9rP32L2qS0fuCCr7ir7Hx+N UDRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724014966; x=1724619766; 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=33O1tYB6ZBAM92pkyxt8k+zeN401oztTnBh5GARjIPw=; b=fpI6RE3INyMr7rI7wxoIe07rGyWhb/PiJ5uFNEYF4t9yCgulVGoRrqVdQ/HInQ5MD7 yJL5i24QvF8YWdMlOi2MMlHZD4tgEopDtt6jK45ac0WMY1QCPsDgHiewjnReBEUNls4d 8hrht1v28/7bl4otjBxxvMUa48FfpxP1W7EtRiWTjsCd7+0+lpKuO0omQwuE6ZW5oCng x7lRf22hnzeay6P4h3KOBB4qruTjLYaD75Cz/dg7kSntVf90lz4FtVg/cFxc9/sC7ym3 8fW0hnukcT5znvkeVLeRgy0Vej2eMyOgnUTJrYH+D5vXfPUStiCtjtc1RliZexBbm8Iw HOpg== X-Gm-Message-State: AOJu0Yx0n2gtT8w9//zvAv+783alqLeqHfprgH5RU05aWGEvnwA4Axyl AxhoPN67fGPh8QdppuM9t6dnC3DJazfpFZ9eM83MR5gMVy37f7YYmDNesA== X-Google-Smtp-Source: AGHT+IF37pvsOxU6lEpKmW36ULokTE+MkxkHNYwoC/m53vY0l2IHld/cLjp0yLPclo9BZHAmqKxmKQ== X-Received: by 2002:a17:907:3fa9:b0:a6f:4804:d41a with SMTP id a640c23a62f3a-a8392a03a86mr642953766b.55.1724014965736; Sun, 18 Aug 2024 14:02:45 -0700 (PDT) Received: from localhost.localdomain ([46.248.82.114]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a83838cfd5esm552895466b.78.2024.08.18.14.02.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Aug 2024 14:02:45 -0700 (PDT) From: Uros Bizjak To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Uros Bizjak , Catalin Marinas , Andrew Morton Subject: [PATCH v2 1/2] err.h: Add ERR_PTR_PCPU(), PTR_ERR_PCPU() and IS_ERR_PCPU() macros Date: Sun, 18 Aug 2024 23:01:51 +0200 Message-ID: <20240818210235.33481-1-ubizjak@gmail.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: CFDBE1C000B X-Stat-Signature: dzp9ybay7o5q137gzjir8afnwuukkzpo X-Rspam-User: X-HE-Tag: 1724014968-199139 X-HE-Meta: U2FsdGVkX1+EKjwxvZwkpIArnGaUJxhjFdyxhZMGHC9tsPnANGR2TDFmLt4g5sal35TaupnmdcuHMTQdxGHM4/jSKesXoM8JvofKn1WK/vCH3nDSaY11xNg9fSaDwGRz2Dq0dAhK21LvFBKH1naZKLZ0RoqUJBEEqv9r+k9qa2oHW+sP71cfgb2bzBrISy0KiaqUYwMyZpyOlYK4oFT9h65n/6wfvw2CRMvX+QFkZzAxESLUFfT2Y67LZTPRB7YoN1Vq4uz4zXoOIX5OAvXc6645d6b0sYmBZpCRQ8W/jK6Muvq3eepLOjiieAzB37aXN4TLfZULgsZBkLCnn8AOzwc7fVqNFs4kLxc2GTOUG58OlrTeIjZn4vRlBeEzqiYy5QRkRNY8Jw/ylFyCOdO/y0ERYUIX+MFRW5kXpQrKZzMmr/bmt97ONa1LZd5TdthJmUUlhRMm14SlrhigPb2GUqVDRlaQRejNuW4qsgSVpPjzkJcMPKVAfHZxgWIGSuhb0w9/UVOeBNmiSf6UneSoiPyHCgF3HJpHXLFQooWcBZm4uZxSk402jZSih9YMrVPTGbklE/hBmTG8dF+URULUE+nK/OqZeoZ/Gd97fGkHSY95ILIz4NEfACYdxR1tnzf1lLDEi61xf1NYMsDo/apONKSEDCdSh0uOg6t00kLYN2Zn2s9WF3m+DtqgIu+jpIjiBTt3N8nY7y7BuM4jxT45swwrfpuwncJYHw4HCfq1sBEhDY7BsEf+UARcXoYT6dK/xraTaOy3oSHp1QH/W77R8+pu7vyudxbJrIJzscc0L1OLrhbdrgrjaVhXaZQDWJO13iy5h8WQrYYFo7T+/iTrhd9S82Xil8wzYIcQlKykrViZlaOYLGv1rhi93oTU0FR6nbQHgoYWGGpKeJX0kpBUCDRjZgV4c8AuSI6Asds8CCaJU4gRYtC9hXyDOOzuIt+bToRWDsKbqWw23eCFA+1 7+gLGrtf QjXMg+0/bOQZRExLHhizbTg6HX2r7EDG8eieCO+HhINAgGWESThBMrFg4PQOj3pNX+yWFXNr8+SwCVZeZn6x8BlRE4ZxZd9pzlYdP63GjZCpJBpApM308+6j6S3N+BRjn8wC9Tek5chHSc37zCRFZdbk0cFsufI43psOinSIdzEArhLuNxq8qFrn1KSzvEpy/cgZyUNhXsqPmzXHzHFDQG6OL6rOAnbr1Y3qccd2qznytLypbC6/kfG5cMWyNqku1ef21NJGAiL7jAOg3qTQi9Efss/9y/yfHgqvnk00DFxwgiBc4YjNZAWHbKnpm1REA8HOw4GNAW7VOtTaebYTUiU6zFs4l+45c7tt/73MEiCH5Taefc/8nf/42dTRlmoLIkbn7Rb+EeFtlnF4VoqnikezEScI6yk9K9GpGUJTJzfxTW7vIrE8ziZZBzapv2X4CNv+ksa9zH0JcHrZcdIf44B8nEAWmYX7KdqIhEbXIzkJ+VPY1lBxhnFnGtPF4stfaRitQ51XOW+rJmSY= 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: Add ERR_PTR_PCPU(), PTR_ERR_PCPU() and IS_ERR_PCPU() macros that operate on pointers in the percpu address space. These macros remove the need for (__force void *) function argument casts (to avoid sparse -Wcast-from-as warnings). The patch will also avoid future build errors due to pointer address space mismatch with enabled strict percpu address space checks. Signed-off-by: Uros Bizjak Cc: Catalin Marinas Cc: Andrew Morton Acked-by: Catalin Marinas --- v2: Implement as macros to avoid powerpc build failure --- include/linux/err.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/linux/err.h b/include/linux/err.h index b5d9bb2a2349..a4dacd745fcf 100644 --- a/include/linux/err.h +++ b/include/linux/err.h @@ -41,6 +41,9 @@ static inline void * __must_check ERR_PTR(long error) return (void *) error; } +/* Return the pointer in the percpu address space. */ +#define ERR_PTR_PCPU(error) ((void __percpu *)(unsigned long)ERR_PTR(error)) + /** * PTR_ERR - Extract the error code from an error pointer. * @ptr: An error pointer. @@ -51,6 +54,9 @@ static inline long __must_check PTR_ERR(__force const void *ptr) return (long) ptr; } +/* Read an error pointer from the percpu address space. */ +#define PTR_ERR_PCPU(ptr) (PTR_ERR((const void *)(__force const unsigned long)(ptr))) + /** * IS_ERR - Detect an error pointer. * @ptr: The pointer to check. @@ -61,6 +67,9 @@ static inline bool __must_check IS_ERR(__force const void *ptr) return IS_ERR_VALUE((unsigned long)ptr); } +/* Read an error pointer from the percpu address space. */ +#define IS_ERR_PCPU(ptr) (IS_ERR((const void *)(__force const unsigned long)(ptr))) + /** * IS_ERR_OR_NULL - Detect an error pointer or a null pointer. * @ptr: The pointer to check.