From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-173.mta0.migadu.com (out-173.mta0.migadu.com [91.218.175.173]) (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 659C037106D for ; Wed, 11 Mar 2026 01:01:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773190882; cv=none; b=POUf9aJKSoHvwmzFdydfSmSkTbFM0yIXraCEV6ykSxOPBuYOFWs1wmEDMjpLuWUFnvVDJhEyhP+TIv6eOBxXFf+lNKmWAtV3A/Wx2ZWdJY0r5nVF+zLp5CvtCmOS2GKG02wchubx9J97sz7OipUE7F7tv55qqPG+rVPCac80V00= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773190882; c=relaxed/simple; bh=BRnvxecRJrtJR52VTI82H9eQekjTHMZcpnbZu9WnyQ0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Rw9iZPrt2aFemHwLmUyw0Eg709VcgmJqtq1ICpzAeXbo/eOl/vDqPkJ6iXAxm9IkbWD6rnSlQ5qGSnjQbMSckecOhYWI6z7laGu8UdyzoJMaNG8FdEWIDPXxtEfBqft4CDwYzExyHEJbMoVv8da3GV3AurN1AJs2SP8iauVdHwc= 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=LgHUGpls; arc=none smtp.client-ip=91.218.175.173 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="LgHUGpls" 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=1773190869; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=1zI0HjdpVIeLf9hsutuK6PY4JFf5qAhFtdlVI8aS1sw=; b=LgHUGplsk2p9syAn/wJWFocufn0GBEBbF/HLE+Hy6ni8L7uAVzEcVw7Zi4W98y97igwNd3 ct3hRgGLQHsuKtE95Av+ETz/CnvanrSyODESwHGyblTNbf6APrdMKTbSSTKZRvOn7KUPk/ Ju7/rXEFjmtKd1lL3Ymwc6MgnShnvxA= From: Shakeel Butt To: Tejun Heo Cc: Johannes Weiner , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Chen Ridong , Jakub Kicinski , Meta kernel team , linux-mm@kvack.org, netdev@vger.kernel.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 0/3] cgroup: improve cgroup_file_notify() scalability Date: Tue, 10 Mar 2026 18:00:58 -0700 Message-ID: <20260311010101.3306366-1-shakeel.butt@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT Jakub Kicinski reported that after the commit d929525c2e30 ("memcg: net: track network throttling due to memcg memory pressure"), in Meta fleet, the network intensive workloads started seeing extensive spinlock contention in the rx path in the function cgroup_file_notify(). cgroup_file_notify() uses a single global spinlock to protect the cfile->kn pointer across all cgroups. On systems with many cgroups under memory pressure, this becomes a bottleneck as multiple CPUs in reclaim call __memcg_memory_event(), which walks the cgroup hierarchy calling cgroup_file_notify() at each level -- all serialized on the same lock. This series reduces the lock hold time by moving kernfs_notify() outside the critical section, adds lockless fast-path checks to avoid the lock entirely in common cases (torn-down files and rate-limited bursts), and replaces the global lock with a per-cgroup_file lock to eliminate cross-cgroup contention. Changes since v1: - Second patch moves rate-limiting code out of lock Shakeel Butt (3): cgroup: reduce cgroup_file_kn_lock hold time in cgroup_file_notify() cgroup: add lockless fast-path checks to cgroup_file_notify() cgroup: replace global cgroup_file_kn_lock with per-cgroup_file lock include/linux/cgroup-defs.h | 1 + kernel/cgroup/cgroup.c | 53 ++++++++++++++++++++----------------- 2 files changed, 29 insertions(+), 25 deletions(-) -- 2.52.0