Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 75378199246 for ; Thu, 19 Sep 2024 08:51:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=83.149.199.84 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726735915; cv=none; b=Hu8go9hWWCE4Imim3Wi4vT7uAt/mRThx+MMDkvsUyLEUGQozl7U1bbFmcW84aM7s0c3DUJhhVg9ldcX+vFB36u3+5gctLZ6ayLD+UDJolqRE5qnUw/kyu8IhiYyi+B3R6gZSCfSp0X3AmbJWLDr7vamBo1mVK6k9+vfAun/A0SA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726735915; c=relaxed/simple; bh=nKA4NtU2849l/ocd584e87shWiysgLoErawIX/jiiGc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=EGiE1AmedrQFmlXlgn0uygxRN9sEsIi+bNFKc07b2Yh7qCFsVLNs23BRvyCP5LwaiRqPGF0fefKylsnLGyyQJs3Gkby2+yAi3AXrOXXpGH26MQQpgjR9GqFboHLo+GZViZ/KgfbvwhivIUwGFE3rFT0nlCY1Z8+BTi8bbihF2M4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ispras.ru; spf=pass smtp.mailfrom=ispras.ru; dkim=pass (1024-bit key) header.d=ispras.ru header.i=@ispras.ru header.b=mTteDyVj; arc=none smtp.client-ip=83.149.199.84 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ispras.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ispras.ru Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ispras.ru header.i=@ispras.ru header.b="mTteDyVj" Received: from fpc.intra.ispras.ru (unknown [10.10.165.11]) by mail.ispras.ru (Postfix) with ESMTPSA id 674D040B2794; Thu, 19 Sep 2024 08:51:50 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru 674D040B2794 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ispras.ru; s=default; t=1726735910; bh=l8wjukOOzlhGGXPMuIVIoRJoj2sKtLxI19RcRd2G9Qk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mTteDyVjFpn5DSEMtzZIaE8JnyBUIRafWduJi2CRJmtMUVtp0DLDzyhlQunhGPHOv uKqsK4CYe5lJa0tG6bIO5bm01i5d2syBVUA7BFVIM64e80dk3JW8E4ahFbhqiLiswO tP6V+C79XHqPsSsuZizY6QS5nysQZrcVwuszGXss= From: Fedor Pchelkin To: Greg Thelen Cc: Fedor Pchelkin , Chen Ridong , Tejun Heo , Shivani Agarwal , Greg Kroah-Hartman , stable@vger.kernel.org, lvc-project@linuxtesting.org, =?UTF-8?q?Michal=20Koutn=C3=BD?= , Stephen Rothwell , Waiman Long , Yafang Shao , Yosry Ahmed Subject: [PATCH 5.10/5.15 2/2] cgroup: Move rcu_head up near the top of cgroup_root Date: Thu, 19 Sep 2024 11:51:14 +0300 Message-Id: <20240919085114.128781-2-pchelkin@ispras.ru> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20240919085114.128781-1-pchelkin@ispras.ru> References: <20240919085114.128781-1-pchelkin@ispras.ru> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Waiman Long commit a7fb0423c201ba12815877a0b5a68a6a1710b23a upstream. Commit d23b5c577715 ("cgroup: Make operations on the cgroup root_list RCU safe") adds a new rcu_head to the cgroup_root structure and kvfree_rcu() for freeing the cgroup_root. The current implementation of kvfree_rcu(), however, has the limitation that the offset of the rcu_head structure within the larger data structure must be less than 4096 or the compilation will fail. See the macro definition of __is_kvfree_rcu_offset() in include/linux/rcupdate.h for more information. By putting rcu_head below the large cgroup structure, any change to the cgroup structure that makes it larger run the risk of causing build failure under certain configurations. Commit 77070eeb8821 ("cgroup: Avoid false cacheline sharing of read mostly rstat_cpu") happens to be the last straw that breaks it. Fix this problem by moving the rcu_head structure up before the cgroup structure. Fixes: d23b5c577715 ("cgroup: Make operations on the cgroup root_list RCU safe") Reported-by: Stephen Rothwell Closes: https://lore.kernel.org/lkml/20231207143806.114e0a74@canb.auug.org.au/ Signed-off-by: Waiman Long Acked-by: Yafang Shao Reviewed-by: Yosry Ahmed Reviewed-by: Michal Koutný Signed-off-by: Tejun Heo Signed-off-by: Fedor Pchelkin --- include/linux/cgroup-defs.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/linux/cgroup-defs.h b/include/linux/cgroup-defs.h index 08912a5dd438..20b2b32f825b 100644 --- a/include/linux/cgroup-defs.h +++ b/include/linux/cgroup-defs.h @@ -501,6 +501,10 @@ struct cgroup_root { /* Unique id for this hierarchy. */ int hierarchy_id; + /* A list running through the active hierarchies */ + struct list_head root_list; + struct rcu_head rcu; + /* The root cgroup. Root is destroyed on its release. */ struct cgroup cgrp; @@ -510,10 +514,6 @@ struct cgroup_root { /* Number of cgroups in the hierarchy, used only for /proc/cgroups */ atomic_t nr_cgrps; - /* A list running through the active hierarchies */ - struct list_head root_list; - struct rcu_head rcu; - /* Hierarchy-specific flags */ unsigned int flags; -- 2.39.5