From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-181.mta1.migadu.com (out-181.mta1.migadu.com [95.215.58.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 46CF93876A5 for ; Thu, 26 Feb 2026 07:19:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772090396; cv=none; b=Uf6XGfA9hUS9UHSQByd6lbWYYoVZdOxdV54sGHwHaNG7SQDrshSQt5qbG4loWik4evJyMNP+bsxTviKaxXvFmJRvqCLHJFTUKh0C/HALDsioaIU8gP44M3aEHVCWGBa5WWuTfxzDBEdFr26JDrNvH9i4vlTzN++M1nIHb4Q3Mi4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772090396; c=relaxed/simple; bh=pt3rSAlPAIRCPueJJuVjc7ZZQjV/hf3zan1yrVBIbqs=; h=Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Cc: Message-Id:References:To; b=L7ti7dolp+bzmAems481qp24e0wWy7Md4fO/wwTdjbFelh82Ti+Qc+dKnQdAAeau5WMxSaXYZazt/KinNvH1j0xpnHYVlIXIu4Nq12dFtpu4lVjpWliGIqg8fQGLWmzAU40EeHOycPOxGQ0dY8PEJp1eBVmhVCzi8vr3av5glDQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=fF853wqr; arc=none smtp.client-ip=95.215.58.181 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) header.d=linux.dev header.i=@linux.dev header.b="fF853wqr" Content-Type: text/plain; charset=utf-8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1772090393; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=npaXqvVXjWOnjtn7obYuDFYCJUrNtZ/favP3D0wZMkA=; b=fF853wqr32BSDTUbGd1rY6RRHLFU34YixtCz6yx6IB5YlxaWnDUycHWULYIe2HbWLdoh97 gysH/UA7f3RNXtn7fyFtmmhpPNQVo8NOBLYHAwzGVGHYr/ecB5Qx+0Gh7ID6ZyHMGI0P6S DRemCPK5n1vwGXFdeO/5lQaPB1huL8M= Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.400.21\)) Subject: Re: [PATCH] mm: Do not allocate shrinker info with cgroup.memory=nokmem X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Muchun Song In-Reply-To: <20260225-cgroup-ml-nokmem-shrinker-v1-1-d703899bdda4@suse.com> Date: Thu, 26 Feb 2026 15:19:02 +0800 Cc: Andrew Morton , Dave Chinner , Qi Zheng , Roman Gushchin , Jan Kara , linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Message-Id: <2F51915F-374B-4C69-8853-D980908BFDE8@linux.dev> References: <20260225-cgroup-ml-nokmem-shrinker-v1-1-d703899bdda4@suse.com> To: =?utf-8?Q?Michal_Koutn=C3=BD?= X-Migadu-Flow: FLOW_OUT > On Feb 26, 2026, at 02:38, Michal Koutn=C3=BD = wrote: >=20 > There'd be no work for memcg-aware shrinkers when kernel memory is not > accounted per cgroup, so we can skip allocating per memcg shrinker = data. > This saves some memory, avoids holding shrinker_mutex with = O(nr_memcgs) > and saves work in shrink_slab_memcg(). >=20 > Then there are SHRINKER_NONSLAB shrinkers which handle non-kernel = memory > so nokmem should not disable their per-memcg behavior. Such shrinkers > (e.g. deferred_split_shrinker) still need access to per-memcg data = (see > also commit 0a432dcbeb32e ("mm: shrinker: make shrinker not depend on > memcg kmem")). >=20 > The savings with this patch come on container hosts that create many > superblocks (each with own shrinker) but tracking and processing > per-memcg data is pointless with nokmem (shrink_slab_memcg() is > partially guarded with !memcg_kmem_online already). >=20 > The patch uses "boottime" predicate mem_cgroup_kmem_disabled() (not > memcg_kmem_online()) to avoid mistakenly un-MEMCG_AWARE-ing shrinkers > registered before first non-root memcg is mkdir'd. >=20 > Signed-off-by: Michal Koutn=C3=BD Reviewed-by: Muchun Song Thanks