Message ID | 20240204125404.2112384-1-hezhongkun.hzk@bytedance.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-51645-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp334454dyb; Sun, 4 Feb 2024 04:55:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IF1RAz2frmadlEV0H1sZGcQMivy/cc9yKP6w0WGjqkpMARMWjttswv2SdlWzfO4fZ+CsSaZ X-Received: by 2002:a5d:694d:0:b0:33b:2e68:d041 with SMTP id r13-20020a5d694d000000b0033b2e68d041mr2324160wrw.6.1707051300277; Sun, 04 Feb 2024 04:55:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707051300; cv=pass; d=google.com; s=arc-20160816; b=LMzjTgzr9itG+LOC6MA8TIeZt8M8O567ys+Q28veL5Iyx5abpB3mP7j1E2P3B5WtRO hlGmpbHfA3c+IoCWXEU0du/G0fJChNGSVU2LTGn+OCZoZx1X7i4mcshd2kLmHviaBHRy pd1FTGXFEfZXvwVpqBkLNOTQDekBPUDpslJ22Vk00zxTrFeS9gelPUkA7Wo6DfA6sMIH oudT2Xh28JoYFODceJd+xfNKjy7OiReR8MQScdGcCeODGBJCp0WzF82QTba2KzrY5VNe wruvXOzgUiR5FxZdl9UCpLXZFRUFTWX9UAcXdOLEMVIJkuzfdnsIYk7eJcyqO4e5+Kmo R0Ug== 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:message-id:date:subject:cc:to :from:dkim-signature; bh=5tAC4bTgcHhyuinc/GPvD04sELvx94YbTxerqzMu8Bg=; fh=Kh0LrOB0GwQegyLh4R6HDPDxW1YbFIOVNlVNln3qyK4=; b=RqrITGZx0HN45WUqFkcc4eAMWzmXMU4RSxfrEdsTZwd/YPVqoNVqV+xtOXr9cwLhUS Lg98biYbLNsnlxl+8eDoy9l9Hr1Vv291s4NY4Mj8obKB72Sefy0odqdAUuRl2Oggd7Zc e3GDXeznRAF+qqYfIRPM6PIgzoTG3zzR/j5czhvUvPr4gMmGERGDCT8W27oiMBy+GOU0 WzYGdrGiWpoMuh7FM67vSQ1qi+iDKMt5WKDU3jpm5xaqKMDykEQXbpLVbNT8UuPRlMqT Rj7n0uEWniEeJxIhhChqIPIrYZ3O11/bWcW9SRcwOM1EBprOVABZPlAn8nmifwu+UtjC Ievw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b="J//Tquri"; arc=pass (i=1 spf=pass spfdomain=bytedance.com dkim=pass dkdomain=bytedance.com dmarc=pass fromdomain=bytedance.com); spf=pass (google.com: domain of linux-kernel+bounces-51645-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51645-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com X-Forwarded-Encrypted: i=1; AJvYcCXkHXX1Sq1Po20wnho1neLQhQnklTxDDHkrdYf2MAZ2eUE/9pYeRnBH9/tp16BRdZafwUrS879NAUJ7GuUlBkRt06VXSg== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id u15-20020a50a40f000000b0055d095ff96fsi2937582edb.45.2024.02.04.04.55.00 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 04:55:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-51645-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b="J//Tquri"; arc=pass (i=1 spf=pass spfdomain=bytedance.com dkim=pass dkdomain=bytedance.com dmarc=pass fromdomain=bytedance.com); spf=pass (google.com: domain of linux-kernel+bounces-51645-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51645-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 5650E1F22096 for <ouuuleilei@gmail.com>; Sun, 4 Feb 2024 12:54:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C7EEF224EF; Sun, 4 Feb 2024 12:54:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b="J//Tquri" Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) (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 E392B225B2 for <linux-kernel@vger.kernel.org>; Sun, 4 Feb 2024 12:54:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707051280; cv=none; b=VpeWBeP+S94YYyCy2RrIY157TvJ/0KgADQcRNT6X8dmXHnZyJ9+84UIWhIqsGSQPSoZxvVTrU8CQgOlFWqTwPiGvk8F4R/XhTXrJapxQ9ngoX3Zo3K2gInMqdwta9OAoV3BeQmDPQnacP7PSXjX+GJG0YrgnU/zOvS+kGvIJrVA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707051280; c=relaxed/simple; bh=yX98yZz9bh6TkXa1p8lJWZAeQ1Ovg4lal3xzOaBMMpE=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=av38DDzBLDNSFRfqiFwLVTjukOtQdFMiIe3o2WCHMQRy8X6WAVxRewtnC0OMOCIxgMLhydFxqYJafJMtFVGcao+1puW9bHu0SG2iaYzxGmBfKVvq8AN0QkprpmwW+VO6RGn7ckQXUBA2WFnLUpSH3mxcivdwua3DELbmsJ93kJw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com; spf=pass smtp.mailfrom=bytedance.com; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b=J//Tquri; arc=none smtp.client-ip=209.85.215.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bytedance.com Received: by mail-pg1-f173.google.com with SMTP id 41be03b00d2f7-5dc11fdddd6so583566a12.1 for <linux-kernel@vger.kernel.org>; Sun, 04 Feb 2024 04:54:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1707051267; x=1707656067; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=5tAC4bTgcHhyuinc/GPvD04sELvx94YbTxerqzMu8Bg=; b=J//Tquri7h+ki/O7hCWKV4zjS+C1GKn3viupyiCuijngZMY3DgCXJstVALSVtwPd2c YM9oZfdxCqkfhGXMKCo6f8ajMWSe+F5KheizX4kgUY1dpZbjcSUzQPlT1h2Rbiv1VkEx VHlKdALsLmorRZlgC/k/RQ4RYk8gaaFUASFW7xc91NwNjGy/dKD/alIvmo9e4F/B/RV6 FACDyEKZ+htSX1TQkAC2ZpLKWUtOohhlGkrFJf6Le6Q7xQwftxwBjWKW65LNs4tWotJR Jp6QV5bMomVHfcu3aB10ztHKoIcZG4iJdF76fBlnRneYmlnctkWLtI946s0vZGJ4b3Ro hntg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707051267; x=1707656067; 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=5tAC4bTgcHhyuinc/GPvD04sELvx94YbTxerqzMu8Bg=; b=vVjxEq06GhFvZNDpzU7GThOI53LqW9C1PdzVUOXF2htSa2NzZbsxGFfDGkCOhKcf2B C0TCBxWQGJcHch97Hgn8Umjy6gboKdxXceJj3Q149mQ2AVs+fMOcTh6k0JLL4ro/AxwD ad3DAKm64b++ACtDFg298fAqm/rFU2TJOi1W29vphHRTf8WZd+GuMUiYaE9git+asBTU AysZEsVr+oy2BFmki4lm6zprm+EcaJ2RhO0KfgF8eqzW6WzJvUJesfoFO0PqKmeLSdaL 9Dkn+KtaMSu/KZC49HNRL79si/xCDrQC6Yrju+8tujEpyHSF1oMcfUJGZ80R+CdE8GbN E8SQ== X-Gm-Message-State: AOJu0Yw/Na8/RkTUzQkpzlx8doUdD6Z6CpUxl34vIHnhFDjBHBTNBBB3 L/+MOHcZsSIPvD/LpX0zjkPgOwwmvyNkfjJoT+Kw1sHqFGzBOECd5cwW26ayyNk= X-Received: by 2002:a17:903:2b04:b0:1d9:7ab0:5e20 with SMTP id mc4-20020a1709032b0400b001d97ab05e20mr7448141plb.69.1707051266767; Sun, 04 Feb 2024 04:54:26 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCU2P3M441IKo3m94kcEIRyLqmQoSjqPXpbfoHeFX+kaEVe4IRHlE8e+6vNrp+rtriUX5uoFL4D/zFlmli9GWz2GA6Qu0KZAYzDd+wVjQHfqcSdN/dUzNO/esBTcZdhfUbYFVkrjYBMeufya Received: from n37-034-248.byted.org ([180.184.51.70]) by smtp.gmail.com with ESMTPSA id pt12-20020a17090b3d0c00b002968824041dsm900193pjb.5.2024.02.04.04.54.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 04:54:26 -0800 (PST) From: Zhongkun He <hezhongkun.hzk@bytedance.com> To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Zhongkun He <hezhongkun.hzk@bytedance.com> Subject: [PATCH] mm/z3fold: remove unneeded spinlock Date: Sun, 4 Feb 2024 20:54:04 +0800 Message-Id: <20240204125404.2112384-1-hezhongkun.hzk@bytedance.com> X-Mailer: git-send-email 2.20.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789973024087378352 X-GMAIL-MSGID: 1789973024087378352 |
Series |
mm/z3fold: remove unneeded spinlock
|
|
Commit Message
Zhongkun He
Feb. 4, 2024, 12:54 p.m. UTC
There is no need to use spinlock in this section, so
remove it.
Signed-off-by: Zhongkun He <hezhongkun.hzk@bytedance.com>
---
mm/z3fold.c | 2 --
1 file changed, 2 deletions(-)
Comments
On Sun, Feb 04, 2024 at 08:54:04PM +0800, Zhongkun He wrote: > There is no need to use spinlock in this section, so > remove it. I don't know this code at all, but the idiom is (relatively) common. It waits until anybody _currently_ holding the lock has released it. That would, eg, make it safe to free the 'pool' memory. > - spin_lock(&pool->lock); > - spin_unlock(&pool->lock);
On Mon, Feb 5, 2024 at 2:46 AM Matthew Wilcox <willy@infradead.org> wrote: > > On Sun, Feb 04, 2024 at 08:54:04PM +0800, Zhongkun He wrote: > > There is no need to use spinlock in this section, so > > remove it. > > I don't know this code at all, but the idiom is (relatively) common. > It waits until anybody _currently_ holding the lock has released it. > > That would, eg, make it safe to free the 'pool' memory. > > > - spin_lock(&pool->lock); > > - spin_unlock(&pool->lock); > no, please see the commit 'e774a7bc7f0adb'. spin_lock(&pool->lock); - if (!list_empty(&page->lru)) - list_del_init(&page->lru); spin_unlock(&pool->lock); The original purpose of this lock was to protect page->lru, which was removed now, so the spinlock is unnecessary. Thanks for your time.
On Mon, Feb 05, 2024 at 09:08:05AM +0800, Zhongkun He wrote: > On Mon, Feb 5, 2024 at 2:46 AM Matthew Wilcox <willy@infradead.org> wrote: > > > > On Sun, Feb 04, 2024 at 08:54:04PM +0800, Zhongkun He wrote: > > > There is no need to use spinlock in this section, so > > > remove it. > > > > I don't know this code at all, but the idiom is (relatively) common. > > It waits until anybody _currently_ holding the lock has released it. > > > > That would, eg, make it safe to free the 'pool' memory. > > > > > - spin_lock(&pool->lock); > > > - spin_unlock(&pool->lock); > > > > no, please see the commit 'e774a7bc7f0adb'. > > spin_lock(&pool->lock); > - if (!list_empty(&page->lru)) > - list_del_init(&page->lru); > spin_unlock(&pool->lock); > > The original purpose of this lock was to protect page->lru, > which was removed now, so the spinlock is unnecessary. But pool->lock protects other stuff too? This doesn't rule out that there is some other ordering dependency on cycling the lock before freeing the entry. The person who would know best is the maintainer of this code, Vitaly. Let's CC him.
On Thu, Feb 8, 2024 at 11:29 AM Johannes Weiner <hannes@cmpxchg.org> wrote: > > On Mon, Feb 05, 2024 at 09:08:05AM +0800, Zhongkun He wrote: > > On Mon, Feb 5, 2024 at 2:46 AM Matthew Wilcox <willy@infradead.org> wrote: > > > > > > On Sun, Feb 04, 2024 at 08:54:04PM +0800, Zhongkun He wrote: > > > > There is no need to use spinlock in this section, so > > > > remove it. > > > > > > I don't know this code at all, but the idiom is (relatively) common. > > > It waits until anybody _currently_ holding the lock has released it. > > > > > > That would, eg, make it safe to free the 'pool' memory. > > > > > > > - spin_lock(&pool->lock); > > > > - spin_unlock(&pool->lock); > > > > > > > no, please see the commit 'e774a7bc7f0adb'. > > > > spin_lock(&pool->lock); > > - if (!list_empty(&page->lru)) > > - list_del_init(&page->lru); > > spin_unlock(&pool->lock); > > > > The original purpose of this lock was to protect page->lru, > > which was removed now, so the spinlock is unnecessary. > > But pool->lock protects other stuff too? This doesn't rule out that > there is some other ordering dependency on cycling the lock before > freeing the entry. The person who would know best is the maintainer of > this code, Vitaly. Let's CC him. Thank you for your reply and look forward to hearing from Vitaly.
diff --git a/mm/z3fold.c b/mm/z3fold.c index 7c76b396b74c..7f608c0667f3 100644 --- a/mm/z3fold.c +++ b/mm/z3fold.c @@ -442,8 +442,6 @@ static void __release_z3fold_page(struct z3fold_header *zhdr, bool locked) WARN_ON(!list_empty(&zhdr->buddy)); set_bit(PAGE_STALE, &page->private); clear_bit(NEEDS_COMPACTING, &page->private); - spin_lock(&pool->lock); - spin_unlock(&pool->lock); if (locked) z3fold_page_unlock(zhdr);