Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp834711lqp; Thu, 23 May 2024 01:01:59 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUWm7XqMRXwuzOJ7JveqNfZ2FclnyUbW8DBHcydI2PSLizseVkul7k3wN7ICGh/K/aOsrwG3mrAqM0jK2Iv0t/xB4/mCzyJ76WexO3Izw== X-Google-Smtp-Source: AGHT+IEpwVlbQ0+cIZiAAbOcby+skghkZ/48gWcOJkimuAS3WLoA0x7o+Udrj+EfMHU20PPU070M X-Received: by 2002:a05:6a20:3cac:b0:1ac:de57:b1e3 with SMTP id adf61e73a8af0-1b205b83be4mr2402694637.0.1716451319611; Thu, 23 May 2024 01:01:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716451319; cv=pass; d=google.com; s=arc-20160816; b=jZrBuvO77jVB0aitc4cxTQTzgiAzde6XyP9BzbhU8HlnlIbZYakitvJQlWbNh6W7Y8 D+q9t3uj1UQO0kY01Vf8Mdaj51v7xUQYZh4ou0ojZbV8Cv11ncvGrZFAbkYrlhv4QJ4F tLtuy+5suyooW4be/QK98yWNDlj9VPvxBORrpmJsxjwsmeWyqzPLSgX1Nl2LwLJNqNBW 3iwDqVcC0ouLF02tKPXK5RdIwZWIikXWGk28LoontQcjqmlRv1sBhk/EBAeZ+3pFbwoM e4pdjGsWmEoU501CZZrO5sIy9j47N1rIO3mGWuL1tQpgLuFQsgr1YiJO/T7WV9YdxgbV oxkA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=ZJJ6AuEpcS/RPE/CUPbVaVlAztUWI2Z2Lb/LJ9UyRY0=; fh=cRb96Z/f+CnPV9Nk7HwPhVbtf9Ffbv9k4oQuYpjG8dY=; b=bpWEiaFcv0sI6WoqZcrjrEikEpcy7QKKP0KObw/JjkVsbS+8IwR2Lm7nIqbgyhSKOD 7Ge8hs/mzt25PWbpgLswIzI6Hg1oN1yrvzZj1ZcwQrlPTBWZXH3amEZFtPnTphXsW6ak SnbIjT7tvoKWznuGEAC4SMW4pSEXevlSRST5rCwc+91d8QaO2cTKitVuqRqRzO9PWgGj U84khWWAi+s0wQZBhWxqNhYImBqM/JJIaMVCDIIVCFKhbCmgsdkS16TMoeYP6m2tvlia p+2JR5nKnMSmebvDD7UQvmMcoSCVatVBIOsB5PEdd25R/9VvoGAYRHT7dY2coXjqst/m eTEg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Xx+JSwDM; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-187136-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187136-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-656d6e6c05asi4702045a12.806.2024.05.23.01.01.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 01:01:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-187136-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Xx+JSwDM; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-187136-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187136-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 6AC44281832 for ; Thu, 23 May 2024 08:01:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 337DD13CF8F; Thu, 23 May 2024 08:01:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Xx+JSwDM" Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D7BA713BAC6 for ; Thu, 23 May 2024 08:01:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716451305; cv=none; b=MW8cn76wfP72U26KLLQ3hF3UKpvd1hXGMp4tkvgKGQ1y+bTHe5AZ7nIZRjUIOlsJkku0EmRe0i6b2jKxGw167jdSFw9PsoimiXy0Gu7+VRk3axZyY6nhzyHTuqGaoDmxl+eN3quf3NYjluuvyL8xfr+oe/YAWkiMW3suwKZ+cg4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716451305; c=relaxed/simple; bh=lr4bUWphsJyZbNUKRRfYxfYiaz4mun/8WN1QLLNsFNA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ggJTIuVPEX71h8UVorjDV0u7ec+Bp73Lc9rr5D73pbCxpeq7Q03t6lOq1uehSRPM3JvdBuX9TOTLzYk1vhNGu+16MzYaSXkQCXOkUN3Txx0HUG/VygGK7LqgIitbe8vfhTzint8FkZJ6e6Q7evR5zfZR8YYDlWlhJyMq6UkqZ10= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Xx+JSwDM; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-4201986d60aso14575295e9.3 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=1716451302; x=1717056102; darn=vger.kernel.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=Xx+JSwDMN+vSuKKj7f75DDuMLrIvYrEIIAqKizjoYxUwixjJYP+3F9mWli4VYf1nRB gyrnB8NDCAWRoF7DlQLlK/jHLs5JgKx/oyohM/q4iffqDV4f2ynnEyXAjpz41tXdUsZo SrCCN1DEIpfp5WahHGJrD5TvAPuSYZ/zXDLQPdzQT8/DntSd+XOABDZPZJaSUbA+zALO QPEmRv0kgJbUSvLIxnqgpoVuSBtXKF9kkBxcXrMDOBRojqwiTKd5uoyrDApPAVo7Kx3J QOxyGYPVp67w9JBzz+u2oOBPWfR73a6baYe1D5SYFvUId55vbRIJbFo7MaHX6eyQiW5y PQqg== 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=M/CFXtXqj9FwmTDWwgmg/gq5DyV8C45+OakbX38m6CdLJUUqEgULj99y42QEFLD6A1 IX8hQBLpL4Zwx7tHcYDefdI2FIxTTWMFrMSSlY+lW7HDCDs9L5F68a/lbg8RxLtn0hak do3kjBphdipIIy//oI1qnxVvyICXYQi7r7JLAAH7MReKMHz8nx8zlw/tabFA+f/xmy4a rItkawh/H/bCQlQIovbfG/64jSO+Spuk7vaHxrMBlKTnmulLZITD8HTP6PdENFmVXoeX t9ZkP2yO/hJ73o4ejr96CGXnQdpfwZA/3QusgN4pViSfGe7ROzXyizCH4XK5ZyceIc6o WtgA== X-Forwarded-Encrypted: i=1; AJvYcCVVa+CCSjFS8Q9meBM8Z28Kbb1CddySQ4pmo1QPsryPtjbdxrluBhmQVABtuq3A9JTWmUrwGjX7kSbL03ezSLPM6ZTRXRTHY1mu4xPA X-Gm-Message-State: AOJu0YyvSDb7sqbzvEYFueYeWjqnXDAIMjzaW9giYHVpG3sM5cDF67pA gs5bNuXeH6y/RTGJhbfHvLq4ECAxK7m2g3J6Y0EE8dskjr2IEEmT 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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); } -- 2.45.1