Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1539197 > unrolled thread
| Started by | Boqun Feng <boqun.feng@gmail.com> |
|---|---|
| First post | 2016-12-09 09:50 +0100 |
| Last post | 2016-12-11 01:10 +0100 |
| Articles | 8 — 2 participants |
Back to article view | Back to linux.kernel
[RFC 0/5] rcu: Introduce leaf_node_for_each_mask_possible_cpu() and its friend Boqun Feng <boqun.feng@gmail.com> - 2016-12-09 09:50 +0100
[RFC 5/5] rcu: Use leaf_node_for_each_mask_*() for leaf node online CPU iteration Boqun Feng <boqun.feng@gmail.com> - 2016-12-09 10:00 +0100
Re: [RFC 0/5] rcu: Introduce leaf_node_for_each_mask_possible_cpu() and its friend "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-12-10 00:50 +0100
Re: [RFC 0/5] rcu: Introduce leaf_node_for_each_mask_possible_cpu() and its friend Boqun Feng <boqun.feng@gmail.com> - 2016-12-10 01:50 +0100
Re: [RFC 0/5] rcu: Introduce leaf_node_for_each_mask_possible_cpu() and its friend "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-12-10 05:30 +0100
Re: [RFC 0/5] rcu: Introduce leaf_node_for_each_mask_possible_cpu() and its friend Boqun Feng <boqun.feng@gmail.com> - 2016-12-10 14:40 +0100
Re: [RFC 0/5] rcu: Introduce leaf_node_for_each_mask_possible_cpu() and its friend "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2016-12-10 18:40 +0100
Re: [RFC 0/5] rcu: Introduce leaf_node_for_each_mask_possible_cpu() and its friend Boqun Feng <boqun.feng@gmail.com> - 2016-12-11 01:10 +0100
| From | Boqun Feng <boqun.feng@gmail.com> |
|---|---|
| Date | 2016-12-09 09:50 +0100 |
| Subject | [RFC 0/5] rcu: Introduce leaf_node_for_each_mask_possible_cpu() and its friend |
| Message-ID | <sMp2p-12O-13@gated-at.bofh.it> |
Hi Paul, While reading the discussion at: https://marc.info/?l=linux-kernel&m=148044253400769 I figured we might use this fact to save some extra checks in RCU core code, currently we iterate over all the possible CPUs on a leaf node, check whether they were masked in a certain mask and do something. However, given the fact that the masks on a leaf node should always be sparse than the corresponding part of cpu_possible_mask, we'd better iterate over all bits in a mask and check whether the corresponding CPU is possible or not. So I made this RFC, I did a simple build/boot/rcutorture test on my box with SMP=4, nothing bad happens. Currently I'm waiting for the 0day and trying to test this one a bigger system, in the meanwhile, looking forwards to any comment and suggestion. So thoughts? Regards, Boqun
[toc] | [next] | [standalone]
| From | Boqun Feng <boqun.feng@gmail.com> |
|---|---|
| Date | 2016-12-09 10:00 +0100 |
| Subject | [RFC 5/5] rcu: Use leaf_node_for_each_mask_*() for leaf node online CPU iteration |
| Message-ID | <sMpc6-16k-23@gated-at.bofh.it> |
| In reply to | #1539197 |
Though mostly identical, ->qsmaskinit(A.K.A rcu_rnp_online_cpus) is sometimes more sparse than the corresponding part of cpu_possible_mask for an RCU leaf node. So we use leaf_node_for_each_mask_possible_cpu() in rcu_boost_kthread_setaffinity() instead to save some extra checks. Signed-off-by: Boqun Feng <boqun.feng@gmail.com> --- kernel/rcu/tree_plugin.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h index 69c6eb27c37f..c954c2a7a9ba 100644 --- a/kernel/rcu/tree_plugin.h +++ b/kernel/rcu/tree_plugin.h @@ -1170,15 +1170,17 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu) unsigned long mask = rcu_rnp_online_cpus(rnp); cpumask_var_t cm; int cpu; + unsigned long bit; if (!t) return; if (!zalloc_cpumask_var(&cm, GFP_KERNEL)) return; - for_each_leaf_node_possible_cpu(rnp, cpu) - if ((mask & leaf_node_cpu_bit(rnp, cpu)) && - cpu != outgoingcpu) + + leaf_node_for_each_mask_possible_cpu(rnp, mask, bit, cpu) + if (cpu != outgoingcpu) cpumask_set_cpu(cpu, cm); + if (cpumask_weight(cm) == 0) cpumask_setall(cm); set_cpus_allowed_ptr(t, cm); -- 2.10.2
[toc] | [prev] | [next] | [standalone]
| From | "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> |
|---|---|
| Date | 2016-12-10 00:50 +0100 |
| Subject | Re: [RFC 0/5] rcu: Introduce leaf_node_for_each_mask_possible_cpu() and its friend |
| Message-ID | <sMD5n-17m-5@gated-at.bofh.it> |
| In reply to | #1539197 |
On Fri, Dec 09, 2016 at 04:48:22PM +0800, Boqun Feng wrote: > Hi Paul, > > While reading the discussion at: > > https://marc.info/?l=linux-kernel&m=148044253400769 This discussion was for stalls specifically, rather than for routine scans of the bitmasks. But it does look to save some code, so worth looking into. > I figured we might use this fact to save some extra checks in RCU core code, > currently we iterate over all the possible CPUs on a leaf node, check whether > they were masked in a certain mask and do something. However, given the fact > that the masks on a leaf node should always be sparse than the corresponding > part of cpu_possible_mask, we'd better iterate over all bits in a mask and > check whether the corresponding CPU is possible or not. > > So I made this RFC, I did a simple build/boot/rcutorture test on my box with > SMP=4, nothing bad happens. Currently I'm waiting for the 0day and trying to > test this one a bigger system, in the meanwhile, looking forwards to any > comment and suggestion. > > So thoughts? By analogy with for_each_cpu() and for_each_possible_cpu(), the name should instead be for_each_leaf_node_cpu(), the tradition of excessively long names in RCU notwithstanding. ;-) Thanx, Paul
[toc] | [prev] | [next] | [standalone]
| From | Boqun Feng <boqun.feng@gmail.com> |
|---|---|
| Date | 2016-12-10 01:50 +0100 |
| Subject | Re: [RFC 0/5] rcu: Introduce leaf_node_for_each_mask_possible_cpu() and its friend |
| Message-ID | <sME1r-1Gv-1@gated-at.bofh.it> |
| In reply to | #1539737 |
[Multipart message — attachments visible in raw view] — view raw
On Fri, Dec 09, 2016 at 03:49:45PM -0800, Paul E. McKenney wrote: > On Fri, Dec 09, 2016 at 04:48:22PM +0800, Boqun Feng wrote: > > Hi Paul, > > > > While reading the discussion at: > > > > https://marc.info/?l=linux-kernel&m=148044253400769 > > This discussion was for stalls specifically, rather than for routine > scans of the bitmasks. > > But it does look to save some code, so worth looking into. > > > I figured we might use this fact to save some extra checks in RCU core code, > > currently we iterate over all the possible CPUs on a leaf node, check whether > > they were masked in a certain mask and do something. However, given the fact > > that the masks on a leaf node should always be sparse than the corresponding > > part of cpu_possible_mask, we'd better iterate over all bits in a mask and > > check whether the corresponding CPU is possible or not. > > > > So I made this RFC, I did a simple build/boot/rcutorture test on my box with > > SMP=4, nothing bad happens. Currently I'm waiting for the 0day and trying to > > test this one a bigger system, in the meanwhile, looking forwards to any > > comment and suggestion. > > > > So thoughts? > > By analogy with for_each_cpu() and for_each_possible_cpu(), the name > should instead be for_each_leaf_node_cpu(), the tradition of excessively > long names in RCU notwithstanding. ;-) > Make sense ;-) I think it's more appropriate to call it for_each_leaf_node_mask_cpu(), because we don't iterate all cpus of a leaf node. The word "possible" could be dropped because obviously we won't iterate over "impossible" cpus in a leaf node ;-) Will modify that in next version. Regards, Boqun > Thanx, Paul >
[toc] | [prev] | [next] | [standalone]
| From | "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> |
|---|---|
| Date | 2016-12-10 05:30 +0100 |
| Subject | Re: [RFC 0/5] rcu: Introduce leaf_node_for_each_mask_possible_cpu() and its friend |
| Message-ID | <sMHsl-3Pm-3@gated-at.bofh.it> |
| In reply to | #1539749 |
On Sat, Dec 10, 2016 at 08:45:38AM +0800, Boqun Feng wrote: > On Fri, Dec 09, 2016 at 03:49:45PM -0800, Paul E. McKenney wrote: > > On Fri, Dec 09, 2016 at 04:48:22PM +0800, Boqun Feng wrote: > > > Hi Paul, > > > > > > While reading the discussion at: > > > > > > https://marc.info/?l=linux-kernel&m=148044253400769 > > > > This discussion was for stalls specifically, rather than for routine > > scans of the bitmasks. > > > > But it does look to save some code, so worth looking into. > > > > > I figured we might use this fact to save some extra checks in RCU core code, > > > currently we iterate over all the possible CPUs on a leaf node, check whether > > > they were masked in a certain mask and do something. However, given the fact > > > that the masks on a leaf node should always be sparse than the corresponding > > > part of cpu_possible_mask, we'd better iterate over all bits in a mask and > > > check whether the corresponding CPU is possible or not. > > > > > > So I made this RFC, I did a simple build/boot/rcutorture test on my box with > > > SMP=4, nothing bad happens. Currently I'm waiting for the 0day and trying to > > > test this one a bigger system, in the meanwhile, looking forwards to any > > > comment and suggestion. > > > > > > So thoughts? > > > > By analogy with for_each_cpu() and for_each_possible_cpu(), the name > > should instead be for_each_leaf_node_cpu(), the tradition of excessively > > long names in RCU notwithstanding. ;-) > > > > Make sense ;-) > > I think it's more appropriate to call it for_each_leaf_node_mask_cpu(), > because we don't iterate all cpus of a leaf node. The word "possible" > could be dropped because obviously we won't iterate over "impossible" > cpus in a leaf node ;-) C'mon, Boqun! The for_each_leaf_node_cpu() is not only consistent with the for_each_cpu() family, it is shorter! ;-) Thanx, Paul > Will modify that in next version. > > Regards, > Boqun > > > Thanx, Paul > >
[toc] | [prev] | [next] | [standalone]
| From | Boqun Feng <boqun.feng@gmail.com> |
|---|---|
| Date | 2016-12-10 14:40 +0100 |
| Subject | Re: [RFC 0/5] rcu: Introduce leaf_node_for_each_mask_possible_cpu() and its friend |
| Message-ID | <sMQ2C-2RK-15@gated-at.bofh.it> |
| In reply to | #1539769 |
[Multipart message — attachments visible in raw view] — view raw
On Fri, Dec 09, 2016 at 08:28:05PM -0800, Paul E. McKenney wrote: > On Sat, Dec 10, 2016 at 08:45:38AM +0800, Boqun Feng wrote: > > On Fri, Dec 09, 2016 at 03:49:45PM -0800, Paul E. McKenney wrote: > > > On Fri, Dec 09, 2016 at 04:48:22PM +0800, Boqun Feng wrote: > > > > Hi Paul, > > > > > > > > While reading the discussion at: > > > > > > > > https://marc.info/?l=linux-kernel&m=148044253400769 > > > > > > This discussion was for stalls specifically, rather than for routine > > > scans of the bitmasks. > > > > > > But it does look to save some code, so worth looking into. > > > > > > > I figured we might use this fact to save some extra checks in RCU core code, > > > > currently we iterate over all the possible CPUs on a leaf node, check whether > > > > they were masked in a certain mask and do something. However, given the fact > > > > that the masks on a leaf node should always be sparse than the corresponding > > > > part of cpu_possible_mask, we'd better iterate over all bits in a mask and > > > > check whether the corresponding CPU is possible or not. > > > > > > > > So I made this RFC, I did a simple build/boot/rcutorture test on my box with > > > > SMP=4, nothing bad happens. Currently I'm waiting for the 0day and trying to > > > > test this one a bigger system, in the meanwhile, looking forwards to any > > > > comment and suggestion. > > > > > > > > So thoughts? > > > > > > By analogy with for_each_cpu() and for_each_possible_cpu(), the name > > > should instead be for_each_leaf_node_cpu(), the tradition of excessively > > > long names in RCU notwithstanding. ;-) > > > > > > > Make sense ;-) > > > > I think it's more appropriate to call it for_each_leaf_node_mask_cpu(), > > because we don't iterate all cpus of a leaf node. The word "possible" > > could be dropped because obviously we won't iterate over "impossible" > > cpus in a leaf node ;-) > > C'mon, Boqun! The for_each_leaf_node_cpu() is not only consistent > with the for_each_cpu() family, it is shorter! ;-) > Sure ;-) But for_each_leaf_node_cpu() seems like an operation that iterates over _all_ cpus in a leaf node, but I actually implement it as an operation that iterates only the _masked_ cpus. So I feel like word "mask" better be added in the name. If we call it for_each_leaf_node_cpu(rnp, mask,...), we will rely on the hope that readers could figure it out what the primitive actually does by the indication of the parameter @mask. I like shorter names too, but not sure whether putting "mask" in the name is better. After all, naming is one of the most difficult challenges in programming ;-) Regards, Boqun > Thanx, Paul > > > Will modify that in next version. > > > > Regards, > > Boqun > > > > > Thanx, Paul > > > > >
[toc] | [prev] | [next] | [standalone]
| From | "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> |
|---|---|
| Date | 2016-12-10 18:40 +0100 |
| Subject | Re: [RFC 0/5] rcu: Introduce leaf_node_for_each_mask_possible_cpu() and its friend |
| Message-ID | <sMTMR-580-17@gated-at.bofh.it> |
| In reply to | #1539833 |
On Sat, Dec 10, 2016 at 09:36:29PM +0800, Boqun Feng wrote: > On Fri, Dec 09, 2016 at 08:28:05PM -0800, Paul E. McKenney wrote: > > On Sat, Dec 10, 2016 at 08:45:38AM +0800, Boqun Feng wrote: > > > On Fri, Dec 09, 2016 at 03:49:45PM -0800, Paul E. McKenney wrote: > > > > On Fri, Dec 09, 2016 at 04:48:22PM +0800, Boqun Feng wrote: > > > > > Hi Paul, > > > > > > > > > > While reading the discussion at: > > > > > > > > > > https://marc.info/?l=linux-kernel&m=148044253400769 > > > > > > > > This discussion was for stalls specifically, rather than for routine > > > > scans of the bitmasks. > > > > > > > > But it does look to save some code, so worth looking into. > > > > > > > > > I figured we might use this fact to save some extra checks in RCU core code, > > > > > currently we iterate over all the possible CPUs on a leaf node, check whether > > > > > they were masked in a certain mask and do something. However, given the fact > > > > > that the masks on a leaf node should always be sparse than the corresponding > > > > > part of cpu_possible_mask, we'd better iterate over all bits in a mask and > > > > > check whether the corresponding CPU is possible or not. > > > > > > > > > > So I made this RFC, I did a simple build/boot/rcutorture test on my box with > > > > > SMP=4, nothing bad happens. Currently I'm waiting for the 0day and trying to > > > > > test this one a bigger system, in the meanwhile, looking forwards to any > > > > > comment and suggestion. > > > > > > > > > > So thoughts? > > > > > > > > By analogy with for_each_cpu() and for_each_possible_cpu(), the name > > > > should instead be for_each_leaf_node_cpu(), the tradition of excessively > > > > long names in RCU notwithstanding. ;-) > > > > > > > > > > Make sense ;-) > > > > > > I think it's more appropriate to call it for_each_leaf_node_mask_cpu(), > > > because we don't iterate all cpus of a leaf node. The word "possible" > > > could be dropped because obviously we won't iterate over "impossible" > > > cpus in a leaf node ;-) > > > > C'mon, Boqun! The for_each_leaf_node_cpu() is not only consistent > > with the for_each_cpu() family, it is shorter! ;-) > > Sure ;-) But for_each_leaf_node_cpu() seems like an operation that > iterates over _all_ cpus in a leaf node, but I actually implement it as > an operation that iterates only the _masked_ cpus. So I feel like word > "mask" better be added in the name. Although that is a fair point, the same can be said of for_each_cpu(). Which people seem to be able to use without undue pain. > If we call it for_each_leaf_node_cpu(rnp, mask,...), we will rely on the > hope that readers could figure it out what the primitive actually does > by the indication of the parameter @mask. > > I like shorter names too, but not sure whether putting "mask" in the > name is better. After all, naming is one of the most difficult > challenges in programming ;-) The two most difficult challenges in programming are the last two hard things that the person speaking worked on. ;-) Consistency is more important than the stand-alone understanding of this particular name. You can always add a comment pointing out that it follows for_each_cpu(). Thanx, Paul > Regards, > Boqun > > > Thanx, Paul > > > > > Will modify that in next version. > > > > > > Regards, > > > Boqun > > > > > > > Thanx, Paul > > > > > > > >
[toc] | [prev] | [next] | [standalone]
| From | Boqun Feng <boqun.feng@gmail.com> |
|---|---|
| Date | 2016-12-11 01:10 +0100 |
| Subject | Re: [RFC 0/5] rcu: Introduce leaf_node_for_each_mask_possible_cpu() and its friend |
| Message-ID | <sMZSh-ui-17@gated-at.bofh.it> |
| In reply to | #1539867 |
[Multipart message — attachments visible in raw view] — view raw
On Sat, Dec 10, 2016 at 09:38:54AM -0800, Paul E. McKenney wrote: > On Sat, Dec 10, 2016 at 09:36:29PM +0800, Boqun Feng wrote: > > On Fri, Dec 09, 2016 at 08:28:05PM -0800, Paul E. McKenney wrote: > > > On Sat, Dec 10, 2016 at 08:45:38AM +0800, Boqun Feng wrote: > > > > On Fri, Dec 09, 2016 at 03:49:45PM -0800, Paul E. McKenney wrote: > > > > > On Fri, Dec 09, 2016 at 04:48:22PM +0800, Boqun Feng wrote: > > > > > > Hi Paul, > > > > > > > > > > > > While reading the discussion at: > > > > > > > > > > > > https://marc.info/?l=linux-kernel&m=148044253400769 > > > > > > > > > > This discussion was for stalls specifically, rather than for routine > > > > > scans of the bitmasks. > > > > > > > > > > But it does look to save some code, so worth looking into. > > > > > > > > > > > I figured we might use this fact to save some extra checks in RCU core code, > > > > > > currently we iterate over all the possible CPUs on a leaf node, check whether > > > > > > they were masked in a certain mask and do something. However, given the fact > > > > > > that the masks on a leaf node should always be sparse than the corresponding > > > > > > part of cpu_possible_mask, we'd better iterate over all bits in a mask and > > > > > > check whether the corresponding CPU is possible or not. > > > > > > > > > > > > So I made this RFC, I did a simple build/boot/rcutorture test on my box with > > > > > > SMP=4, nothing bad happens. Currently I'm waiting for the 0day and trying to > > > > > > test this one a bigger system, in the meanwhile, looking forwards to any > > > > > > comment and suggestion. > > > > > > > > > > > > So thoughts? > > > > > > > > > > By analogy with for_each_cpu() and for_each_possible_cpu(), the name > > > > > should instead be for_each_leaf_node_cpu(), the tradition of excessively > > > > > long names in RCU notwithstanding. ;-) > > > > > > > > > > > > > Make sense ;-) > > > > > > > > I think it's more appropriate to call it for_each_leaf_node_mask_cpu(), > > > > because we don't iterate all cpus of a leaf node. The word "possible" > > > > could be dropped because obviously we won't iterate over "impossible" > > > > cpus in a leaf node ;-) > > > > > > C'mon, Boqun! The for_each_leaf_node_cpu() is not only consistent > > > with the for_each_cpu() family, it is shorter! ;-) > > > > Sure ;-) But for_each_leaf_node_cpu() seems like an operation that > > iterates over _all_ cpus in a leaf node, but I actually implement it as > > an operation that iterates only the _masked_ cpus. So I feel like word > > "mask" better be added in the name. > > Although that is a fair point, the same can be said of for_each_cpu(). > Which people seem to be able to use without undue pain. > > > If we call it for_each_leaf_node_cpu(rnp, mask,...), we will rely on the > > hope that readers could figure it out what the primitive actually does > > by the indication of the parameter @mask. > > > > I like shorter names too, but not sure whether putting "mask" in the > > name is better. After all, naming is one of the most difficult > > challenges in programming ;-) > > The two most difficult challenges in programming are the last two hard > things that the person speaking worked on. ;-) > ;-) > Consistency is more important than the stand-alone understanding of > this particular name. You can always add a comment pointing out that > it follows for_each_cpu(). > Fair enough. Let us name it for_each_leaf_node_cpu() ;-) Regards, Boqun > Thanx, Paul > > > Regards, > > Boqun > > > > > Thanx, Paul > > > > > > > Will modify that in next version. > > > > > > > > Regards, > > > > Boqun > > > > > > > > > Thanx, Paul > > > > > > > > > > > > >
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web