From patchwork Thu May 23 08:00:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 13671373 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 9FFF2C25B75 for ; Thu, 23 May 2024 08:01:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1E87F6B0089; Thu, 23 May 2024 04:01:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 199636B008A; 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 039316B008C; Thu, 23 May 2024 04:01:46 -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 DE58A6B0089 for ; Thu, 23 May 2024 04:01:46 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 6671B403F0 for ; Thu, 23 May 2024 08:01:46 +0000 (UTC) X-FDA: 82148916612.15.3B35446 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) by imf04.hostedemail.com (Postfix) with ESMTP id 84B774001A for ; Thu, 23 May 2024 08:01:44 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=KTjUaqMj; spf=pass (imf04.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.128.53 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=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:in-reply-to:references:references:dkim-signature; bh=ZJJ6AuEpcS/RPE/CUPbVaVlAztUWI2Z2Lb/LJ9UyRY0=; b=cziUCbMN/3kB1t451pjsVxft1YLlluIbDYuinwJUPPdi85HQ2AYXtYOPFw07btUyI14goe DsBwoxMQnFjBPijMsNqynCKKmUf5bqDsgDSQmBzx2mbRGPlnYfj7bbIYipbPJsiFp57kIN euKLYNhwn6i2zhMX6OZ98V3o5jfy0xI= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=KTjUaqMj; spf=pass (imf04.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.128.53 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=1716451304; a=rsa-sha256; cv=none; b=QNHVVifnGgbbVJUSzyJ4vwIzH9b5hgVBSZ4VMqiK9pubuPJRHGJBBIiJWhtGJmA/YQrF2x DlPE0c36jB6Fl4uwRlgaF7Yb2JC4/kBlxtVBSCHkJ4hw8e6VXo1jDszOHLwmkC44eDqzKN lFaoR3l9SiKHBMBG6UDW1b15Gvi8OHk= Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-42011507a4eso14793665e9.0 for ; Thu, 23 May 2024 01:01:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716451302; x=1717056102; 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=ZJJ6AuEpcS/RPE/CUPbVaVlAztUWI2Z2Lb/LJ9UyRY0=; b=KTjUaqMjpJpHQIZJuAxmmec39o8ZitC/HtuzhtGFUFkdkm1dYxJutDk7QYoX47pSDQ H50HA80fDi/jeWXTAGhrQZ+U7UMLCuqF3qbNt/9OlsEd8PPyKXeaFabKIxXKueqctCia zg/HPF55dvWMt8oshA/DlfC1qTAnZ0RBLciMQg5kJISPKw7a4+rLoCTCozi01BXIvnu/ MxnTdoIWNc1MJpPbq0J4DA0ug7a9+x0j+9fWAQUBCnll5r3SnG02GQVxcb+0I0Lm+pqS HN//BWEF6Gw6R4mQKf2XnEmMrTHonTwe7CevusZOEn/KCgbSu6n3yx4Td2Z/GHCxnJiT 8mFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716451302; x=1717056102; 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=ZJJ6AuEpcS/RPE/CUPbVaVlAztUWI2Z2Lb/LJ9UyRY0=; b=jqZRz+c1w3pkZZYzWtugRJT1HVyUv2K4FbcsMb2A+tQBWTEmn3HysLVCwmnIZ9s5u2 7lzosa2Ss4N4FEfxYc6XKw29p3oF/DtzIoFivV2OWr+npDxVt78s/3y7oOtLX5vmv2bu 5PZ1gTmk5YIY0O66Le8qDQyQGltJF3UjvN1GX96SY0DIN/mY79Yaqmq1prExFfBC8aiF xuwPRO6my8E3A1Oo9xsYPT3Jb6xrTF41g3/8sivzYqfaVzJ7rWbpvmTUh0ac1nNdA7uZ lziwcjiSVZoJCGileMgWg/Pg/w1Ev4MyQCK9icUrEvnyKv6f4XHOX8fZ5LePHu+k3H/w eqOg== X-Gm-Message-State: AOJu0YwGu83yMDkv7iUPkP1Jrkg9qbCfTY3DR5li62NoiSYETejzitLD qtvWjHkwRdN0XA6HkhaC061y2aHWBo+cE753EL19IOzW3pnkcAzW86hGaQXiQyA= X-Google-Smtp-Source: AGHT+IGxf8z+KBReL8dDRkf+3eZRAAFo/WXe1J5r3DlWJfOpykLJKaaRPtQPIQdbgfq4TfYmqGXuIg== X-Received: by 2002:a05:600c:4fc7:b0:41b:fbec:a53a with SMTP id 5b1f17b1804b1-420fd30e19dmr32547545e9.16.1716451301860; 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.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 01:01:41 -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 2/2] mm/vmalloc: Use __this_cpu_try_cmpxchg() in preload_this_cpu_lock() Date: Thu, 23 May 2024 10:00:32 +0200 Message-ID: <20240523080136.9863-2-ubizjak@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240523080136.9863-1-ubizjak@gmail.com> References: <20240523080136.9863-1-ubizjak@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 84B774001A X-Stat-Signature: 4ybwt8c9xx7bkxguzwmkommi3rd363yj X-HE-Tag: 1716451304-824825 X-HE-Meta: U2FsdGVkX18DjCW5iNQthJB7EnWJ8ckoUhOmOxe4M2fjmy+kRLUbo6hFqcLD55L8KstRwehhRpEZ0/KruCSZ1AfqT2NJFR1mWqChwm4IrGxvFDX6nmh0d/o2YZazCEIOiWfYOC4/vq8UgbDcW7CNSacS/Ht+tZe0KbVYUFRVreRl7bm5irbQJQuY7PIP7eDSAxs4ArNnKD/N5q3+FobG02WSThklGfKt+omH4orqFLGGrgCKgarsEu/jiyzF1705xsrX1M0cUT37kGx5yZhmWuWaZKwQqUmIczTb8Z5eF5qV7ZrnFkMoPglUKP2VHzqbGODomE/WblTQOATeJgFlOlZVAGgDYQAh/ljMOH9+Rern67AT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7wk9pFGAJ5dcEntwbV63+kB3foETnXzxANLz/osG5GYmaDV7jeHuCgm5ZcyLSv4t7rQOZ4w5McczSZJ9UGzogcZTEZDAOcJeOwn9Lh74y5JLgAQB7p4Dad6hmcBsvquGiI0S/+ryyUsR7QyJI1SLlwEWk6cg0i4BMyab6geJWepKNurikvprHWxMrZr8Dxu36Z/EM2/KtOg84N4RDsryZdXtyPN5BtBZfKJ2WSNWcsROQTiNikoQksOi9+ugkDDrARHFeu96jvZ 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: Use __this_cpu_try_cmpxchg() instead of __this_cpu_cmpxchg (*ptr, old, new) == old in preload_this_cpu_lock(). x86 CMPXCHG instruction returns success in ZF flag, so this change saves a compare after cmpxchg. No functional change intended. 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 --- mm/vmalloc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 6641be0ca80b..0120faee5471 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -1816,7 +1816,7 @@ static void free_vmap_area(struct vmap_area *va) static inline void preload_this_cpu_lock(spinlock_t *lock, gfp_t gfp_mask, int node) { - struct vmap_area *va = NULL; + struct vmap_area *va = NULL, *tmp; /* * Preload this CPU with one extra vmap_area object. It is used @@ -1832,7 +1832,8 @@ preload_this_cpu_lock(spinlock_t *lock, gfp_t gfp_mask, int node) spin_lock(lock); - if (va && __this_cpu_cmpxchg(ne_fit_preload_node, NULL, va)) + tmp = NULL; + if (va && !__this_cpu_try_cmpxchg(ne_fit_preload_node, &tmp, va)) kmem_cache_free(vmap_area_cachep, va); }