Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp2768459rdb; Mon, 5 Feb 2024 18:07:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IGoaK1jax/xi2MM6ghq0YQ0YySSDIBDptfWuKQ1RatzX3YhNOXcB70QUkvRC9ZNVseqbpFY X-Received: by 2002:a17:90a:39c8:b0:296:ae1c:13cd with SMTP id k8-20020a17090a39c800b00296ae1c13cdmr1287079pjf.9.1707185256060; Mon, 05 Feb 2024 18:07:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707185256; cv=pass; d=google.com; s=arc-20160816; b=T/t9JCTaDpt8Li/icXdLQb3c1r2LORWvajlhRXoLEOskSBw5diTcB8NKBcX8QEqkS9 kwllRHjNjxsaT8WT9bXcdGIUMnXldP0b9hwGB+E1OJEhRoKINN+ZxViabMrVVt121Cru 9IxvZGSubzdVT1p9B1LC1F4GeW3Cpr5xgs+3hagiLnbzLrJm6ln+4ZWZC7Lv8X9GMYLM R/YLSErIshBcMTSqYzl7BT4nmhsW56hPvfQiEfWbk35Q6Obl1aps5fguV+hN5un30LeU WuAH/0Py9lT/W/aT4nJy7xVzGVjrb6cobnuGsW3lyb0bzfIaOW1edBhbeZmeGVIZmY4L 2VoA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:dkim-signature:message-id; bh=eIJijInYFu0cUG/tmLajV3LIHwabmz8bTWiDitWtQ+k=; fh=c2YsCGi3MHfcNmuXrVBeekthiwZoMW6ZdmLB+tLCCpw=; b=aPD1gs0c2VCUuafb6MPAseoOHrZeqWRO2+WGjFKv18DgAVQP3PRGRipe+Ecs1LszmP 0ETGcNZAWRt9fSJQwqrV9jjxCVHgyBrfujMEQXvgRS5MXeiTEmQycvjXlflfmxLhdAJV BuBfb8KMl/rIoMUtGkmZNG7P09gfJ1BDK1AOSRQMFnBqSFENATKI9R74eAM1rFfhAm1R 9bNrV4eNHPghXlPQ9/JcQJAyk0vQzBLmHt+4QsR5kCs0pURfi82vT/RqK+JkYKcgH468 VZwZuAdeJJ0pPE8em29NArO/sgt7u2MXwE2L+9/GEZCCLZkT2HDwT0b6WY94Xr2Ekoie QW/w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=LV73bJJY; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-54180-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54180-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev X-Forwarded-Encrypted: i=1; AJvYcCUd/v4EAMTwnOx0s4A3vYnXwZAKr/mT6aHblMKPAGhGJHVNscQ7wZIiOodF8rA0rQqF9uqUFSoomORITPcEAZSs6IQ9rtGKyc9w6LXqkw== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id t12-20020a17090b018c00b00296c5f9c2a7si254661pjs.70.2024.02.05.18.07.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 18:07:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-54180-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=@linux.dev header.s=key1 header.b=LV73bJJY; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-54180-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54180-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev 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 7E60C287FBB for ; Tue, 6 Feb 2024 02:07:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1842756B65; Tue, 6 Feb 2024 02:07:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="LV73bJJY" Received: from out-187.mta1.migadu.com (out-187.mta1.migadu.com [95.215.58.187]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 69AD05677B for ; Tue, 6 Feb 2024 02:07:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.187 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707185249; cv=none; b=f7x7ekVxI2GleR5V21DFRtCrQ7N/LcYOzio0AK4bXbw6C8rWN/5U1MEzHwbSi3QHCHkCyDV9hbvHIwV7woxjwbYkpd2A/ULMx4xDTty7TN1Wk4KrSPzGfD1hX0t1uWBO9yygFDmYgQxcJ1txgl/++0LqitbyfPeLr3iNfTUAXuc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707185249; c=relaxed/simple; bh=mqZDvLVTP8VLg8Z0roufiMafcQM1Hvn1MKVhNCmazPo=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=K1nd8Hk9NG7ezoGVTHr5Iy15GWqLnbHZBydpBZalHeCbkL8dOHL/ipLdxAfjuZ9oAM1CZ0emQUtT6xVxlrdEC0hTb9SHgw04Bke4DJV9riyrY6+cl0w8VO9O/0Jl6+Je5q1+9fJNb9t7a486kPTwa9KOFQ4I6CuEQNwCFcHvkos= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=LV73bJJY; arc=none smtp.client-ip=95.215.58.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Message-ID: <38dae4da-7afe-4405-9545-294efc18fb8f@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1707185245; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eIJijInYFu0cUG/tmLajV3LIHwabmz8bTWiDitWtQ+k=; b=LV73bJJYq+BC3YGCCBAWgfDKtcFLErH41Ml9O9zbPiFRre+qDKQcXllfi1XubWXUBEvFDH KwuK1d1z4y8kBULaXqi8ehf+wTFSQwz4MmtNl/FK+QWr/hw+o+72dUCpbYpwbyoXfze0tm NmFxfyNHo1Qf/tEcRKhOcVB7M0Kmu90= Date: Tue, 6 Feb 2024 10:07:19 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH] mm/swap_state: update zswap LRU's protection range with the folio locked Content-Language: en-US To: Nhat Pham , akpm@linux-foundation.org Cc: hannes@cmpxchg.org, yosryahmed@google.com, linux-mm@kvack.org, kernel-team@meta.com, linux-kernel@vger.kernel.org References: <20240205232442.3240571-1-nphamcs@gmail.com> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Chengming Zhou In-Reply-To: <20240205232442.3240571-1-nphamcs@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT On 2024/2/6 07:24, Nhat Pham wrote: > Move the zswap LRU protection range update above the swap_read_folio() > call, and only when a new page is allocated. This is the case where > (z)swapin could happen, which is a signal that the zswap shrinker should > be more conservative with its reclaiming action. > > It also prevents a race, in which folio migration can clear the > memcg_data of the now unlocked folio, resulting in a warning in the > inlined folio_lruvec() call. > > Reported-by: syzbot+17a611d10af7d18a7092@syzkaller.appspotmail.com > Closes: https://lore.kernel.org/all/000000000000ae47f90610803260@google.com/ > Fixes: b5ba474f3f51 ("zswap: shrink zswap pool based on memory pressure") > Signed-off-by: Nhat Pham LGTM, thanks! Reviewed-by: Chengming Zhou > --- > mm/swap_state.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) > > diff --git a/mm/swap_state.c b/mm/swap_state.c > index e671266ad772..7255c01a1e4e 100644 > --- a/mm/swap_state.c > +++ b/mm/swap_state.c > @@ -680,9 +680,10 @@ struct folio *swap_cluster_readahead(swp_entry_t entry, gfp_t gfp_mask, > /* The page was likely read above, so no need for plugging here */ > folio = __read_swap_cache_async(entry, gfp_mask, mpol, ilx, > &page_allocated, false); > - if (unlikely(page_allocated)) > + if (unlikely(page_allocated)) { > + zswap_folio_swapin(folio); > swap_read_folio(folio, false, NULL); > - zswap_folio_swapin(folio); > + } > return folio; > } > > @@ -855,9 +856,10 @@ static struct folio *swap_vma_readahead(swp_entry_t targ_entry, gfp_t gfp_mask, > /* The folio was likely read above, so no need for plugging here */ > folio = __read_swap_cache_async(targ_entry, gfp_mask, mpol, targ_ilx, > &page_allocated, false); > - if (unlikely(page_allocated)) > + if (unlikely(page_allocated)) { > + zswap_folio_swapin(folio); > swap_read_folio(folio, false, NULL); > - zswap_folio_swapin(folio); > + } > return folio; > } > > > base-commit: 91f3daa1765ee4e0c89987dc25f72c40f07af34d