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 59A2944C64E for ; Tue, 14 Jul 2026 19:41:56 +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=1784058118; cv=none; b=hY46Kt+LdJgAXFlBDlN5Qu/GmFr1XhwqIGMaUe7I+hjOG/axfSiRZL/8xUJCSwYV9+91192eD70uPmdXnaRnO7huKIOgPTnbQ95Mi02b475sGb9l+zyW9P3+rtcAuWFY86UMMrg5zPidbkh3hmIrE65p1F2qxSx00p7lnwqIRhw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784058118; c=relaxed/simple; bh=MJOPfZgWoOuY9WoaTSgn/QRExxhrG9WiL/2+OlLbqn8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ffawlPsMRpgywWXVRntmF4A+Ot5dX6f5JfCLqjJU0/aHFjoe6iMM8JwrHTzRzvChVI8UCVnuX1Uo2u5JmM/RNM6m5XO38CarCd61wlGKPRmJilGophV3hlcSEJN0cpNDRokKYQG5XEgLM7BOobX0TrvsVSGj+a3u4SL1g6vDeaQ= 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=Zl8Y98I6; 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="Zl8Y98I6" Date: Tue, 14 Jul 2026 12:41:28 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1784058103; 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: in-reply-to:in-reply-to:references:references; bh=kYcYCSULV/hfG7U7cWmlPQ/oHtSU1VEtwNwKSB8CpEM=; b=Zl8Y98I6TSwbZ6r8suDxniwyylFwFl2e1Uau1HCcE8ii377yG/8MagwcljzpEk0YOb8REZ qHJAuCBiRirQETZGb7LWtF5StJUHNQdqGjh3TlG5a6CDN6PbPEj9NBsA88g0TA5LrGRNq2 e6ARkIOGoJ2oH9RrVX684FV/RY5Ob9o= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Shakeel Butt To: Usama Arif Cc: brauner@kernel.org, qi.zheng@linux.dev, jack@suse.cz, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Al Viro , linux-mm@kvack.org, hughd@google.com, boris@bur.io, clm@fb.com, dsterba@suse.com, linux-btrfs@vger.kernel.org, cem@kernel.org, linux-xfs@vger.kernel.org, hannes@cmpxchg.org, riel@surriel.com, kernel-team@meta.com Subject: Re: [PATCH] fs: push nr_cached_objects memcg gating into individual filesystems Message-ID: References: <20260714101454.1202449-1-usama.arif@linux.dev> 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: <20260714101454.1202449-1-usama.arif@linux.dev> X-Migadu-Flow: FLOW_OUT On Tue, Jul 14, 2026 at 03:14:54AM -0700, Usama Arif wrote: > Commit 0baad6f9b997 ("fs/super: skip non-memcg-aware nr_cached_objects > in memcg slab shrink") added a check in fs/super.c that skips the > ->nr_cached_objects() hook whenever the shrinker is invoked for a > non-root memcg, because none of the current implementations (btrfs, > xfs, shmem huge) honour sc->memcg. > > That policy is really a filesystem-owned property: fs/super.c should > not encode the assumption that these hooks are never memcg-aware, > since a future implementation might legitimately filter by sc->memcg. > Move the check into btrfs_nr_cached_objects(), xfs_fs_nr_cached_objects() > and shmem_unused_huge_count() so each filesystem can lift the > restriction independently once its underlying counters/scans become > memcg-aware, without needing a coordinated change to fs/super.c. > > Behaviour is unchanged: calls into these hooks from shrink_slab_memcg() > still early-return 0 for non-root memcg contexts, keeping the shrinker > bit clearable in each memcg's bitmap; the global (kswapd or root > direct reclaim) path still drives them as before. > > Signed-off-by: Usama Arif Reviewed-by: Shakeel Butt