From patchwork Tue May 28 14:43:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 13676930 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 A3A7EC25B7C for ; Tue, 28 May 2024 14:44:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0192F6B0099; Tue, 28 May 2024 10:44:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F0BCB6B009B; Tue, 28 May 2024 10:44:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DD1E36B009C; Tue, 28 May 2024 10:44:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id C56726B0099 for ; Tue, 28 May 2024 10:44:06 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 423721A0588 for ; Tue, 28 May 2024 14:44:06 +0000 (UTC) X-FDA: 82168074492.03.7E63A70 Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) by imf16.hostedemail.com (Postfix) with ESMTP id 83421180008 for ; Tue, 28 May 2024 14:44:03 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Ba5xDCmN; spf=pass (imf16.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.167.54 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=1716907443; 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=UMfUDTirHx9AqY5s/gqdnHQ3Y6Rgml00jUPMDkQzF2g=; b=aRMrLabAbw9lr/8aucPZSsNxJbMton85eg1z+9QbQI3Y/uVDbWfD7OHa0vYNnRiUgESCox ZOMahXSPeSK+1cojmrdPMTPRA0nIVdcxPTFGgRnxmPAqSpQHkSz0buAvyb1mkTezj0y9jX 63JDu8ebN2Jp8x75OFlEPToXET5z7MY= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Ba5xDCmN; spf=pass (imf16.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.167.54 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=1716907443; a=rsa-sha256; cv=none; b=CHd5neWhng/s8jHHynstgIzVMCW1Pvr6lwPQoOS6I6/EQftJ9uW2Lxkc3o8Fguu5j/7NHp BieDVYDTHJj+/VmIgWvVAQ/ZSHt6zZxP5etncdSu6leDPq8pDeI++/5nDhugUukNq62dj4 rZIjPty4c4UwOLuafFwoF+aV7XhcVhM= Received: by mail-lf1-f54.google.com with SMTP id 2adb3069b0e04-523b017a5c6so1319420e87.1 for ; Tue, 28 May 2024 07:44:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716907441; x=1717512241; 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=UMfUDTirHx9AqY5s/gqdnHQ3Y6Rgml00jUPMDkQzF2g=; b=Ba5xDCmN/ttg4z6cHc6sJm0lo0z2VSwoWo9gLbdhO6oIDw7WDhHzJrt8lsr5Azdhg7 0gKw4jvhNHnYWI29ROjKI403JuxV3MavruaJHqjdmuAV4ffjU+o3PaBtoTRY9Bvrh/Ah 7l5cQXDVKW2XC0PkupbhBl32nOzycrZcNFIt8XyCZqCPc4SHv5fyUEe3nYicyFtQ0U2J zp0V5ECUIvAtH+ZjvxvNHouopdreFdbGJMl5h0aM6j3yZE3OzOUIb2c51/dYJ5UePiiT +xp2x4h2QK8LlN/ELaadsYV/FL88+I2CkExO38Smlhxmyo2kb60/sKZgnHAFBE6b9p4t yh3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716907441; x=1717512241; 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=UMfUDTirHx9AqY5s/gqdnHQ3Y6Rgml00jUPMDkQzF2g=; b=pR4Y88AwfkXV4enTv+g0vAS8aAPLQJSfi9kQhg1x5MRFjYZ69DmalFjBmx1npudSO5 DYOqCNiiU/1FFRfsju5R4Esdhs80zh4CPr6s/BVDM60/C76hiXHCZgdVbpJCqVn29AFK gHTPFTDZ2dnKv76KdNJeiWA0HdJNWTADfSrC8nHVi6FElXtYoXuRel59WF24wYVLh46O 0zQbZEArUPwbvbSHf0IaG7DwnZuYQoprcST/saeDATpjlUUJqEnm4+YUyqfuyIoUZt5T PTSiNy1OfJaHEo/3pZpxDC6bATcLnQaHFkJSO98YCoudOwtgcHEOkQ0TlAtEd4ddstbD 3gkA== X-Gm-Message-State: AOJu0YwfAj4XgJeSOGUo6XsN/r8YePRz+nxCM2T5o+y1JaInRo3VoVUr RFovAwF3/yLqSeV0Lh3KnybLXfaRbRk77FgmP3Tg/uUo1cbnRPKtuBxuXGdfEHg= X-Google-Smtp-Source: AGHT+IEC9mDolb6Ese2exbI+TapVH9JPhCAovHWo2SBEk5sP16XS6XK7sfyYXR7sN9HWPUDGhi5n5A== X-Received: by 2002:a05:6512:3136:b0:522:3356:3b8 with SMTP id 2adb3069b0e04-52965a4241emr8553100e87.27.1716907441050; Tue, 28 May 2024 07:44:01 -0700 (PDT) Received: from localhost.localdomain ([46.248.82.114]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a626c817ad3sm629797966b.16.2024.05.28.07.44.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 07:44:00 -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 v2 1/2] percpu: Add __this_cpu_try_cmpxchg() Date: Tue, 28 May 2024 16:43:13 +0200 Message-ID: <20240528144345.5980-1-ubizjak@gmail.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-Stat-Signature: 9pdfkq4dwcisshoz4zj6ot4ma53tbptj X-Rspamd-Queue-Id: 83421180008 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1716907443-675964 X-HE-Meta: U2FsdGVkX1+NmnLOlcc/Gbd2fqGvUkE/2ODjjzOHo4n/45r5Fu18H1YJGGMB9RjciF4ezE745/HQzCmVHyQBN4gCMU1ij0KcqEox41OKo2HL7nJtLc0O8M+qG5YeaHcU621Vmemf9vVK9HWCHt8bXRuO+4v4xofD3/qb1m3bfkcXW2Z3dAUj7GweGdzhdz+NPUIUf8SMipvdZCQCEWaJW3Ikt2FSlxj1I2cJsvpE7RChyXFt70+bT1dmEu8q/WXDQFw42/cJu/rfsMEAazMZc8p7mb8ouuriU0SXcYjSjpdjSP+qJ2N6LpnjFa+7HjEvCG3xMJPqOoL/cvjOYWstky/5IkK111x8FdMVtzYHNlyZZqi9aRa4j96N03IIBdv9wA8ls8jVrIk4VZqcDlV5dYQRcvb4UCHHQj+mfD5vgTsycZz/pxHKO5hUonzjGJC2SBQjlRIRcGWESGzxb4seKh9we39wwfCuY8PCjFtUqomspifmhTbLUp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Oe6X77zDXywzBCfI0FkjNHt4s0xsh8KdbSTRMItyzMJzMBmi5ZtRto7NXuJbuVOmCq49SA8u+oKh8xxUp67xXvrjU+h2ydOeCUT0/SS02JTeyiN9lHBtVYX1hGXbE5/XylSmmv7yIPD/i7w5ijqlzVC1k 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 __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 Acked-by: Uladzislau Rezki (Sony) --- 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)