From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.200 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795332642; b=wIjjzd0kGdZtqB6gktZkjCj7manSkxkVE437a5PSYLwEyaOq68fqUsnjXmXLdUAzDvjo czYOwXa2YJD4ng5UhxQ1nNpgj+Ow/W27BuljI8be6T2DpvuCNiKxHBp1lD3ULCKX1bYlD 0tj923dfXwsqCe/o+90njAmiyXnbst97LVilWGyiG7PNOQuvuMEI+8RoNmtiGtc3v6Mmc WnQ8AYe+f+ScoiyUXSnRKEdwiW9Fr72Am6k9kKWd4AYR2tfjckpDotP+EzG7kT2et9k+b 3w4dmC2bWMimUMYa1tADf/AdaoZxQZsEHQ9jM4Vv5hAoJoZcJmNxvZkWZ6yBJ4rjlTg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795332642; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date:MIME-Version:User-Agent: Subject:To:Cc:References:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=H02gl3A8lED/orev+VVlUTCHLPwpp1eOdDDA4V8ytIA=; b=NneBmTZWGijGQh63fUidG48MFfthrL34KGdf4jhRG9YaMoxEumO1N2fsAhEHVz7fIFkB kUbR40ODi7Y4tkSSP1VvHbDY75CCicNfvfh0rrExTy4YISetbgcW7g/oLNWsbB2Zzv7K+ 3+P3yLWb7pCHOESWQMVdEdJ8yHmWa65btAMh6HOqEiPbeX4wQ0Z1PZJIYAeuF3QybZGD/ 82lCcOhSxfwSvqZV4B3oAOOgaz3NL2dXPnj9xDJR5anrNr/C95qllI3YzwqeD0zyEpVXg seA+X5kg/mIq+CsdogqIH2qyb2axf5qkgaFTePZn2xMVtU5a1hEbmL5O+hZvZi9vbGw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=M8jygr5a; arc=none smtp.remote-ip=91.218.175.200 Received: from mta0.migadu.com (out-200.mta0.migadu.com [91.218.175.200]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 999C9606A332 for ; Sun, 22 Nov 2026 07:30:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 999C9606A332 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=M8jygr5a X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=NLC7oANZwCfL7depjHfIzJ4jloTo6BAzdIgGpvntEFI=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1795332639; v=1; x=1795937439; b=M8jygr5aBCWN7dK64eSo5G8nBVNnH0PVvZJGbiNzj+/iqwBKnRyiMpIwEeajBT8v9Zwurfdb 4WVj/0p+Z8kpL94Zyzs+pjbbbZTWMJqOsf4W2KJXbOfLfrnI7egNG+fFRkVEV1nxoKF3B1VtJq1 8pUyTesQeNgTH7mUVdlBe9BM= X-Envelope-To: linux-kernel@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id b98bde626d255cef; Sun, 22 Nov 2026 07:30:38 +0000 X-Mizu-Trace-ID: b98bde626d255cef X-Migadu-Flow: FLOW_OUT Message-ID: <3af03366-784b-48bb-a807-9ccea92e39ca@linux.dev> Date: Sun, 22 Nov 2026 15:30:25 +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 v5 04/17] mm/memcg: add folio-based lruvec live helper To: kasong@tencent.com, linux-mm@kvack.org Cc: Andrew Morton , Johannes Weiner , Muchun Song , Ying Huang , Chris Li , Baoquan He , Nico Pache , Usama Arif , Michal Hocko , Roman Gushchin , Shakeel Butt , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Barry Song , Axel Rasmussen , Yuanchu Xie , Wei Xu , Vlastimil Babka , Suren Baghdasaryan , Nhat Pham , Youngjun Park , Zi Yan , Gregory Price , "Matthew Wilcox (Oracle)" , Baolin Wang , Ryan Roberts , Dev Jain , Lance Yang , Hugh Dickins , SJ Park , David Rientjes , Yu Zhao , Vernon Yang , Zicheng Wang , Chen Ridong , Tal Zussman , Kairui Song , Xiang Liu , Ehab Ababneh , Zhao Zhenzhuo , Lian Wang , Joanne Koong , Kunwu Chan , Hui Zhu , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, damon@lists.linux.dev, linux-doc@vger.kernel.org References: <20261119-mglru-fg-v5-0-9eee2fe97a2d@tencent.com> <20261119-mglru-fg-v5-4-9eee2fe97a2d@tencent.com> From: Qi Zheng In-Reply-To: <20261119-mglru-fg-v5-4-9eee2fe97a2d@tencent.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 11/19/26 5:03 AM, Kairui Song via B4 Relay wrote: > From: Kairui Song > > Add a helper that resolves a live lruvec for a folio under RCU > without taking the lruvec lock. It takes a folio directly so the > lruvec lookup happens inside the RCU read-side critical section, > which a lruvec-based interface cannot guarantee. The first user is > the lockless folio_inc_lru_refs() path later in the series. > > Factor the ancestor walk out of lruvec_live_lock_irq() into > __lruvec_get_live(), so that both entry points share it, and spell > out why the walk is enough while only the RCU read lock is held: > reparenting of a memcg that starts dying waits for a grace period, > so it cannot race with the caller until the lock is released. Right, that's the ordering: CSS_DYING is set before the reparenting in the RCU work, so testing for a dying memcg under `rcu_read_lock()` fully covers the race. > > Move memcg_is_dying() up in memcontrol.h, next to the other memcg state > predicates, and use it for the walk rather than repeating the open coded > css_is_dying() test a few definitions away from where it is explained. > > No functional change for existing callers. > > Tested-by: Zhao Zhenzhuo > Signed-off-by: Kairui Song > --- > include/linux/memcontrol.h | 71 ++++++++++++++++++++++++++++++++++++---------- > 1 file changed, 56 insertions(+), 15 deletions(-) > LGTM, so: Reviewed-by: Qi Zheng Thanks, Qi