Message ID | 20221215090029.2972236-1-qiang1.zhang@intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp230765wrn; Thu, 15 Dec 2022 00:58:58 -0800 (PST) X-Google-Smtp-Source: AA0mqf6x29wWW57DNCIz8rrnOuCGiRae0JWGmnJNKymMWAbj5qfn3uh4saKeO/4R9tG2az5FaN0O X-Received: by 2002:a17:907:f86:b0:7c4:f4b8:f1c6 with SMTP id kb6-20020a1709070f8600b007c4f4b8f1c6mr4166875ejc.4.1671094738207; Thu, 15 Dec 2022 00:58:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671094738; cv=none; d=google.com; s=arc-20160816; b=RpjPzLJ94Xc1jgneJm8JqLiHvMn4UWMzqP86qSgyshxnOWRlwSzaccy9XH9Wlc4grj IIpV6UO+CeSvPtk6pHy1PQ6nkUZowuVDfEPJ58kYadtWgTZhgjh81qvNf1nSp1qCX+Z8 33XW/YAazmBuzbX7t8O/3dURQZ00ycjhBMtxG8231AJYC/driAjzL4P0m/95HoamcSo4 BjuWt0xXfzg+2IvyjDfQjKkyRrRvG4WWDm6nWE5i2Ts8ARJxnEefT/D7ih58HDyn7mBP +Y5luweBkbl7Ww+a799ny/l/LZXhr1sMP/NTXsWLQ+4wQquRvYql4wVDVYpJ9l3b0YLd wCDQ== 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=avv0SgSxMSv1CpDUK49S3oM0FFLjqC7/d9ux4ykiwZ4=; b=hfDeI0jUSir8i4O5bsNvYntnkYzdXKd8xUafYmbmN0WJ6mnXXTt214Wa44Bm3louhU UQTBjMloynemkqHHyTg0syXHqOsNjmo6sHoGAntWmTACVwHwnwpQw6n4g/kBi367mHwI kgW9B9u7wEQPszXnSxZYR6gH3Q8eiJzdFZ7PENc0A4q2nkuNIPuo0R3QPSb2bBAPKL0H AYrbd3OeC7gWyV5j0hOcYLHBGEgHixV5YVQ6LbW57w5Rw4zRmmWBjf4UcGXNf0M0W0VV F1f3eYEri/fjoMdKCYevPzxOJDcfyOdDHLkFxVqDZ8/bKtrKBB5JFhhRbWJffBjJymfE vbNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BreZfMrc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hp33-20020a1709073e2100b007c18e8131e1si6840096ejc.744.2022.12.15.00.58.34; Thu, 15 Dec 2022 00:58:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BreZfMrc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229734AbiLOIzR (ORCPT <rfc822;jeantsuru.cumc.mandola@gmail.com> + 99 others); Thu, 15 Dec 2022 03:55:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229805AbiLOIyz (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 15 Dec 2022 03:54:55 -0500 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1E112C658; Thu, 15 Dec 2022 00:54:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1671094494; x=1702630494; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=Uev9S5ocS7bK1HqwVkJ4NTAo0vUxSsTQB2xMcXsLcAw=; b=BreZfMrcKeDrDHjqakC9qCEOaVT0kB8LX7nZGM4l9SneICIpU5VOqNoo BZjOa/ODz0lVlSOPsprms1m5NbqRIFDDD7b4SYAQJhokjcb8F8lKbBxeF V72gvUaU4xelSlSIu49c6wIe9ztV4yw/6Kdb+QhinuM7CXnCDle2A6iU2 nA4VAnXTTAy9r+iivJctEx3NDDngO09Nuq86tQ1SUWO0vm0I/K3MKzwfj QSPslb11JnOUtNCAeKFgGGADKL9AP8YUp/BVxXMJtBjQg8+8SEUwY4Wql pT04XGQcsI5R7QErCb5a1wdnHp9g/DeKQ5i3UTjeE2loMOquyzUgqnMHW Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10561"; a="316263154" X-IronPort-AV: E=Sophos;i="5.96,246,1665471600"; d="scan'208";a="316263154" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Dec 2022 00:54:54 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10561"; a="642838888" X-IronPort-AV: E=Sophos;i="5.96,246,1665471600"; d="scan'208";a="642838888" Received: from zq-optiplex-7090.bj.intel.com ([10.238.156.129]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Dec 2022 00:54:52 -0800 From: Zqiang <qiang1.zhang@intel.com> To: paulmck@kernel.org, frederic@kernel.org, quic_neeraju@quicinc.com, joel@joelfernandes.org Cc: rcu@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] rcu: Remove duplicate settings for rcu boost kthreads affinity Date: Thu, 15 Dec 2022 17:00:29 +0800 Message-Id: <20221215090029.2972236-1-qiang1.zhang@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_NONE autolearn=ham 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752269836080534433?= X-GMAIL-MSGID: =?utf-8?q?1752269836080534433?= |
Series |
rcu: Remove duplicate settings for rcu boost kthreads affinity
|
|
Commit Message
Zqiang
Dec. 15, 2022, 9 a.m. UTC
Currently, when CPUs going offline, the rcu boost kthreads CPU
affinity has been reset in rcutree_offline_cpu(), therefore this
commit remove duplicate settings in rcutree_dead_cpu().
Signed-off-by: Zqiang <qiang1.zhang@intel.com>
---
kernel/rcu/tree.c | 5 -----
1 file changed, 5 deletions(-)
Comments
On Thu, Dec 15, 2022 at 05:00:29PM +0800, Zqiang wrote: > Currently, when CPUs going offline, the rcu boost kthreads CPU > affinity has been reset in rcutree_offline_cpu(), therefore this > commit remove duplicate settings in rcutree_dead_cpu(). > > Signed-off-by: Zqiang <qiang1.zhang@intel.com> One question... Given that rcutree_offline_cpu() causes rcu_boost_kthread_setaffinity() to be invoked with the number of the outgoing CPU, but rcutree_dead_cpu() instead passes in -1, are these two invocations really redundant? Thanx, paul > --- > kernel/rcu/tree.c | 5 ----- > 1 file changed, 5 deletions(-) > > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c > index 65f3dd2fd3ae..20de83ed0c7e 100644 > --- a/kernel/rcu/tree.c > +++ b/kernel/rcu/tree.c > @@ -4122,15 +4122,10 @@ static void rcu_cleanup_dead_rnp(struct rcu_node *rnp_leaf) > */ > int rcutree_dead_cpu(unsigned int cpu) > { > - struct rcu_data *rdp = per_cpu_ptr(&rcu_data, cpu); > - struct rcu_node *rnp = rdp->mynode; /* Outgoing CPU's rdp & rnp. */ > - > if (!IS_ENABLED(CONFIG_HOTPLUG_CPU)) > return 0; > > WRITE_ONCE(rcu_state.n_online_cpus, rcu_state.n_online_cpus - 1); > - /* Adjust any no-longer-needed kthreads. */ > - rcu_boost_kthread_setaffinity(rnp, -1); > // Stop-machine done, so allow nohz_full to disable tick. > tick_dep_clear(TICK_DEP_BIT_RCU); > return 0; > -- > 2.25.1 >
On Thu, Dec 15, 2022 at 05:00:29PM +0800, Zqiang wrote: > Currently, when CPUs going offline, the rcu boost kthreads CPU > affinity has been reset in rcutree_offline_cpu(), therefore this > commit remove duplicate settings in rcutree_dead_cpu(). > > Signed-off-by: Zqiang <qiang1.zhang@intel.com> > >One question... > >Given that rcutree_offline_cpu() causes rcu_boost_kthread_setaffinity() >to be invoked with the number of the outgoing CPU, but rcutree_dead_cpu() >instead passes in -1, are these two invocations really redundant? Although -1 is passed in, but at this time, the outgoing CPU has been removed from rcu_rnp_online_cpus(rnp), in other words, we will eliminate the same CPU, which is also we passed in cpu in the rcutree_offline_cpu() before. Thanks Zqiang > > Thanx, paul > --- > kernel/rcu/tree.c | 5 ----- > 1 file changed, 5 deletions(-) > > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c > index 65f3dd2fd3ae..20de83ed0c7e 100644 > --- a/kernel/rcu/tree.c > +++ b/kernel/rcu/tree.c > @@ -4122,15 +4122,10 @@ static void rcu_cleanup_dead_rnp(struct rcu_node *rnp_leaf) > */ > int rcutree_dead_cpu(unsigned int cpu) > { > - struct rcu_data *rdp = per_cpu_ptr(&rcu_data, cpu); > - struct rcu_node *rnp = rdp->mynode; /* Outgoing CPU's rdp & rnp. */ > - > if (!IS_ENABLED(CONFIG_HOTPLUG_CPU)) > return 0; > > WRITE_ONCE(rcu_state.n_online_cpus, rcu_state.n_online_cpus - 1); > - /* Adjust any no-longer-needed kthreads. */ > - rcu_boost_kthread_setaffinity(rnp, -1); > // Stop-machine done, so allow nohz_full to disable tick. > tick_dep_clear(TICK_DEP_BIT_RCU); > return 0; > -- > 2.25.1 >
On Thu, Dec 15, 2022 at 05:00:29PM +0800, Zqiang wrote: > Currently, when CPUs going offline, the rcu boost kthreads CPU > affinity has been reset in rcutree_offline_cpu(), therefore this > commit remove duplicate settings in rcutree_dead_cpu(). > > Signed-off-by: Zqiang <qiang1.zhang@intel.com> > >One question... > >Given that rcutree_offline_cpu() causes rcu_boost_kthread_setaffinity() >to be invoked with the number of the outgoing CPU, but rcutree_dead_cpu() >instead passes in -1, are these two invocations really redundant? > >Although -1 is passed in, but at this time, the outgoing CPU has been removed from >rcu_rnp_online_cpus(rnp), in other words, we will eliminate the same CPU, which is >also we passed in cpu in the rcutree_offline_cpu() before. > I also used " qemu -smp 4 "for a simple test. 1) rcutree_offline_cpu() (gdb) bt #0 set_cpus_allowed_ptr (p=p@entry=0xffff888100bd9cc0, new_mask=new_mask@entry=0xffff888100ce7cd0) at kernel/sched/core.c:2939 #1 0xffffffff811be169 in rcu_boost_kthread_setaffinity (rnp=0xffffffff837a4c00 <rcu_state>, outgoingcpu=outgoingcpu@entry=3) at kernel/rcu/tree_plugin.h:1250 #2 0xffffffff811cfa9f in rcutree_affinity_setting (outgoing=3, cpu=3) at kernel/rcu/tree.c:4297 #3 rcutree_offline_cpu (cpu=3) at kernel/rcu/tree.c:4341 #4 0xffffffff810c4e6f in cpuhp_invoke_callback (cpu=cpu@entry=3, state=state@entry=CPUHP_AP_RCUTREE_ONLINE, bringup=bringup@entry=false, node=<optimized out>, lastp=lastp@entry=0xffff88815b027568) at kernel/cpu.c:192 #5 0xffffffff810c6e24 in cpuhp_thread_fun (cpu=<optimized out>) at kernel/cpu.c:785 #6 0xffffffff8111784e in smpboot_thread_fn (data=0xffff88810014c3c0) at kernel/smpboot.c:164 #7 0xffffffff8110c88e in kthread (_create=0xffff8881009b8b00) at kernel/kthread.c:376 #8 0xffffffff81002902 in ret_from_fork () at arch/x86/entry/entry_64.S:306 #9 0x0000000000000000 in ?? () (gdb) p/x *0xffff888100ce7cd0 $1 = 0x7 2) rcutree_dead_cpu() #0 set_cpus_allowed_ptr (p=p@entry=0xffff888100bd9cc0, new_mask=new_mask@entry=0xffff888109fc7948) at kernel/sched/core.c:2939 #1 0xffffffff811be169 in rcu_boost_kthread_setaffinity (rnp=0xffffffff837a4c00 <rcu_state>, outgoingcpu=outgoingcpu@entry=-1) at kernel/rcu/tree_plugin.h:1250 #2 0xffffffff811cf4a1 in rcutree_dead_cpu (cpu=3) at kernel/rcu/tree.c:4176 #3 0xffffffff810c4e6f in cpuhp_invoke_callback (cpu=cpu@entry=3, state=CPUHP_RCUTREE_PREP, bringup=bringup@entry=false, node=node@entry=0x0 <fixed_percpu_data>, lastp=lastp@entry=0x0 <fixed_percpu_data>) at kernel/cpu.c:192 #4 0xffffffff810c58f5 in cpuhp_invoke_callback_range (bringup=bringup@entry=false, cpu=cpu@entry=3, st=st@entry=0xffff88815b027540, target=target@entry=CPUHP_OFFLINE) at kernel/cpu.c:675 #5 0xffffffff827a5f6a in cpuhp_down_callbacks (target=CPUHP_OFFLINE, st=0xffff88815b027540, cpu=3) at kernel/cpu.c:1170 #6 _cpu_down (cpu=cpu@entry=3, tasks_frozen=tasks_frozen@entry=0, target=target@entry=CPUHP_OFFLINE) at kernel/cpu.c:1170 #7 0xffffffff810c6ff8 in cpu_down_maps_locked (target=CPUHP_OFFLINE, cpu=3) at kernel/cpu.c:1202 #8 cpu_down (cpu=3, target=target@entry=CPUHP_OFFLINE) at kernel/cpu.c:1210 #9 0xffffffff810c7906 in cpu_device_down (dev=dev@entry=0xffff88815b026988) at kernel/cpu.c:1227 (gdb) p/x *0xffff888109fc7948 $2 = 0x7 As can be seen from the above, we have set the same cpumask twice for the same boost kthreads. Thanks Zqiang >Thanks >Zqiang > > Thanx, paul > --- > kernel/rcu/tree.c | 5 ----- > 1 file changed, 5 deletions(-) > > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c > index 65f3dd2fd3ae..20de83ed0c7e 100644 > --- a/kernel/rcu/tree.c > +++ b/kernel/rcu/tree.c > @@ -4122,15 +4122,10 @@ static void rcu_cleanup_dead_rnp(struct rcu_node *rnp_leaf) > */ > int rcutree_dead_cpu(unsigned int cpu) > { > - struct rcu_data *rdp = per_cpu_ptr(&rcu_data, cpu); > - struct rcu_node *rnp = rdp->mynode; /* Outgoing CPU's rdp & rnp. */ > - > if (!IS_ENABLED(CONFIG_HOTPLUG_CPU)) > return 0; > > WRITE_ONCE(rcu_state.n_online_cpus, rcu_state.n_online_cpus - 1); > - /* Adjust any no-longer-needed kthreads. */ > - rcu_boost_kthread_setaffinity(rnp, -1); > // Stop-machine done, so allow nohz_full to disable tick. > tick_dep_clear(TICK_DEP_BIT_RCU); > return 0; > -- > 2.25.1 >
On Sat, Dec 17, 2022 at 01:02:03PM +0000, Zhang, Qiang1 wrote: > On Thu, Dec 15, 2022 at 05:00:29PM +0800, Zqiang wrote: > > Currently, when CPUs going offline, the rcu boost kthreads CPU > > affinity has been reset in rcutree_offline_cpu(), therefore this > > commit remove duplicate settings in rcutree_dead_cpu(). > > > > Signed-off-by: Zqiang <qiang1.zhang@intel.com> > > > >One question... > > > >Given that rcutree_offline_cpu() causes rcu_boost_kthread_setaffinity() > >to be invoked with the number of the outgoing CPU, but rcutree_dead_cpu() > >instead passes in -1, are these two invocations really redundant? > > > >Although -1 is passed in, but at this time, the outgoing CPU has been removed from > >rcu_rnp_online_cpus(rnp), in other words, we will eliminate the same CPU, which is > >also we passed in cpu in the rcutree_offline_cpu() before. > > > > I also used " qemu -smp 4 "for a simple test. > > 1) rcutree_offline_cpu() > > (gdb) bt > #0 set_cpus_allowed_ptr (p=p@entry=0xffff888100bd9cc0, new_mask=new_mask@entry=0xffff888100ce7cd0) > at kernel/sched/core.c:2939 > #1 0xffffffff811be169 in rcu_boost_kthread_setaffinity (rnp=0xffffffff837a4c00 <rcu_state>, > outgoingcpu=outgoingcpu@entry=3) at kernel/rcu/tree_plugin.h:1250 > #2 0xffffffff811cfa9f in rcutree_affinity_setting (outgoing=3, cpu=3) at kernel/rcu/tree.c:4297 > #3 rcutree_offline_cpu (cpu=3) at kernel/rcu/tree.c:4341 > #4 0xffffffff810c4e6f in cpuhp_invoke_callback (cpu=cpu@entry=3, state=state@entry=CPUHP_AP_RCUTREE_ONLINE, > bringup=bringup@entry=false, node=<optimized out>, lastp=lastp@entry=0xffff88815b027568) at kernel/cpu.c:192 > #5 0xffffffff810c6e24 in cpuhp_thread_fun (cpu=<optimized out>) at kernel/cpu.c:785 > #6 0xffffffff8111784e in smpboot_thread_fn (data=0xffff88810014c3c0) at kernel/smpboot.c:164 > #7 0xffffffff8110c88e in kthread (_create=0xffff8881009b8b00) at kernel/kthread.c:376 > #8 0xffffffff81002902 in ret_from_fork () at arch/x86/entry/entry_64.S:306 > #9 0x0000000000000000 in ?? () > > (gdb) p/x *0xffff888100ce7cd0 > $1 = 0x7 > > 2) rcutree_dead_cpu() > > #0 set_cpus_allowed_ptr (p=p@entry=0xffff888100bd9cc0, new_mask=new_mask@entry=0xffff888109fc7948) > at kernel/sched/core.c:2939 > #1 0xffffffff811be169 in rcu_boost_kthread_setaffinity (rnp=0xffffffff837a4c00 <rcu_state>, > outgoingcpu=outgoingcpu@entry=-1) at kernel/rcu/tree_plugin.h:1250 > #2 0xffffffff811cf4a1 in rcutree_dead_cpu (cpu=3) at kernel/rcu/tree.c:4176 > #3 0xffffffff810c4e6f in cpuhp_invoke_callback (cpu=cpu@entry=3, state=CPUHP_RCUTREE_PREP, bringup=bringup@entry=false, > node=node@entry=0x0 <fixed_percpu_data>, lastp=lastp@entry=0x0 <fixed_percpu_data>) at kernel/cpu.c:192 > #4 0xffffffff810c58f5 in cpuhp_invoke_callback_range (bringup=bringup@entry=false, cpu=cpu@entry=3, > st=st@entry=0xffff88815b027540, target=target@entry=CPUHP_OFFLINE) at kernel/cpu.c:675 > #5 0xffffffff827a5f6a in cpuhp_down_callbacks (target=CPUHP_OFFLINE, st=0xffff88815b027540, cpu=3) at kernel/cpu.c:1170 > #6 _cpu_down (cpu=cpu@entry=3, tasks_frozen=tasks_frozen@entry=0, target=target@entry=CPUHP_OFFLINE) at kernel/cpu.c:1170 > #7 0xffffffff810c6ff8 in cpu_down_maps_locked (target=CPUHP_OFFLINE, cpu=3) at kernel/cpu.c:1202 > #8 cpu_down (cpu=3, target=target@entry=CPUHP_OFFLINE) at kernel/cpu.c:1210 > #9 0xffffffff810c7906 in cpu_device_down (dev=dev@entry=0xffff88815b026988) at kernel/cpu.c:1227 > > (gdb) p/x *0xffff888109fc7948 > $2 = 0x7 > > As can be seen from the above, we have set the same cpumask twice for the same boost kthreads. Very good, thank you for checking! I have queued this as shown below, so please let me know of any issues. Thanx, Paul ------------------------------------------------------------------------ commit 5815245b56229198d5f5d0c48c26d3c0c53ee222 Author: Zqiang <qiang1.zhang@intel.com> Date: Wed Dec 21 11:15:43 2022 -0800 rcu: Remove redundant call to rcu_boost_kthread_setaffinity() The rcu_boost_kthread_setaffinity() function is invoked at rcutree_online_cpu() and rcutree_offline_cpu() time, early in the online timeline and late in the offline timeline, respectively. It is also invoked from rcutree_dead_cpu(), however, in the absence of userspace manipulations (for which userspace must take responsibility), this call is redundant with that from rcutree_offline_cpu(). This redundancy can be demonstrated by printing out the relevant cpumasks This commit therefore removes the call to rcu_boost_kthread_setaffinity() from rcutree_dead_cpu(). Signed-off-by: Zqiang <qiang1.zhang@intel.com> Signed-off-by: Paul E. McKenney <paulmck@kernel.org> diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index c3255d27286c4..a6181b76fd5ab 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -4165,15 +4165,10 @@ static void rcu_cleanup_dead_rnp(struct rcu_node *rnp_leaf) */ int rcutree_dead_cpu(unsigned int cpu) { - struct rcu_data *rdp = per_cpu_ptr(&rcu_data, cpu); - struct rcu_node *rnp = rdp->mynode; /* Outgoing CPU's rdp & rnp. */ - if (!IS_ENABLED(CONFIG_HOTPLUG_CPU)) return 0; WRITE_ONCE(rcu_state.n_online_cpus, rcu_state.n_online_cpus - 1); - /* Adjust any no-longer-needed kthreads. */ - rcu_boost_kthread_setaffinity(rnp, -1); // Stop-machine done, so allow nohz_full to disable tick. tick_dep_clear(TICK_DEP_BIT_RCU); return 0;
On Sat, Dec 17, 2022 at 01:02:03PM +0000, Zhang, Qiang1 wrote: > On Thu, Dec 15, 2022 at 05:00:29PM +0800, Zqiang wrote: > > Currently, when CPUs going offline, the rcu boost kthreads CPU > > affinity has been reset in rcutree_offline_cpu(), therefore this > > commit remove duplicate settings in rcutree_dead_cpu(). > > > > Signed-off-by: Zqiang <qiang1.zhang@intel.com> > > > >One question... > > > >Given that rcutree_offline_cpu() causes rcu_boost_kthread_setaffinity() > >to be invoked with the number of the outgoing CPU, but rcutree_dead_cpu() > >instead passes in -1, are these two invocations really redundant? > > > >Although -1 is passed in, but at this time, the outgoing CPU has been removed from > >rcu_rnp_online_cpus(rnp), in other words, we will eliminate the same CPU, which is > >also we passed in cpu in the rcutree_offline_cpu() before. > > > > I also used " qemu -smp 4 "for a simple test. > > 1) rcutree_offline_cpu() > > (gdb) bt > #0 set_cpus_allowed_ptr (p=p@entry=0xffff888100bd9cc0, new_mask=new_mask@entry=0xffff888100ce7cd0) > at kernel/sched/core.c:2939 > #1 0xffffffff811be169 in rcu_boost_kthread_setaffinity (rnp=0xffffffff837a4c00 <rcu_state>, > outgoingcpu=outgoingcpu@entry=3) at kernel/rcu/tree_plugin.h:1250 > #2 0xffffffff811cfa9f in rcutree_affinity_setting (outgoing=3, cpu=3) at kernel/rcu/tree.c:4297 > #3 rcutree_offline_cpu (cpu=3) at kernel/rcu/tree.c:4341 > #4 0xffffffff810c4e6f in cpuhp_invoke_callback (cpu=cpu@entry=3, state=state@entry=CPUHP_AP_RCUTREE_ONLINE, > bringup=bringup@entry=false, node=<optimized out>, lastp=lastp@entry=0xffff88815b027568) at kernel/cpu.c:192 > #5 0xffffffff810c6e24 in cpuhp_thread_fun (cpu=<optimized out>) at kernel/cpu.c:785 > #6 0xffffffff8111784e in smpboot_thread_fn (data=0xffff88810014c3c0) at kernel/smpboot.c:164 > #7 0xffffffff8110c88e in kthread (_create=0xffff8881009b8b00) at kernel/kthread.c:376 > #8 0xffffffff81002902 in ret_from_fork () at arch/x86/entry/entry_64.S:306 > #9 0x0000000000000000 in ?? () > > (gdb) p/x *0xffff888100ce7cd0 > $1 = 0x7 > > 2) rcutree_dead_cpu() > > #0 set_cpus_allowed_ptr (p=p@entry=0xffff888100bd9cc0, new_mask=new_mask@entry=0xffff888109fc7948) > at kernel/sched/core.c:2939 > #1 0xffffffff811be169 in rcu_boost_kthread_setaffinity (rnp=0xffffffff837a4c00 <rcu_state>, > outgoingcpu=outgoingcpu@entry=-1) at kernel/rcu/tree_plugin.h:1250 > #2 0xffffffff811cf4a1 in rcutree_dead_cpu (cpu=3) at kernel/rcu/tree.c:4176 > #3 0xffffffff810c4e6f in cpuhp_invoke_callback (cpu=cpu@entry=3, state=CPUHP_RCUTREE_PREP, bringup=bringup@entry=false, > node=node@entry=0x0 <fixed_percpu_data>, lastp=lastp@entry=0x0 <fixed_percpu_data>) at kernel/cpu.c:192 > #4 0xffffffff810c58f5 in cpuhp_invoke_callback_range (bringup=bringup@entry=false, cpu=cpu@entry=3, > st=st@entry=0xffff88815b027540, target=target@entry=CPUHP_OFFLINE) at kernel/cpu.c:675 > #5 0xffffffff827a5f6a in cpuhp_down_callbacks (target=CPUHP_OFFLINE, st=0xffff88815b027540, cpu=3) at kernel/cpu.c:1170 > #6 _cpu_down (cpu=cpu@entry=3, tasks_frozen=tasks_frozen@entry=0, target=target@entry=CPUHP_OFFLINE) at kernel/cpu.c:1170 > #7 0xffffffff810c6ff8 in cpu_down_maps_locked (target=CPUHP_OFFLINE, cpu=3) at kernel/cpu.c:1202 > #8 cpu_down (cpu=3, target=target@entry=CPUHP_OFFLINE) at kernel/cpu.c:1210 > #9 0xffffffff810c7906 in cpu_device_down (dev=dev@entry=0xffff88815b026988) at kernel/cpu.c:1227 > > (gdb) p/x *0xffff888109fc7948 > $2 = 0x7 > > As can be seen from the above, we have set the same cpumask twice for the same boost kthreads. > >Very good, thank you for checking! > >I have queued this as shown below, so please let me know of any issues. I have checked and thank you for the clear description. Thanks Zqiang > > Thanx, Paul > >------------------------------------------------------------------------ commit 5815245b56229198d5f5d0c48c26d3c0c53ee222 Author: Zqiang <qiang1.zhang@intel.com> Date: Wed Dec 21 11:15:43 2022 -0800 rcu: Remove redundant call to rcu_boost_kthread_setaffinity() The rcu_boost_kthread_setaffinity() function is invoked at rcutree_online_cpu() and rcutree_offline_cpu() time, early in the online timeline and late in the offline timeline, respectively. It is also invoked from rcutree_dead_cpu(), however, in the absence of userspace manipulations (for which userspace must take responsibility), this call is redundant with that from rcutree_offline_cpu(). This redundancy can be demonstrated by printing out the relevant cpumasks This commit therefore removes the call to rcu_boost_kthread_setaffinity() from rcutree_dead_cpu(). Signed-off-by: Zqiang <qiang1.zhang@intel.com> Signed-off-by: Paul E. McKenney <paulmck@kernel.org> diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index c3255d27286c4..a6181b76fd5ab 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -4165,15 +4165,10 @@ static void rcu_cleanup_dead_rnp(struct rcu_node *rnp_leaf) */ int rcutree_dead_cpu(unsigned int cpu) { - struct rcu_data *rdp = per_cpu_ptr(&rcu_data, cpu); - struct rcu_node *rnp = rdp->mynode; /* Outgoing CPU's rdp & rnp. */ - if (!IS_ENABLED(CONFIG_HOTPLUG_CPU)) return 0; WRITE_ONCE(rcu_state.n_online_cpus, rcu_state.n_online_cpus - 1); - /* Adjust any no-longer-needed kthreads. */ - rcu_boost_kthread_setaffinity(rnp, -1); // Stop-machine done, so allow nohz_full to disable tick. tick_dep_clear(TICK_DEP_BIT_RCU); return 0;
On Wed, Dec 21, 2022 at 11:26:22AM -0800, Paul E. McKenney wrote: > On Sat, Dec 17, 2022 at 01:02:03PM +0000, Zhang, Qiang1 wrote: > commit 5815245b56229198d5f5d0c48c26d3c0c53ee222 > Author: Zqiang <qiang1.zhang@intel.com> > Date: Wed Dec 21 11:15:43 2022 -0800 > > rcu: Remove redundant call to rcu_boost_kthread_setaffinity() > > The rcu_boost_kthread_setaffinity() function is invoked at > rcutree_online_cpu() and rcutree_offline_cpu() time, early in the online > timeline and late in the offline timeline, respectively. It is also > invoked from rcutree_dead_cpu(), however, in the absence of userspace > manipulations (for which userspace must take responsibility), this call > is redundant with that from rcutree_offline_cpu(). This redundancy can > be demonstrated by printing out the relevant cpumasks > > This commit therefore removes the call to rcu_boost_kthread_setaffinity() > from rcutree_dead_cpu(). > > Signed-off-by: Zqiang <qiang1.zhang@intel.com> > Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Reviewed-by: Frederic Weisbecker <frederic@kernel.org> Thanks! > > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c > index c3255d27286c4..a6181b76fd5ab 100644 > --- a/kernel/rcu/tree.c > +++ b/kernel/rcu/tree.c > @@ -4165,15 +4165,10 @@ static void rcu_cleanup_dead_rnp(struct rcu_node *rnp_leaf) > */ > int rcutree_dead_cpu(unsigned int cpu) > { > - struct rcu_data *rdp = per_cpu_ptr(&rcu_data, cpu); > - struct rcu_node *rnp = rdp->mynode; /* Outgoing CPU's rdp & rnp. */ > - > if (!IS_ENABLED(CONFIG_HOTPLUG_CPU)) > return 0; > > WRITE_ONCE(rcu_state.n_online_cpus, rcu_state.n_online_cpus - 1); > - /* Adjust any no-longer-needed kthreads. */ > - rcu_boost_kthread_setaffinity(rnp, -1); > // Stop-machine done, so allow nohz_full to disable tick. > tick_dep_clear(TICK_DEP_BIT_RCU); > return 0;
On Thu, Jan 12, 2023 at 04:07:07PM +0100, Frederic Weisbecker wrote: > On Wed, Dec 21, 2022 at 11:26:22AM -0800, Paul E. McKenney wrote: > > On Sat, Dec 17, 2022 at 01:02:03PM +0000, Zhang, Qiang1 wrote: > > commit 5815245b56229198d5f5d0c48c26d3c0c53ee222 > > Author: Zqiang <qiang1.zhang@intel.com> > > Date: Wed Dec 21 11:15:43 2022 -0800 > > > > rcu: Remove redundant call to rcu_boost_kthread_setaffinity() > > > > The rcu_boost_kthread_setaffinity() function is invoked at > > rcutree_online_cpu() and rcutree_offline_cpu() time, early in the online > > timeline and late in the offline timeline, respectively. It is also > > invoked from rcutree_dead_cpu(), however, in the absence of userspace > > manipulations (for which userspace must take responsibility), this call > > is redundant with that from rcutree_offline_cpu(). This redundancy can > > be demonstrated by printing out the relevant cpumasks > > > > This commit therefore removes the call to rcu_boost_kthread_setaffinity() > > from rcutree_dead_cpu(). > > > > Signed-off-by: Zqiang <qiang1.zhang@intel.com> > > Signed-off-by: Paul E. McKenney <paulmck@kernel.org> > > Reviewed-by: Frederic Weisbecker <frederic@kernel.org> Thank you! I will apply this on my next rebase. Thanx, Paul > Thanks! > > > > > > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c > > index c3255d27286c4..a6181b76fd5ab 100644 > > --- a/kernel/rcu/tree.c > > +++ b/kernel/rcu/tree.c > > @@ -4165,15 +4165,10 @@ static void rcu_cleanup_dead_rnp(struct rcu_node *rnp_leaf) > > */ > > int rcutree_dead_cpu(unsigned int cpu) > > { > > - struct rcu_data *rdp = per_cpu_ptr(&rcu_data, cpu); > > - struct rcu_node *rnp = rdp->mynode; /* Outgoing CPU's rdp & rnp. */ > > - > > if (!IS_ENABLED(CONFIG_HOTPLUG_CPU)) > > return 0; > > > > WRITE_ONCE(rcu_state.n_online_cpus, rcu_state.n_online_cpus - 1); > > - /* Adjust any no-longer-needed kthreads. */ > > - rcu_boost_kthread_setaffinity(rnp, -1); > > // Stop-machine done, so allow nohz_full to disable tick. > > tick_dep_clear(TICK_DEP_BIT_RCU); > > return 0;
diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index 65f3dd2fd3ae..20de83ed0c7e 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -4122,15 +4122,10 @@ static void rcu_cleanup_dead_rnp(struct rcu_node *rnp_leaf) */ int rcutree_dead_cpu(unsigned int cpu) { - struct rcu_data *rdp = per_cpu_ptr(&rcu_data, cpu); - struct rcu_node *rnp = rdp->mynode; /* Outgoing CPU's rdp & rnp. */ - if (!IS_ENABLED(CONFIG_HOTPLUG_CPU)) return 0; WRITE_ONCE(rcu_state.n_online_cpus, rcu_state.n_online_cpus - 1); - /* Adjust any no-longer-needed kthreads. */ - rcu_boost_kthread_setaffinity(rnp, -1); // Stop-machine done, so allow nohz_full to disable tick. tick_dep_clear(TICK_DEP_BIT_RCU); return 0;