From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 3901537C0E6 for ; Tue, 21 Apr 2026 03:07:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776740846; cv=none; b=T+UL+ZNLEWFUJ818hdDdsbMLWRR11mmed1uu3Fpy0MVwQCRyTZZRJ+PNl8ZxLdhbYJL+532d//DRoeSYgwT69yX2moy7YR/dPhSnl1M+dOSz0F0b5g8HH6GhFg0JbLVMjGEeP5E/st/CMcOmsIyVlVKQafZH9ZePhmkAn8YI/Cc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776740846; c=relaxed/simple; bh=aF/UkhCs2sXjpLZZ8EJMXj3n8vqyVnU6ma6HupdSaMw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TtdcXnwWG213jbaZn7HoFGHgKcn+4u/Fs8kcZbY+QpozsSZEudJ3v37nOJsptYClK3Y09l5JWQnvlrgT8pzSTgvf40kbNdNh2qL5thjNzENi8TIgm+9hwrBIEYgFe3+jBxyzHQD9j0axrO7WJ4g9FLuEF0o31c8bTeVeBAFZftM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=ROlz3vKd; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ROlz3vKd" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1776740844; 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: in-reply-to:in-reply-to:references:references; bh=oqkCB8gg1IaUA29GIqPtEMXErOagjLMO2tdDX2wDRaY=; b=ROlz3vKdVda7VYJdoWm6Lbe2Rn2DMW9SZxnAbSZ9I5p4OtTebMLVn6lvPXQVzd+jlZ7Wu4 LRVRAEdbfmmOyOS71etJy3zFTpencUJ9SePB1iaoXyt0Xlv+vaGS75inqPor+whmmyx6vO v1rNzQ1HjcO8qPMN5aW6sSuRDYqmb2I= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-449-0aQeQXPvOxGsYdnzx6me9Q-1; Mon, 20 Apr 2026 23:07:19 -0400 X-MC-Unique: 0aQeQXPvOxGsYdnzx6me9Q-1 X-Mimecast-MFC-AGG-ID: 0aQeQXPvOxGsYdnzx6me9Q_1776740834 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 37476195608E; Tue, 21 Apr 2026 03:07:14 +0000 (UTC) Received: from llong-thinkpadp16vgen1.westford.csb (unknown [10.22.65.81]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0D92F19560AB; Tue, 21 Apr 2026 03:07:06 +0000 (UTC) From: Waiman Long To: Tejun Heo , Johannes Weiner , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Jonathan Corbet , Shuah Khan , Catalin Marinas , Will Deacon , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Long Li , Guenter Roeck , Frederic Weisbecker , "Paul E. McKenney" , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Anna-Maria Behnsen , Ingo Molnar , Thomas Gleixner , Chen Ridong , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Ben Segall , Mel Gorman , Valentin Schneider , K Prateek Nayak , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman Cc: cgroups@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-hyperv@vger.kernel.org, linux-hwmon@vger.kernel.org, rcu@vger.kernel.org, netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, Costa Shulyupin , Qiliang Yuan , Waiman Long Subject: [PATCH 19/23] cgroup/cpuset: Improve check for calling housekeeping_update() Date: Mon, 20 Apr 2026 23:03:47 -0400 Message-ID: <20260421030351.281436-20-longman@redhat.com> In-Reply-To: <20260421030351.281436-1-longman@redhat.com> References: <20260421030351.281436-1-longman@redhat.com> Precedence: bulk X-Mailing-List: cgroups@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 By making sure that isolated_hk_cpus matches isolated_cpus at boot time, we can more accurately determine if calling housekeeping_update() is needed by comparing if the two cpumasks are equal. The update_housekeeping flag still have a use in cpuset_handle_hotplug() to determine if a work function should be queued to invoke cpuset_update_sd_hk_unlock() as it is not supposed to look at isolated_hk_cpus without holding cpuset_top_mutex. Signed-off-by: Waiman Long --- kernel/cgroup/cpuset.c | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index a4eccb0ec0d1..1b0c50b46a49 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -1339,26 +1339,29 @@ static void cpuset_update_sd_hk_unlock(void) __releases(&cpuset_mutex) __releases(&cpuset_top_mutex) { + update_housekeeping = false; + /* force_sd_rebuild will be cleared in rebuild_sched_domains_locked() */ if (force_sd_rebuild) rebuild_sched_domains_locked(); - if (update_housekeeping) { - update_housekeeping = false; - cpumask_copy(isolated_hk_cpus, isolated_cpus); - - /* - * housekeeping_update() is now called without holding - * cpus_read_lock and cpuset_mutex. Only cpuset_top_mutex - * is still being held for mutual exclusion. - */ - mutex_unlock(&cpuset_mutex); - cpus_read_unlock(); - WARN_ON_ONCE(housekeeping_update(isolated_hk_cpus, BIT(HK_TYPE_DOMAIN))); - mutex_unlock(&cpuset_top_mutex); - } else { + if (cpumask_equal(isolated_hk_cpus, isolated_cpus)) { + /* No housekeeping cpumask update needed */ cpuset_full_unlock(); + return; } + + cpumask_copy(isolated_hk_cpus, isolated_cpus); + + /* + * housekeeping_update() is now called without holding + * cpus_read_lock and cpuset_mutex. Only cpuset_top_mutex + * is still being held for mutual exclusion. + */ + mutex_unlock(&cpuset_mutex); + cpus_read_unlock(); + WARN_ON_ONCE(housekeeping_update(isolated_hk_cpus, BIT(HK_TYPE_DOMAIN))); + mutex_unlock(&cpuset_top_mutex); } /* @@ -3692,10 +3695,11 @@ int __init cpuset_init(void) BUG_ON(!alloc_cpumask_var(&cpus_attach, GFP_KERNEL)); - if (housekeeping_enabled(HK_TYPE_DOMAIN_BOOT)) + if (housekeeping_enabled(HK_TYPE_DOMAIN_BOOT)) { cpumask_andnot(isolated_cpus, cpu_possible_mask, housekeeping_cpumask(HK_TYPE_DOMAIN_BOOT)); - + cpumask_copy(isolated_hk_cpus, isolated_cpus); + } return 0; } -- 2.53.0