From patchwork Thu May 23 08:00:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 13671374 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 BC690C25B7A for ; Thu, 23 May 2024 08:01:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 67C886B008A; Thu, 23 May 2024 04:01:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 62BB86B008C; Thu, 23 May 2024 04:01:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4FD4E6B0092; Thu, 23 May 2024 04:01:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 22D1B6B008C for ; Thu, 23 May 2024 04:01:47 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id C1C271C09E9 for ; Thu, 23 May 2024 08:01:46 +0000 (UTC) X-FDA: 82148916612.29.0502876 Received: from mail-lj1-f173.google.com (mail-lj1-f173.google.com [209.85.208.173]) by imf03.hostedemail.com (Postfix) with ESMTP id DF6A420002 for ; Thu, 23 May 2024 08:01:43 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="OH/f+Mtr"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf03.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.208.173 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=1716451304; 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=ZluRRQ9XyXo20qI6tf/Kv1PIsqdwtqNbch7EYxePXUk=; b=BeDahVcfBwm3sWtw4hIxq6VnYU5GfPL5Y1AAgonFiQ0Y9K/WXYCmYhosIgOsuxozaHahZF 1skPLnPlUZVdqyMMgX09ofTVmyIoJtcT8ZD1Whv5jmxh/VzQ/ov/jW+LII8xtwh5FLfpj+ VfwaplgRLqmwqdCN46PggY21jjJSCZ8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716451304; a=rsa-sha256; cv=none; b=kw/D13tDg/J8bZ5D+FImWA040xbq1uNzzlSj+9d40es9UjLq1DJ+xUbXtTpgNS/Qq8Fm2R zHc9XOfeMHcLAJhWo67sXYTI9kG/dSaPnt1zvMVCEc7C/2V4OcRnU1t9rQ4iOhO/me1diG dSAqXaisikaYhalK2XkD4A3BwIsWIb8= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="OH/f+Mtr"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf03.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.208.173 as permitted sender) smtp.mailfrom=ubizjak@gmail.com Received: by mail-lj1-f173.google.com with SMTP id 38308e7fff4ca-2e538a264f7so81500251fa.0 for ; Thu, 23 May 2024 01:01:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716451301; x=1717056101; 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=ZluRRQ9XyXo20qI6tf/Kv1PIsqdwtqNbch7EYxePXUk=; b=OH/f+Mtrvyx2rrgzaqQ1yyjqaMwzbA715+3ylypTGLnEwbk0Mv6Wz+z23yMjm9UdTs iwwh48glFWXJ61AL23+CF539ipOEIchW4JwPQFU7jhW3xm3R87zBD4MQ5btYHCxpcyya CEzcXv/2y8nQ6oOGJW0fMpvAUouMPnAuWC9+YmmbaUNJDnC2z3FuSTc6Jg+z9RUPs5MU 1I8dN5hzVvTtO1UWT3gTjlRToBKgLvDl+P09ik6O1Z18ZJlkeSyVLmPMbyWlD3V4bXtg yX5Ip1EPLxB+nWLVBpYAFxIstqAtLSMxN4H2wvRs+qotJeApHK7k2YaHOBYFKZZ+iCHJ ey5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716451301; x=1717056101; 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=ZluRRQ9XyXo20qI6tf/Kv1PIsqdwtqNbch7EYxePXUk=; b=WNf3SeXPP4fgmSUAfJj75mxBgTMm/ALHxf53cLek5y1oJ42zOfw5nn8p/SpyqDmFhH EGkNTsTYdho1AA80pzsfaOmBRfBworxj/mXPmMjqiJzHitg3J6QWMQQVJGAX5M6avA7E Xy0ldziv2KT1U2CCXhFiWdZZFd1Fu1mJ7AGh+2K5r5BSjDrJGQaH/VUbGMzTYu3tgMmr Yh7YTBGniqSthgyNVwiwnE4SXOHHmATiwb9yXxcrD3N7oInRxzzfXpqrwx1NsutuHVeF WlDEVNtz9VDqOtD7fclZNP52cenfQKpWbtVdn0PKhqmnWDQoWWXPUQUwUhaf+46aVHm7 DKpw== X-Gm-Message-State: AOJu0YwanE676ttNUxvDS1axWLsjHX1VsXN1zeSSm/Lm6R1MkWKF+iug NuvJCb5HLpLi6ynM9Q+Ca96PemKN96x7YrX1F3AswSIgWNOm7mPH08CyaE5vf88= X-Google-Smtp-Source: AGHT+IEP8QHHLCRarDBboaWu7hRaU4vf5dunldJNtpdKLpOgkI7yExL6vlD475Ef66rcj4+zUc8fIg== X-Received: by 2002:a2e:850a:0:b0:2d6:c43e:f0b3 with SMTP id 38308e7fff4ca-2e9496ba782mr25884081fa.50.1716451301010; Thu, 23 May 2024 01:01:41 -0700 (PDT) Received: from fedora.iskraemeco.si ([193.77.86.250]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42100f1548bsm17489045e9.11.2024.05.23.01.01.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 01:01:40 -0700 (PDT) From: Uros Bizjak To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Uros Bizjak , Andrew Morton , Uladzislau Rezki , Christoph Hellwig , Lorenzo Stoakes , Dennis Zhou , Tejun Heo , Christoph Lameter Subject: [PATCH 1/2] percpu: Add __this_cpu_try_cmpxchg() Date: Thu, 23 May 2024 10:00:31 +0200 Message-ID: <20240523080136.9863-1-ubizjak@gmail.com> X-Mailer: git-send-email 2.45.1 MIME-Version: 1.0 X-Stat-Signature: f6m8z88x5xdkagettyjk4wz4uy88g4af X-Rspamd-Queue-Id: DF6A420002 X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1716451303-983426 X-HE-Meta: U2FsdGVkX19sMtdQ2ETETzpMBiYGLLdptLcdwyCcZ4sZ1RhivtXOy0Iien4fGu7EspDFO1XQZ/L/GEGaF4ivgi8ApENs4PqiK/5YFIQv/KStpn8FCrBMxoL//PsUQRU9Eq1wVndketJsaNhYt7qLgYRp8mpaqItxJjfFM960q5M75UkRfRrCbAPNmJL2Eb+nDQX40qmlnbs0v9lw+j41c4+z+a+JMywj/JrBdaXauy5uNbLrE9pzQwfm6kZierXZ+PViPW3q2TFDNPysHrw3CYRVTgt0K9KRWuexo4OkWbfb3174Ug4kKiPahW9nFLAQkZH1/zRMtSktgr5lfTlb559/FLWIlzHCBTKcsnKnwGi9i9ePxzIcboybEtBMiUYVHeCTjhMtwIj8bqFxYKWC51D98du/7xZaAd2lbKxy5k889n1+nVTBiJ2MIMZhZ/Q5DblpXeabXjkH0Xqz/b7YPQyv32k6druWRB9X8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5NYXKOrTJ8/WV2jddGiHs4IzmW55d1kGHfPFlrMwhz+RtntwgMpwWLmEdDxPh/lOH2u93QvILsYv8Uy2ebAotFlZavL4V+cK7vqDrqaKp2aK1wDfm0S+U7H8VezIXLwQuCqzBdBKfgQWNVg1vEaMNTkarqHv1kdG8zPc X-Bogosity: Ham, tests=bogofilter, spamicity=0.000008, 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 __this_cpu_try_cmpxchg() version of the percpu op. Signed-off-by: Uros Bizjak Cc: Andrew Morton Cc: Uladzislau Rezki Cc: Christoph Hellwig Cc: Lorenzo Stoakes Cc: Dennis Zhou Cc: Tejun Heo Cc: Christoph Lameter --- include/linux/percpu-defs.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/percpu-defs.h b/include/linux/percpu-defs.h index ec3573119923..8efce7414fad 100644 --- a/include/linux/percpu-defs.h +++ b/include/linux/percpu-defs.h @@ -475,6 +475,12 @@ do { \ raw_cpu_cmpxchg(pcp, oval, nval); \ }) +#define __this_cpu_try_cmpxchg(pcp, ovalp, nval) \ +({ \ + __this_cpu_preempt_check("try_cmpxchg"); \ + raw_cpu_try_cmpxchg(pcp, ovalp, nval); \ +}) + #define __this_cpu_sub(pcp, val) __this_cpu_add(pcp, -(typeof(pcp))(val)) #define __this_cpu_inc(pcp) __this_cpu_add(pcp, 1) #define __this_cpu_dec(pcp) __this_cpu_sub(pcp, 1)