From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f182.google.com (mail-qt1-f182.google.com [209.85.160.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D23BC27A904 for ; Thu, 4 Dec 2025 18:28:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764872939; cv=none; b=BYdew/G/zP9wQ5vf68hUyko8I/ErtoDlOZKLDISU1CuTUS2mVOl7NWWnvBNyJMHoih2oKw5T5RVOdwgKeYqLvAWKXPqW+0cxBrXCq7eiCkSzj2gPaf3Bweux+g8qvEM8H0Hr0TrNsUtrhRFRBMj5qValngli/Vh36JIjL5PUuxI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764872939; c=relaxed/simple; bh=5GqhyZT6Rt3PfQ/6GKSyzDj33c7nIyXN6+SMU3m/DgI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Jc5Ohl3GEBVSiN/z6lFQYFo6DJAgL15GjXwFLRcUI8mC5G0aipP2fpGwC/HCgIw80xW35PQjT21eoDcuxhYHMt8W/RiDte6Zqb8n8gcikZZbdRQbjXZmD5FB5ir5LV1lL0fq48529lJXyeMtVwppsjzIaz1lSnLt0w/vHrWb4wA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmpxchg.org; spf=pass smtp.mailfrom=cmpxchg.org; dkim=pass (2048-bit key) header.d=cmpxchg.org header.i=@cmpxchg.org header.b=lxeQUoo0; arc=none smtp.client-ip=209.85.160.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmpxchg.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cmpxchg.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cmpxchg.org header.i=@cmpxchg.org header.b="lxeQUoo0" Received: by mail-qt1-f182.google.com with SMTP id d75a77b69052e-4eddfb8c7f5so14084241cf.1 for ; Thu, 04 Dec 2025 10:28:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg.org; s=google; t=1764872935; x=1765477735; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=EbYKo00Iv7GRqeuEurZ+VNuUOvRrRabNx4MSyyDcnsw=; b=lxeQUoo0LyPiKrmh97mRwEgczR4+misUTNkh0pxOPHRfbrK/EHBeZnNl0I6yN4X+47 uJMn9LxJgIg22LlikYUugDNSvD9TjiboVdGeHZDTs++B7vx70ndQM4gSlQ5RIlpGaYI7 T6Kc+AydSZF6QKn7kVcM1eEdgYukQp6THfVvCpq6Rs4zsqXzwa1t3LVhLAu7AunT3S+r m+gmiqnkAwSSmSc14eYRd2/pgcM0HlZ7QJV833wI1raGmVnCc2Z05q9aBcRJjDoL7OyY R/IDiZ0gO80Iq5TFfBo1oaU74bJPGnBfFY1vehLQTLCaCSGk6CxXW3fdvkrKyNVO/rn7 noeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764872935; x=1765477735; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EbYKo00Iv7GRqeuEurZ+VNuUOvRrRabNx4MSyyDcnsw=; b=d8RBrsgOwsYlg8c5vQcbvxdddjQKoH11jTbNAHoFJClKL6gAeJPmcG6/6uzZB6qFsx jMT8+AoAp5g1EmjSBXfbJF5T7mR5uUnOjw4zHvpFm1VKaoH1DncJFxbkWkzrO7mDj3Db VL+JW0i+7KfoSzc8vMy6+hk4eDTN+XVakMRO25KtwvykepUJwWKwzX+RclXHzN2GXWat ou0Obrx6LRe5j/Eo6c2d05yOU2buv927k2+0NgmDhYgWR5S7EthQGaBb5nPwL3bSotC4 uxlHDDydoKBjRqhF6fyRYvs/i0oHX01IvnQF6kW08j79vMhXXKd+bSo4D0RzNA96d3Vq 8m0A== X-Forwarded-Encrypted: i=1; AJvYcCVKarnXpAo0+tT2R3LyyuKrmbGjemW8gn/M4oDL2wPTxQ5E2E50y+Yza6vpg6gsXYqIHyKsFxogsjfBIgM=@vger.kernel.org X-Gm-Message-State: AOJu0YxXzvg0BjvjAjJZk9A71LOHxowXCDEECjRQ0+UfMQDdzhNwfe7C plvoUbyl/LqfV5HuheDRC+f+jVHVUsjzbTPUgE8kFtKF90IMiGD6EwJ1mOpB83ZFp5g= X-Gm-Gg: ASbGncuPV4nD3O/hBYgmo2l18CsZbNCBfxyPcP2U62yb+L6nYYtpDFehHA/63v6Mddu JmL3lOegLjR/VzYudmuwkM91iJMGtR/b2xvwZPfBynIkpUR1AyVzvFd1NQMX1Hn0QYVQplsHtQU FWMMhjNJYNNsYkcy9h4F0s1VkMS75tqwSZGDZuc0os8Y5oAW+fyetCyMlEeZITiKbcY6vzyxP7U jOdyyDzgQ2NL1m+4Ft7kVGu1RptU6jWkcx2MsIvZjZh21FP6XDB/e/g/p01SWdf+8vGG+WerF+n 1gyyfXvGVqm1HsB3jaAMVxKT3V7HYSTytVdHikZQSf/QbcKWvzUIPt2aBmIbFEdsVNqyn/+BWTT f4sSZ1sdxzIRaptVbsu+AkH9L/dtZHXXWsYIU4pYYU7ZIXGULfScBdjGOaAlxiYXSudughO/aaq RNa5i/5lB79hwIGVuCuw90 X-Google-Smtp-Source: AGHT+IGZlFZPSAeM4UXQLHs00EEi+GdYO84wd6mPsj8XuMELP7WRFAZg4UDdzJCd4HZJh7eQnkG5Jg== X-Received: by 2002:ac8:59cf:0:b0:4ed:e5c1:798 with SMTP id d75a77b69052e-4f023a08b64mr52873691cf.35.1764872935525; Thu, 04 Dec 2025 10:28:55 -0800 (PST) Received: from localhost ([2603:7000:c01:2716:929a:4aff:fe16:c778]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-88827f49e51sm15291736d6.15.2025.12.04.10.28.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Dec 2025 10:28:54 -0800 (PST) Date: Thu, 4 Dec 2025 13:28:50 -0500 From: Johannes Weiner To: Chen Ridong Cc: akpm@linux-foundation.org, axelrasmussen@google.com, yuanchu@google.com, weixugc@google.com, david@kernel.org, lorenzo.stoakes@oracle.com, Liam.Howlett@oracle.com, vbabka@suse.cz, rppt@kernel.org, surenb@google.com, mhocko@suse.com, corbet@lwn.net, roman.gushchin@linux.dev, shakeel.butt@linux.dev, muchun.song@linux.dev, yuzhao@google.com, zhengqi.arch@bytedance.com, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, lujialin4@huawei.com, chenridong@huawei.com Subject: Re: [RFC PATCH -next 1/2] mm/mglru: use mem_cgroup_iter for global reclaim Message-ID: <20251204182850.GA481418@cmpxchg.org> References: <20251204123124.1822965-1-chenridong@huaweicloud.com> <20251204123124.1822965-2-chenridong@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20251204123124.1822965-2-chenridong@huaweicloud.com> On Thu, Dec 04, 2025 at 12:31:23PM +0000, Chen Ridong wrote: > From: Chen Ridong > > The memcg LRU was originally introduced for global reclaim to enhance > scalability. However, its implementation complexity has led to performance > regressions when dealing with a large number of memory cgroups [1]. > > As suggested by Johannes [1], this patch adopts mem_cgroup_iter with > cookie-based iteration for global reclaim, aligning with the approach > already used in shrink_node_memcgs. This simplification removes the > dedicated memcg LRU tracking while maintaining the core functionality. > > It performed a stress test based on Zhao Yu's methodology [2] on a > 1 TB, 4-node NUMA system. The results are summarized below: > > memcg LRU memcg iter > stddev(pgsteal) / mean(pgsteal) 91.2% 75.7% > sum(pgsteal) / sum(requested) 216.4% 230.5% > > The new implementation demonstrates a significant improvement in > fairness, reducing the standard deviation relative to the mean by > 15.5 percentage points. While the reclaim accuracy shows a slight > increase in overscan (from 85086871 to 90633890, 6.5%). > > The primary benefits of this change are: > 1. Simplified codebase by removing custom memcg LRU infrastructure > 2. Improved fairness in memory reclaim across multiple cgroups > 3. Better performance when creating many memory cgroups > > [1] https://lore.kernel.org/r/20251126171513.GC135004@cmpxchg.org > [2] https://lore.kernel.org/r/20221222041905.2431096-7-yuzhao@google.com > Signed-off-by: Chen Ridong Acked-by: Johannes Weiner The diff and the test results look good to me. Comparing the resulting shrink_many() with shrink_node_memcgs(), this also looks like a great step towards maintainability and unification. Thanks!