Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1427447rdb; Wed, 6 Dec 2023 20:38:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IESUFsCRtaOGf20dX5Tc9ZZoliESP2/rQMldPHSHhYCjZNi5/NujR+n7XjybXeeWl0V3AUw X-Received: by 2002:a0d:d5d6:0:b0:5d7:1940:b36e with SMTP id x205-20020a0dd5d6000000b005d71940b36emr1948825ywd.58.1701923898511; Wed, 06 Dec 2023 20:38:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701923898; cv=none; d=google.com; s=arc-20160816; b=w2IDOaBF2R3vRBgHsehqlrM1dymINl30fFXLU3gxtSEpMbJ/YpWr+IgIHa9+X/Hpl7 RNKgwAiuENIneaAfvlMj4wadDWUBK4EmWsgGWOgcSPPefGLxGl4QzTZkUO2Ux+y/dRaa 1Rj6vwialNbCi9H2ki1W9tI2z5EQbVyBdTBx1vVXr+gqeGGDff3BeVWcHmODteNzwA+6 dUGv6tXk26iZBaZLTabaNA8QQdCsI/us4bbABTk87KrfD3PYnlUWxeR2ghyzXvnTRU3m k9QTtisWV81z6pS9Mjs9Kx9eatxq6DtW4sqg5GO64RdK+Jit+FwIrBxMt0ZKlK9Ymi0h OH9Q== 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=tGYuayIbjuzHLuEu82pkqtgPwJeMuDwkxBYxtZFsrRQ=; fh=52opOHN7djXmrUJdydHUjVcMQ1GAceHjEqPGYf2iqkM=; b=YaCKqDyynLaTi0D4S+BC0BtEFO1fu5N2Un3ElPZ7N0l3IHmItNsxE2hKA8xV0VkM/Q W4Upm/UY1uw97XY0d7eT7pAXKAf7hA9UBPfHB2yiezIgNSUzt1wy/fnPBJ/ysqQm6CfE CSlbAmpAyAZ1OPpTJWUgwaVc/bYEvqwyjgJc523u5ts+0x8OwPg3HJJEeZDNAtMHYtLC QBKbhoUjQgCyZtVsQzwLjyM7sWezr/Zhu3DRNDd511QU6uWSd/82vC8RB5yKQTFNqg6k Ti22e84eePBcKEzNdU7vAN/KPu3jDZNXhhIqL/ufZtaQpp2usQ5yCzlsIV54XzTFElTm +U+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=jIEfo0ZR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id nv8-20020a17090b1b4800b00286ba33ec9esi415188pjb.160.2023.12.06.20.38.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 20:38:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=jIEfo0ZR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id DC776807F492; Wed, 6 Dec 2023 20:38:15 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229840AbjLGEiD (ORCPT + 99 others); Wed, 6 Dec 2023 23:38:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229449AbjLGEiB (ORCPT ); Wed, 6 Dec 2023 23:38:01 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33CFBD3 for ; Wed, 6 Dec 2023 20:38:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701923887; 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=tGYuayIbjuzHLuEu82pkqtgPwJeMuDwkxBYxtZFsrRQ=; b=jIEfo0ZRJcwGhrI5/wQ+Zv9yYCWWUGZd23StJyZ4dvLaNaTJkcB2RseiLVmqv6Vi7IqHm6 9MLknV5ExSz21gLTWUeaX9aaG6+8ur2D8n+JkEpP9gN3ZPzCyzWtKbKL8msMlbIo7J148y KKGxRLElywtcwlIAj1N18ovxVh0Zdvc= 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-442-3EujIB-UPuOPPoDl20n5tQ-1; Wed, 06 Dec 2023 23:38:04 -0500 X-MC-Unique: 3EujIB-UPuOPPoDl20n5tQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (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 685FF83BA86; Thu, 7 Dec 2023 04:38:03 +0000 (UTC) Received: from llong.com (unknown [10.22.34.92]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7550D8CD0; Thu, 7 Dec 2023 04:38:02 +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 , Waiman Long Subject: [PATCH-cgroup] cgroup: Move rcu_head up near the top of cgroup_root Date: Wed, 6 Dec 2023 23:37:53 -0500 Message-Id: <20231207043753.876437-1-longman@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 fry.vger.email 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 (fry.vger.email [0.0.0.0]); Wed, 06 Dec 2023 20:38:16 -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 use of kvfree_rcu(), however, has the limitation that the offset of the rcu_head structure within the larger data structure cannot exceed 4096 or the compilation will fail. By putting rcu_head below the cgroup structure, any change to the cgroup structure that makes it larger has the risk of build failure. Commit 77070eeb8821 ("cgroup: Avoid false cacheline sharing of read mostly rstat_cpu") happens to be the commit that breaks it even though it is not its fault. Fix it by moving the rcu_head structure up before the cgroup structure. Fixes: d23b5c577715 ("cgroup: Make operations on the cgroup root_list RCU safe") Signed-off-by: Waiman Long --- 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..45359969d8cf 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; + /* * 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