From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-177.mta1.migadu.com (out-177.mta1.migadu.com [95.215.58.177]) (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 36D0C31A045; Sat, 28 Feb 2026 14:20:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772288441; cv=none; b=i9dH2XC9aDCLclMke0/8VaLdoPmOraOd0aYYVSTNZb+HW6zkFonAFyUNGy+8wE/27/WKC4+7oKb4zSJ4ASgBRnmWeWg7f932fUcyVX+unDqrEoPLMLSseJEn1ERi1kJz3DgMfZw1iVKLZJ6+CqeWDX9shMUE0dUyGaXeET4ffTk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772288441; c=relaxed/simple; bh=dKGoRK0khX66iE1X2O4AAX9o0uorB+HOAo34WYqi7Uc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=n9iC69wywaiQlJtwlb9YgR8b3dDrLqBefBtIGjpclNand4tghBAMt2WyukzOSSe1FSeH1l915r/ZFgjwO4UhYWPIndxAVEfgG8OgN1CJQbZ4l/x28rlecSuAZJaWJ1UwO5UOaM2SR44800pte8CWciNa5sulnDnVyTJNwIt+CNo= 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=f5tGin5i; arc=none smtp.client-ip=95.215.58.177 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="f5tGin5i" 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=1772288437; 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=ploXD4qKyGErpi2h+6GFoldO2iGJIFZ6IgaMbXbP9Uw=; b=f5tGin5iSOmhU2iID2/zFOti5Z8DzbJC7ulhLGGryEYrVJ++a2+qy9DKv3a8kQy4Q2iYVs KtKhbGs8LIa3HSygX7IhUZK2Cva97yzJo4GguhIbLbtG/zA5s3+Vt5Q+IN+FrwN2ljAvBS CbREK2Lrc78F+xacxiniKL0yMMXXEfQ= From: Shakeel Butt To: Tejun Heo Cc: Johannes Weiner , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Roman Gushchin , Kuniyuki Iwashima , Daniel Sedlak , Meta kernel team , linux-mm@kvack.org, netdev@vger.kernel.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 0/3] cgroup: improve cgroup_file_notify() scalability Date: Sat, 28 Feb 2026 06:20:15 -0800 Message-ID: <20260228142018.3178529-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. 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 | 50 +++++++++++++++++++++---------------- 2 files changed, 29 insertions(+), 22 deletions(-) -- 2.47.3