From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=115.124.30.133 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796109498; b=WkgYYOeerzt5WJC9E+LAPirVDgQckPNl9XEgOygVX5TFMH80S9OeVsdj+ObCGnwojq3T lXc56CRnG8n8NHGyZDeveAphIJc0bb5VSiemo5oX90t4UmWoz1AtSMspc//1rztEnRHh+ zU+K4DSqKPaSj8SXVU5emG5Jt7rK1cpYEcYkpc/EakGGbGvAWVzFmptVae7Eu41AKZP7b FAnyKEBsfRQr2WdMKtBlfGat6nIxOOBuCFG8X9bAE8KjKPFauODoHBz6IBY+rKR34OfRq YyADScMrY6gVCOohNYUq7MdJ0ByeiBsYVGHa3L/RuFPf1uqnygpZOhzBzKZ+lRJ9g5Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796109498; h=DMARC-Filter:DKIM-Signature:X-Alimail-AntiSpam:Received:Message-ID: Date:MIME-Version:User-Agent:Subject:To:Cc:References:From: In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=WZDTygY6vOd2Ozs/JURt5dLZt3yAD2SdaQYaU/4uNWQ=; b=a707FJg8x7ytwcVBKx9LnK6ml3NRjvDCCR0J3cSK168ZbEYqbiCUQgiXF6JP2C6cTNSh Lpvi+/tcWwmn1dRvQje1NC1bbfTAIR2dTZIaptL3tppsK9j36ptrlFNjxQ1q0kyaYZRVL Psyy5k8bSUiA99W24GJqAXHYuESAMgjt0TGF1h2VP6/Tvmfld60Q1gM2h656+MddllrGU HEJAFUA/eS7cYBJokZnZGeuxt1ZEiXOnR47CbeeW03YsHxTfo8A224jZQmdh3Lv3zCZ1x tRrK2Tb1WoKuoPm9AkfUcNhpamBPkqn9uEL4dWSj7IkqQENKKolovmJZUMGLEfTxBhQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b=pMzbjBLT; arc=none smtp.remote-ip=115.124.30.133 Received: from out30-133.freemail.mail.aliyun.com (out30-133.freemail.mail.aliyun.com [115.124.30.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C3731606A687; Tue, 1 Dec 2026 07:18:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C3731606A687 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b=pMzbjBLT DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1796109488; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=WZDTygY6vOd2Ozs/JURt5dLZt3yAD2SdaQYaU/4uNWQ=; b=pMzbjBLTVvvv1anTCnYoGXDa8ij6InXxysV/KAw7xCeJpdFi/0c4iiOmM+prf4AlK4c1W2tyi9c8c5jPQ4prcgqaaQrR4jwUAcXid1wYS0xSbOfAvgXke5O3sq5ERYhUxsjQokmOt+0VG+3t8pDAj5nwTVDc/76FWUI6ueeSycs= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R701e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033037009110;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=18;SR=0;TI=SMTPD_---0XFvuofD_1796109485; Received: from 30.74.144.135(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0XFvuofD_1796109485 cluster:ay36) by smtp.aliyun-inc.com; Tue, 01 Dec 2026 15:18:07 +0800 Message-ID: <86852b44-03c1-4865-8ef0-a7c0d0b26113@linux.alibaba.com> Date: Tue, 1 Dec 2026 15:18:05 +0800 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/3] mm/mglru: test PG_lru before taking a folio reference To: "Barry Song (Xiaomi)" , akpm@linux-foundation.org Cc: hannes@cmpxchg.org, mhocko@kernel.org, qi.zheng@linux.dev, shakeel.butt@linux.dev, kasong@tencent.com, axelrasmussen@google.com, yuanchu@google.com, weixugc@google.com, baoquan.he@linux.dev, mason@kernel.org, david@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, ridong.chen@linux.dev, yuzhao@google.com, stable@vger.kernel.org References: <20261129143759.96221-1-baohua@kernel.org> <20261129143759.96221-3-baohua@kernel.org> From: Baolin Wang In-Reply-To: <20261129143759.96221-3-baohua@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 11/29/26 10:37 PM, Barry Song (Xiaomi) wrote: > From: Chris Mason > > With MGLRU, reclaim that races with compaction for a folio can deadlock > on the lruvec->lru_lock that it already holds. > > isolate_folio() runs under the lru_lock. It takes a reference, and drops > it again if another isolator has already cleared PG_lru. That > folio_put() must not be the last one, since the free path takes the > lru_lock if PG_lru is set. But compaction can release the lru_lock while > the folio is still on the list with PG_lru clear. If the folio is > truncated or unmapped meanwhile, the two isolators hold the only > references: > > isolate_migratepages_block() evict_folios() > ============================ ============== > folio_get_nontail_page() > folio_test_clear_lru() > goto isolate_abort > lruvec_unlock_irqrestore() > lruvec_lock_irq() > isolate_folio() > folio_try_get() > folio_test_clear_lru() fails > folio_set_lru() > folio_put() > folio_put() > __page_cache_release() > folio_lruvec_lock_irqsave() > > The fix used here is to leave a folio alone if PG_lru is already clear, > before a reference is taken, as isolate_lru_folios() does. An isolator > that clears PG_lru after that test has to take the lru_lock before it > drops its own reference. > > Fixes: ac35a4902374 ("mm: multi-gen LRU: minimal implementation") > Cc: stable@vger.kernel.org > Signed-off-by: Chris Mason > Signed-off-by: David Hildenbrand (Arm) > [Kairui: Improved the comment] > Signed-off-by: Kairui Song > Signed-off-by: Barry Song (Xiaomi) > --- LGTM. Reviewed-by: Baolin Wang