From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.216 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796525887; b=IOcxZ33nKbH1ltMo8WsRszCCYM00Fi09r8uV/PErPLRZf3flzB3bvLGXEjOk15qzvFRC PjN7HAtfv3x/wOZiX53MnTqO7on6BNDDywoa3S93dvEdLh3w4lZ5Te9st1Sco7Oz+RZZp A7SVcZDwoW3cietogdVRgQm5cVWwOCKDwaEfWOzvNc1AlZ1dSAv9sx+cvQAnaOkpp4Ppx ZNFaZZJ05dj7fHHja8BKH+tntSgjGsktb66UC4ReLWwslK8KMvLF/BOdxNVtlp146ilAM ln8Zhr6DRBeA34uBPoVhvN18esKTjU+vbckRgYNVC4Ip+BVDSymKQRa3R6eXqTgy0Wg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796525887; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Content-Type:Mime-Version:Subject:From: In-Reply-To:Date:Cc:Content-Transfer-Encoding:Message-Id:References: To:X-Mailer; bh=Q4Das3xGa2HYvKG99kB03E2qf/ZN9/M0qsQdz9a4xDU=; b=yDUJQXPr7sQNmjwVQqu3UcjLDE5RRTUwRQ783JaogJdY3ReTD16OMlMD7bwnDLcGnm9x nYC+9ohG8+wukn4VhaO65vAUxttlkQGUIrlinTYUcfRFR+DYs455IYA+y98rFwD1BQ0B6 hR/qalyYXfKD+CJ7huKsTj1pSDSEIocBtJFC9g5gNM2q/E25Y/gIZ8yam+BK+Zjpov+zC 8elNnrKsexeJz1y2LeHT1r/F0mew3cmYGDFiQdhCheQnoKdmJgXVx+lfzp+qG0e6fjjk3 NGvHzO18mrAohjeAvXMSyiKul+yMRzIKZc8pA1CcvusH8o/MjyZVnN1+ZCbIjjJcKQQ== 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=auSjzWi1; arc=none smtp.remote-ip=95.215.58.216 Received: from mta1.migadu.com (out-216.mta1.migadu.com [95.215.58.216]) (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 88FC0606A31F for ; Sun, 6 Dec 2026 02:58:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 88FC0606A31F 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=auSjzWi1 X-Envelope-To: cgroups@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=n5TaEyaWnMEk0GMMFGEee/e4w7CWviszp7l7QFISukc=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796525884; v=1; x=1797130684; b=auSjzWi1lEVwkf5/H1H7twBt52xB57lGA5HLd/Og/qwazaG+tqTbWPAWTiABjttmqMwd37Qo ReaxLIvYTKuHSkE1n5SOD3tdONfFLYH+cO9euL77jHwtUfWOFmasOW3j27raj0gCQgPmLrjXWBw FMab5OnffWVOqoi90ENK8i1w= X-Envelope-To: cgroups@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id b0f03a0d41e70b45; Sun, 06 Dec 2026 02:58:04 +0000 X-Mizu-Trace-ID: b0f03a0d41e70b45 X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset=us-ascii X-Mailing-List: cgroups@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3901.200.71.1.16\)) Subject: Re: [PATCH 1/2] mm: list_lru: fix XArray node leak at destroy From: Muchun Song In-Reply-To: <20261204173929.2355221-1-hannes@cmpxchg.org> Date: Sun, 6 Dec 2026 10:57:48 +0800 Cc: Muchun Song , Andrew Morton , Chris Mason , David Hildenbrand , Michal Hocko , Roman Gushchin , Shakeel Butt , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, Dave Chinner , Kairui Song , Qi Zheng Content-Transfer-Encoding: 7bit Message-Id: References: <20261204173929.2355221-1-hannes@cmpxchg.org> To: Johannes Weiner X-Mailer: Apple Mail (2.3901.200.71.1.16) > On Dec 5, 2026, at 01:39, Johannes Weiner wrote: > > From: Chris Mason > > memcg_destroy_list_lru() tears down lru->xa by erasing its entries, > and relies on the XArray to free each node once its last entry is > gone. That is not how an XArray is torn down. A node can exist > without entries, and nothing frees that one; it also keeps the count > of its parent up, so the parent and everything above it stay > allocated as well. The API has xa_destroy() for this: free the > entries, then call it to free the nodes. > > Empty nodes come from a store that gave up partway. xas_create() > builds the path to a new index one level at a time, and links each > node into the tree before it allocates the next. If that allocation > fails, the linked node stays. This is by design: once xas_nomem() > has refilled the cache, the retry descends into the node and > completes the path, and later stores reuse it too. But if the retry > cannot allocate either, the store returns -ENOMEM and the node stays > empty. __memcg_list_lru_alloc() gets there with GFP_NOWAIT when the > page cache allocates a node under memory pressure. > > The leak is small, a few nodes per list_lru, and shows at umount. > > Fix it by calling xa_destroy() once the entries are freed. > > Fixes: bbca91cca9a9 ("mm: list_lru: replace linear array with xarray") > Cc: Dave Chinner > Cc: Kairui Song > Cc: Michal Hocko > Cc: Muchun Song > Cc: Qi Zheng > Cc: Roman Gushchin > Cc: Shakeel Butt > Signed-off-by: Chris Mason > Signed-off-by: David Hildenbrand (Arm) > Signed-off-by: Johannes Weiner Acked-by: Muchun Song (ByteDance) Thanks.