From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-179.mta1.migadu.com (out-179.mta1.migadu.com [95.215.58.179]) (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 D0DD05FDA7 for ; Thu, 26 Feb 2026 00:25:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772065544; cv=none; b=WE7as080b5XRwOLe1jto6Z03cs4LKDLWwnOTi2kDrL3twhq0E06Qgh3cjcU5Cd8MOdAmPRa1Hh/fbfIL2V9N5PJAP5ee5jBq4zPtifmub8gbzNcL6DnSRodPuI1AgYA5547T39CNdIES6l0Szd2ZfEFi9w+ZejLYCLdUtb9js8c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772065544; c=relaxed/simple; bh=royOVdYRXr1kJsn8jHLrwfGbFidYzWZzC8EWf8oC1Ag=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=d0pPY8jgO8clJZMcibabkzChTSWBCNVqnLqlG55nDGiBnvv7pT3D1/aMmCjzWJGSgf46P2/djfxaEluusGJgT5Dk77eReGMV09BT/tRaGy8mVOviwvGqRGFjWyaGCAlUmcqr7LWJR8FJR8FoNJa1j/o4XK5RGetUJfgJc3OKJZ0= 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=Lhjlr5lN; arc=none smtp.client-ip=95.215.58.179 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="Lhjlr5lN" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1772065540; 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=JmXVL4P1e5YTwQCoJlcBCe7K7mA9E+OOkZZvyk9qLts=; b=Lhjlr5lNIb1WKzputRiZytKzU9MeQHWSk4q1xw1k5qiL896YfGek2Sdzhqho2coh5zYVwK RnxLJhH32L0wMqK9OxLzr06DaYUQX0wC8LuLdxStMCyRXI/R/9diYjyztOSbe7Vtfz0jBa IaqPerrY9fRNnappxWNh4jYDE7ocEoM= From: Roman Gushchin To: Michal =?utf-8?Q?Koutn=C3=BD?= Cc: Andrew Morton , Dave Chinner , Qi Zheng , Muchun Song , Jan Kara , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm: Do not allocate shrinker info with cgroup.memory=nokmem In-Reply-To: <20260225-cgroup-ml-nokmem-shrinker-v1-1-d703899bdda4@suse.com> ("Michal =?utf-8?Q?Koutn=C3=BD=22's?= message of "Wed, 25 Feb 2026 19:38:44 +0100") References: <20260225-cgroup-ml-nokmem-shrinker-v1-1-d703899bdda4@suse.com> Date: Thu, 26 Feb 2026 00:25:17 +0000 Message-ID: <7ia4ikbknyfm.fsf@castle.c.googlers.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=utf-8 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Michal Koutn=C3=BD writes: > 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(). > > 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")). > > 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). > > 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. > > Signed-off-by: Michal Koutn=C3=BD Reviewed-by: Roman Gushchin Thanks!