Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1662946rdb; Thu, 7 Dec 2023 05:46:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IHhp1sxMVpW9x4jzfw1h3UzsR2jqXUpqbKIRMWGc0m+qqsHRDMgvZDPv7N9p6eq1RwcjUVh X-Received: by 2002:a17:903:247:b0:1d0:5878:d4e3 with SMTP id j7-20020a170903024700b001d05878d4e3mr2648880plh.9.1701956819223; Thu, 07 Dec 2023 05:46:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701956819; cv=none; d=google.com; s=arc-20160816; b=anbtrlZKND1f/GEV06BgX1SIE1mGONtVpwBo1Y4K9V8tn3IeAjxZbh/Wh/UuZ548Ca fWH/HA344zZ+jXJoFz0ZQWaps23APnSB/wfxpeQDIbTyYaQ8dLhTJpwLhBkYJsVEkZ1B r8sGGbLyBiP1qPmFftMK2N7VPaUnA2QAKirI6FUs3FC9zKxTAvh4fQ/mF4tAQrBOTXzp hXcKN0eKEeODUBeW1sXwvORdEOKP9FqAQDv39+E5pLwxZ9+jLuYNcr9SpjMOv5O31FwP +8Lg/j0nKjiLsUnZRqWsTAZqm23vI1Kq7nr2rtusfRibdmNssYkrwMrDZV+tiQzVcA/Q yHsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=xICLJqbrK65stKoTdC9zWPAAFCF9WJ2JOuG2uZTX2Bg=; fh=rnq8VKWb6g/wYr0Sdwzp7gGTTUFSfL3cXS9KaXzvHDc=; b=Gn1KXufcijx8RVg/57dFz+rsIJDWbUTvBmm51aNEk62Ia2Mn+2SnaemwiSfvGk/joP 4kIS7cM/g5cmk0Z6jaKEwTaXJgpFttk4UwvhVxx6krwhBX2kET7ZoYO4GPtzdgRf1pru j4ya9coqeN6hwhDWeEiIULkyX8nRNrzCSeHPXRYUoJl7JFcBUBNoWROFxMIWWJyw183f +JT0s5ArSmJaW+lgZwY/EsSl4qDx8KrdldzZnN0IuMSZZf/Ys1A35mkYkt5Up0GHyeND KlefjQH7SafqX4twegWXV42GYSnp/+EdloZyqmY2u5PaAz599gjEKbj9z2viUmMgLPMP Xbnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hGNd25T8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id y9-20020a170902b48900b001cfc0272b48si1161703plr.103.2023.12.07.05.46.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 05:46:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hGNd25T8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 1191E805B30F; Thu, 7 Dec 2023 05:46:39 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442100AbjLGNq2 (ORCPT + 99 others); Thu, 7 Dec 2023 08:46:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442008AbjLGNq0 (ORCPT ); Thu, 7 Dec 2023 08:46:26 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35EF610E9 for ; Thu, 7 Dec 2023 05:46:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701956791; 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=xICLJqbrK65stKoTdC9zWPAAFCF9WJ2JOuG2uZTX2Bg=; b=hGNd25T84/dlThhjxlH+7yGUKT321pOBoIyphJqjQdtgajW7gVXWLlfPyumdFwT52CYrVq j3Gy0IN2WdLmAzuFA5xL1nRTSKZOgLEL+8eNYJFALVL33MrJYj+yoDPRerSzfBSDL3om0X +oruW1/rJrl9MlPHz2WBhjPJbyJ3+IU= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-595-s18BKpLhPquqfPMDwGyRVA-1; Thu, 07 Dec 2023 08:46:25 -0500 X-MC-Unique: s18BKpLhPquqfPMDwGyRVA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5D3FA185A785; Thu, 7 Dec 2023 13:46:25 +0000 (UTC) Received: from llong.com (unknown [10.22.32.209]) by smtp.corp.redhat.com (Postfix) with ESMTP id 821CB2166B35; Thu, 7 Dec 2023 13:46:24 +0000 (UTC) From: Waiman Long To: Tejun Heo , Zefan Li , Johannes Weiner , Yafang Shao Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, Stephen Rothwell , Yosry Ahmed , Waiman Long Subject: [PATCH-cgroup v2] cgroup: Move rcu_head up near the top of cgroup_root Date: Thu, 7 Dec 2023 08:46:14 -0500 Message-Id: <20231207134614.882991-1-longman@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 07 Dec 2023 05:46:39 -0800 (PST) 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 --- 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 5a97ea95b564..ea48c861cd36 100644 --- a/include/linux/cgroup-defs.h +++ b/include/linux/cgroup-defs.h @@ -562,6 +562,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; /* Must be near the top */ + /* * The root cgroup. The containing cgroup_root will be destroyed on its * release. cgrp->ancestors[0] will be used overflowing into the @@ -575,10 +579,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.3