From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=115.124.30.98 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796108515; b=msptKlScemuhhsAVnArqatKicWwyOxbswHizQ2C4c3X80Jmh/m/lPKQ2tQY4JMtAv0fL 1CYsfAeAmIf9QkxPZVrQ1p6pItew4NFlJzodo9ybl03BSmQgAi7Aenj7fHpViF2+J7SYD ncjlw3DcVx64NO1D/0T1Sq6H32rAh/W4uomEV6tbaQNk08Rz8kZo0GgMx7V9oeW53d+pe Ix3S+Jfbva18Y6A396KVRzmafJz7pgcDK2I/OzwuHfdlYPmn85bvtWSmt+XTm7IVmVzXW gKho82Soa1tUOh7ATK1DoDsd2cn3xNH2ylluCQJGUxKMJA/W/qRQ+s2dHS4WlhlwkBw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796108515; 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=VNUiK76etZApFNNMmHlPG3IyXuNzfmbp4In3menlr+I=; b=0fg0y+0wzQYQQO96U+HnhvjXBCtn/aQiPfxXIjlsaCLXfZ/BDz9WXYSzeI2FlRUApWdc RveiYV27q2euLIEBiqY/t22kqsTBVCTL/rpUNVhd6zoJKq5XXPCBuS5dU/y5CeeDOImdy NgUhnSxJ8Pt1UtucmFdCcvo69Lkmkobf0x9ePNGw39WE4lXNz+jXRgprxbB9wkRcndxPG XFWwY4MQUxFjgUQZUv8tDq2q6pcdK3NrJXAoEP1+JFsla4Cn7Q1xYtcmxOJZnLpnzEgOP uU6fms34dsdAkfeLuKSPtZoDvJlmEGHXYScJhc3WveImfb2rPckWUwwxYv961e9Zf+w== 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="HB/dzsK8"; arc=none smtp.remote-ip=115.124.30.98 Received: from out30-98.freemail.mail.aliyun.com (out30-98.freemail.mail.aliyun.com [115.124.30.98]) (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 14431606A320 for ; Tue, 1 Dec 2026 07:01:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 14431606A320 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=HB/dzsK8 DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1796108509; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=VNUiK76etZApFNNMmHlPG3IyXuNzfmbp4In3menlr+I=; b=HB/dzsK8GmOWuFXwiacrgf5YOkM80DYRsq61sSznZbGlXnCQidKgd7RFMaD1S5/wZynQI4VdSGgRILf6KGhkGOWYh5q3PMTvI+IN4Yk39mm+7MjwIVKSv6H2uXA2fo6xaxf8JVJmGnsLYt3LmaZMSGVZycAALPKaz1jl9PwOb+c= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R831e4;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=17;SR=0;TI=SMTPD_---0XFwARge_1796108506; Received: from 30.74.144.135(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0XFwARge_1796108506 cluster:ay36) by smtp.aliyun-inc.com; Tue, 01 Dec 2026 15:01:49 +0800 Message-ID: <93d1945e-96df-459d-a1a7-b5a82dab9079@linux.alibaba.com> Date: Tue, 1 Dec 2026 15:01:46 +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 1/3] mm/mglru: count all generations as evictable 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 References: <20261129143759.96221-1-baohua@kernel.org> <20261129143759.96221-2-baohua@kernel.org> From: Baolin Wang In-Reply-To: <20261129143759.96221-2-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 enabled, clean page cache that was reparented from a removed > memory cgroup can stay unreclaimable for as long as the parent has no > other evictable folios on the same node. > > try_to_shrink_lruvec() derives its scan count from > lruvec_evictable_size(), and with a count of 0 it runs neither eviction > nor aging. lruvec_evictable_size() adds up nr_pages[] only for the > generations from min_seq to max_seq. That sum is complete only if the > count of a generation is 0 by the time min_seq advances past it. > > But try_to_inc_min_seq() ignores the counts: it advances min_seq past a > generation as soon as the lists of that generation are empty. A folio > that folio_update_gen() promoted is counted in its new generation, but > stays on the list of the generation that it came from. Normally min_seq > stops at that list, before it reaches the new generation. > > Reparenting moves each list and each count to the same index in the > parent, where that index can stand for a different age: > > index (seq % MAX_NR_GENS) 0 1 2 3 > seq in the child 0 1 2 3 > seq in the parent 4 5 6 3 > > folio F: on folios[0], counted in nr_pages[3] > child: folios[0] holds min_seq at 0 > parent: folios[3] is empty, so min_seq goes from 3 to 4 > sum: nr_pages[0] + nr_pages[1] + nr_pages[2] = 0, without F > > The fix used here is to add up nr_pages[] of all MAX_NR_GENS generations > in lruvec_evictable_size(). > > Fixes: 163bc3d68c9f ("mm/mglru: restructure the reclaim loop") > Signed-off-by: Chris Mason > Signed-off-by: David Hildenbrand (Arm) > [Barry: Rebased onto mm-new and added comments] > Signed-off-by: Barry Song (Xiaomi) > --- LGTM. Reviewed-by: Baolin Wang