* Re: [PATCH 7/9] lib/cpumask: add num_{possible,present,active}_cpus_{eq,gt,le}
[not found] <YaMME60Jfiz5BeJF@qmqm.qmqm.pl>
@ 2021-11-28 6:34 ` Yury Norov
0 siblings, 0 replies; 7+ messages in thread
From: Yury Norov @ 2021-11-28 6:34 UTC (permalink / raw)
To: Michał Mirosław
Cc: linux-kernel, James E.J. Bottomley, Martin K. Petersen,
Paul E. McKenney, Rafael J. Wysocki, Alexander Shishkin,
Alexey Klimov, Amitkumar Karwar, Andi Kleen, Andrew Lunn,
Andrew Morton, Andy Gross, Andy Lutomirski, Andy Shevchenko,
Anup Patel, Ard Biesheuvel, Arnaldo Carvalho de Melo,
Arnd Bergmann, Borislav Petkov, Catalin Marinas,
Christoph Hellwig, Christoph Lameter, Daniel Vetter, Dave Hansen,
David Airlie, David Laight, Dennis Zhou, Dinh Nguyen,
Geetha sowjanya, Geert Uytterhoeven, Greg Kroah-Hartman, Guo Ren,
Hans de Goede, Heiko Carstens, Ian Rogers, Ingo Molnar,
Jakub Kicinski, Jason Wessel, Jens Axboe, Jiri Olsa,
Jonathan Cameron, Juri Lelli, Kalle Valo, Kees Cook,
Krzysztof Kozlowski, Lee Jones, Marc Zyngier, Marcin Wojtas,
Mark Gross, Mark Rutland, Matti Vaittinen, Mauro Carvalho Chehab,
Mel Gorman, Michael Ellerman, Mike Marciniszyn, Nicholas Piggin,
Palmer Dabbelt, Peter Zijlstra, Petr Mladek, Randy Dunlap,
Rasmus Villemoes, Roy Pledge, Russell King, Saeed Mahameed,
Sagi Grimberg, Sergey Senozhatsky, Solomon Peachy, Stephen Boyd,
Stephen Rothwell, Steven Rostedt, Subbaraya Sundeep, Sudeep Holla,
Sunil Goutham, Tariq Toukan, Tejun Heo, Thomas Bogendoerfer,
Thomas Gleixner, Ulf Hansson, Vincent Guittot, Vineet Gupta,
Viresh Kumar, Vivien Didelot, Vlastimil Babka, Will Deacon,
bcm-kernel-feedback-list, kvm, linux-alpha, linux-arm-kernel,
linux-crypto, linux-csky, linux-ia64, linux-mips, linux-mm,
linux-perf-users, linux-riscv, linux-s390, linux-snps-arc,
linuxppc-dev
(restore CC list)
On Sun, Nov 28, 2021 at 05:56:51AM +0100, Michał Mirosław wrote:
> On Sat, Nov 27, 2021 at 07:57:02PM -0800, Yury Norov wrote:
> > Add num_{possible,present,active}_cpus_{eq,gt,le} and replace num_*_cpus()
> > with one of new functions where appropriate. This allows num_*_cpus_*()
> > to return earlier depending on the condition.
> [...]
> > @@ -3193,7 +3193,7 @@ int __init pcpu_page_first_chunk(size_t reserved_size,
> >
> > /* allocate pages */
> > j = 0;
> > - for (unit = 0; unit < num_possible_cpus(); unit++) {
> > + for (unit = 0; num_possible_cpus_gt(unit); unit++) {
>
> This looks dubious.
Only this?
> The old version I could hope the compiler would call
> num_possible_cpus() only once if it's marked const or pure, but the
> alternative is going to count the bits every time making this a guaranteed
> O(n^2) even though the bitmap doesn't change.
num_possible_cpus() is not const neither pure. This is O(n^2) before and after.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 7/9] lib/cpumask: add num_{possible,present,active}_cpus_{eq,gt,le}
[not found] ` <20211128035704.270739-8-yury.norov@gmail.com>
@ 2021-11-28 17:07 ` Joe Perches
2021-11-28 17:43 ` Yury Norov
0 siblings, 1 reply; 7+ messages in thread
From: Joe Perches @ 2021-11-28 17:07 UTC (permalink / raw)
To: Yury Norov, linux-kernel, James E.J. Bottomley,
Martin K. Petersen, Paul E. McKenney, Rafael J. Wysocki,
Alexander Shishkin, Alexey Klimov, Amitkumar Karwar, Andi Kleen,
Andrew Lunn, Andrew Morton, Andy Gross, Andy Lutomirski,
Andy Shevchenko, Anup Patel, Ard Biesheuvel,
Arnaldo Carvalho de Melo, Arnd Bergmann, Borislav Petkov,
Catalin Marinas, Christoph Hellwig, Christoph Lameter,
Daniel Vetter, Dave Hansen, David Airlie, David Laight,
Dennis Zhou, Dinh Nguyen, Geetha sowjanya, Geert Uytterhoeven,
Greg Kroah-Hartman, Guo Ren, Hans de Goede, Heiko Carstens,
Ian Rogers, Ingo Molnar, Jakub Kicinski, Jason Wessel, Jens Axboe,
Jiri Olsa, Jonathan Cameron, Juri Lelli, Kalle Valo, Kees Cook,
Krzysztof Kozlowski, Lee Jones, Marc Zyngier, Marcin Wojtas,
Mark Gross, Mark Rutland, Matti Vaittinen, Mauro Carvalho Chehab,
Mel Gorman, Michael Ellerman, Mike Marciniszyn, Nicholas Piggin,
Palmer Dabbelt, Peter Zijlstra, Petr Mladek, Randy Dunlap,
Rasmus Villemoes, Roy Pledge, Russell King, Saeed Mahameed,
Sagi Grimberg, Sergey Senozhatsky, Solomon Peachy, Stephen Boyd,
Stephen Rothwell, Steven Rostedt, Subbaraya Sundeep, Sudeep Holla,
Sunil Goutham, Tariq Toukan, Tejun Heo, Thomas Bogendoerfer,
Thomas Gleixner, Ulf Hansson, Vincent Guittot, Vineet Gupta,
Viresh Kumar, Vivien Didelot, Vlastimil Babka, Will Deacon,
bcm-kernel-feedback-list, kvm, linux-alpha, linux-arm-kernel,
linux-crypto, linux-csky, linux-ia64, linux-mips, linux-mm,
linux-perf-users, linux-riscv, linux-s390, linux-snps-arc,
linuxppc-dev
On Sat, 2021-11-27 at 19:57 -0800, Yury Norov wrote:
> Add num_{possible,present,active}_cpus_{eq,gt,le} and replace num_*_cpus()
> with one of new functions where appropriate. This allows num_*_cpus_*()
> to return earlier depending on the condition.
[]
> diff --git a/arch/arc/kernel/smp.c b/arch/arc/kernel/smp.c
[]
> @@ -103,7 +103,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
> * if platform didn't set the present map already, do it now
> * boot cpu is set to present already by init/main.c
> */
> - if (num_present_cpus() <= 1)
> + if (num_present_cpus_le(2))
> init_cpu_present(cpu_possible_mask);
? is this supposed to be 2 or 1
> diff --git a/drivers/cpufreq/pcc-cpufreq.c b/drivers/cpufreq/pcc-cpufreq.c
[]
> @@ -593,7 +593,7 @@ static int __init pcc_cpufreq_init(void)
> return ret;
> }
>
> - if (num_present_cpus() > 4) {
> + if (num_present_cpus_gt(4)) {
> pcc_cpufreq_driver.flags |= CPUFREQ_NO_AUTO_DYNAMIC_SWITCHING;
> pr_err("%s: Too many CPUs, dynamic performance scaling disabled\n",
> __func__);
It looks as if the present variants should be using the same values
so the _le test above with 1 changed to 2 looks odd.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 7/9] lib/cpumask: add num_{possible,present,active}_cpus_{eq,gt,le}
2021-11-28 17:07 ` [PATCH 7/9] lib/cpumask: add num_{possible,present,active}_cpus_{eq,gt,le} Joe Perches
@ 2021-11-28 17:43 ` Yury Norov
2021-11-28 17:54 ` Dennis Zhou
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Yury Norov @ 2021-11-28 17:43 UTC (permalink / raw)
To: Joe Perches
Cc: linux-kernel, James E.J. Bottomley, Martin K. Petersen,
Paul E. McKenney, Rafael J. Wysocki, Alexander Shishkin,
Alexey Klimov, Amitkumar Karwar, Andi Kleen, Andrew Lunn,
Andrew Morton, Andy Gross, Andy Lutomirski, Andy Shevchenko,
Anup Patel, Ard Biesheuvel, Arnaldo Carvalho de Melo,
Arnd Bergmann, Borislav Petkov, Catalin Marinas,
Christoph Hellwig, Christoph Lameter, Daniel Vetter, Dave Hansen,
David Airlie, David Laight, Dennis Zhou, Dinh Nguyen,
Geetha sowjanya, Geert Uytterhoeven, Greg Kroah-Hartman, Guo Ren,
Hans de Goede, Heiko Carstens, Ian Rogers, Ingo Molnar,
Jakub Kicinski, Jason Wessel, Jens Axboe, Jiri Olsa,
Jonathan Cameron, Juri Lelli, Kalle Valo, Kees Cook,
Krzysztof Kozlowski, Lee Jones, Marc Zyngier, Marcin Wojtas,
Mark Gross, Mark Rutland, Matti Vaittinen, Mauro Carvalho Chehab,
Mel Gorman, Michael Ellerman, Mike Marciniszyn, Nicholas Piggin,
Palmer Dabbelt, Peter Zijlstra, Petr Mladek, Randy Dunlap,
Rasmus Villemoes, Roy Pledge, Russell King, Saeed Mahameed,
Sagi Grimberg, Sergey Senozhatsky, Solomon Peachy, Stephen Boyd,
Stephen Rothwell, Steven Rostedt, Subbaraya Sundeep, Sudeep Holla,
Sunil Goutham, Tariq Toukan, Tejun Heo, Thomas Bogendoerfer,
Thomas Gleixner, Ulf Hansson, Vincent Guittot, Vineet Gupta,
Viresh Kumar, Vivien Didelot, Vlastimil Babka, Will Deacon,
bcm-kernel-feedback-list, kvm, linux-alpha, linux-arm-kernel,
linux-crypto, linux-csky, linux-ia64, linux-mips, linux-mm,
linux-perf-users, linux-riscv, linux-s390, linux-snps-arc,
linuxppc-dev
On Sun, Nov 28, 2021 at 09:07:52AM -0800, Joe Perches wrote:
> On Sat, 2021-11-27 at 19:57 -0800, Yury Norov wrote:
> > Add num_{possible,present,active}_cpus_{eq,gt,le} and replace num_*_cpus()
> > with one of new functions where appropriate. This allows num_*_cpus_*()
> > to return earlier depending on the condition.
> []
> > diff --git a/arch/arc/kernel/smp.c b/arch/arc/kernel/smp.c
> []
> > @@ -103,7 +103,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
> > * if platform didn't set the present map already, do it now
> > * boot cpu is set to present already by init/main.c
> > */
> > - if (num_present_cpus() <= 1)
> > + if (num_present_cpus_le(2))
> > init_cpu_present(cpu_possible_mask);
>
> ? is this supposed to be 2 or 1
X <= 1 is the equivalent of X < 2.
> > diff --git a/drivers/cpufreq/pcc-cpufreq.c b/drivers/cpufreq/pcc-cpufreq.c
> []
> > @@ -593,7 +593,7 @@ static int __init pcc_cpufreq_init(void)
> > return ret;
> > }
> >
> > - if (num_present_cpus() > 4) {
> > + if (num_present_cpus_gt(4)) {
> > pcc_cpufreq_driver.flags |= CPUFREQ_NO_AUTO_DYNAMIC_SWITCHING;
> > pr_err("%s: Too many CPUs, dynamic performance scaling disabled\n",
> > __func__);
>
> It looks as if the present variants should be using the same values
> so the _le test above with 1 changed to 2 looks odd.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 7/9] lib/cpumask: add num_{possible,present,active}_cpus_{eq,gt,le}
2021-11-28 17:43 ` Yury Norov
@ 2021-11-28 17:54 ` Dennis Zhou
2021-11-28 18:47 ` Yury Norov
2021-11-28 17:56 ` Emil Renner Berthing
2021-11-28 17:57 ` Joe Perches
2 siblings, 1 reply; 7+ messages in thread
From: Dennis Zhou @ 2021-11-28 17:54 UTC (permalink / raw)
To: Yury Norov
Cc: Joe Perches, linux-kernel, James E.J. Bottomley,
Martin K. Petersen, Paul E. McKenney, Rafael J. Wysocki,
Alexander Shishkin, Alexey Klimov, Amitkumar Karwar, Andi Kleen,
Andrew Lunn, Andrew Morton, Andy Gross, Andy Lutomirski,
Andy Shevchenko, Anup Patel, Ard Biesheuvel,
Arnaldo Carvalho de Melo, Arnd Bergmann, Borislav Petkov,
Catalin Marinas, Christoph Hellwig, Christoph Lameter,
Daniel Vetter, Dave Hansen, David Airlie, David Laight,
Dennis Zhou, Dinh Nguyen, Geetha sowjanya, Geert Uytterhoeven,
Greg Kroah-Hartman, Guo Ren, Hans de Goede, Heiko Carstens,
Ian Rogers, Ingo Molnar, Jakub Kicinski, Jason Wessel, Jens Axboe,
Jiri Olsa, Jonathan Cameron, Juri Lelli, Kalle Valo, Kees Cook,
Krzysztof Kozlowski, Lee Jones, Marc Zyngier, Marcin Wojtas,
Mark Gross, Mark Rutland, Matti Vaittinen, Mauro Carvalho Chehab,
Mel Gorman, Michael Ellerman, Mike Marciniszyn, Nicholas Piggin,
Palmer Dabbelt, Peter Zijlstra, Petr Mladek, Randy Dunlap,
Rasmus Villemoes, Roy Pledge, Russell King, Saeed Mahameed,
Sagi Grimberg, Sergey Senozhatsky, Solomon Peachy, Stephen Boyd,
Stephen Rothwell, Steven Rostedt, Subbaraya Sundeep, Sudeep Holla,
Sunil Goutham, Tariq Toukan, Tejun Heo, Thomas Bogendoerfer,
Thomas Gleixner, Ulf Hansson, Vincent Guittot, Vineet Gupta,
Viresh Kumar, Vivien Didelot, Vlastimil Babka, Will Deacon,
bcm-kernel-feedback-list, kvm, linux-alpha, linux-arm-kernel,
linux-crypto, linux-csky, linux-ia64, linux-mips, linux-mm,
linux-perf-users, linux-riscv, linux-s390, linux-snps-arc,
linuxppc-dev
Hello,
On Sun, Nov 28, 2021 at 09:43:20AM -0800, Yury Norov wrote:
> On Sun, Nov 28, 2021 at 09:07:52AM -0800, Joe Perches wrote:
> > On Sat, 2021-11-27 at 19:57 -0800, Yury Norov wrote:
> > > Add num_{possible,present,active}_cpus_{eq,gt,le} and replace num_*_cpus()
> > > with one of new functions where appropriate. This allows num_*_cpus_*()
> > > to return earlier depending on the condition.
> > []
> > > diff --git a/arch/arc/kernel/smp.c b/arch/arc/kernel/smp.c
> > []
> > > @@ -103,7 +103,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
> > > * if platform didn't set the present map already, do it now
> > > * boot cpu is set to present already by init/main.c
> > > */
> > > - if (num_present_cpus() <= 1)
> > > + if (num_present_cpus_le(2))
> > > init_cpu_present(cpu_possible_mask);
> >
> > ? is this supposed to be 2 or 1
>
> X <= 1 is the equivalent of X < 2.
>
> > > diff --git a/drivers/cpufreq/pcc-cpufreq.c b/drivers/cpufreq/pcc-cpufreq.c
> > []
> > > @@ -593,7 +593,7 @@ static int __init pcc_cpufreq_init(void)
> > > return ret;
> > > }
> > >
> > > - if (num_present_cpus() > 4) {
> > > + if (num_present_cpus_gt(4)) {
> > > pcc_cpufreq_driver.flags |= CPUFREQ_NO_AUTO_DYNAMIC_SWITCHING;
> > > pr_err("%s: Too many CPUs, dynamic performance scaling disabled\n",
> > > __func__);
> >
> > It looks as if the present variants should be using the same values
> > so the _le test above with 1 changed to 2 looks odd.
>
I think the confusion comes from le meaning less than rather than lt.
Given the general convention of: lt (<), le (<=), eg (=), ge (>=),
gt (>), I'd consider renaming your le to lt.
Thanks,
Dennis
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 7/9] lib/cpumask: add num_{possible,present,active}_cpus_{eq,gt,le}
2021-11-28 17:43 ` Yury Norov
2021-11-28 17:54 ` Dennis Zhou
@ 2021-11-28 17:56 ` Emil Renner Berthing
2021-11-28 17:57 ` Joe Perches
2 siblings, 0 replies; 7+ messages in thread
From: Emil Renner Berthing @ 2021-11-28 17:56 UTC (permalink / raw)
To: Yury Norov
Cc: Joe Perches, Linux Kernel Mailing List, James E.J. Bottomley,
Martin K. Petersen, Paul E. McKenney, Rafael J. Wysocki,
Alexander Shishkin, Alexey Klimov, Amitkumar Karwar, Andi Kleen,
Andrew Lunn, Andrew Morton, Andy Gross, Andy Lutomirski,
Andy Shevchenko, Anup Patel, Ard Biesheuvel,
Arnaldo Carvalho de Melo, Arnd Bergmann, Borislav Petkov,
Catalin Marinas, Christoph Hellwig, Christoph Lameter,
Daniel Vetter, Dave Hansen, David Airlie, David Laight,
Dennis Zhou, Dinh Nguyen, Geetha sowjanya, Geert Uytterhoeven,
Greg Kroah-Hartman, Guo Ren, Hans de Goede, Heiko Carstens,
Ian Rogers, Ingo Molnar, Jakub Kicinski, Jason Wessel, Jens Axboe,
Jiri Olsa, Jonathan Cameron, Juri Lelli, Kalle Valo, Kees Cook,
Krzysztof Kozlowski, Lee Jones, Marc Zyngier, Marcin Wojtas,
Mark Gross, Mark Rutland, Matti Vaittinen, Mauro Carvalho Chehab,
Mel Gorman, Michael Ellerman, Mike Marciniszyn, Nicholas Piggin,
Palmer Dabbelt, Peter Zijlstra, Petr Mladek, Randy Dunlap,
Rasmus Villemoes, Roy Pledge, Russell King, Saeed Mahameed,
Sagi Grimberg, Sergey Senozhatsky, Solomon Peachy, Stephen Boyd,
Stephen Rothwell, Steven Rostedt, Subbaraya Sundeep, Sudeep Holla,
Sunil Goutham, Tariq Toukan, Tejun Heo, Thomas Bogendoerfer,
Thomas Gleixner, Ulf Hansson, Vincent Guittot, Vineet Gupta,
Viresh Kumar, Vivien Didelot, Vlastimil Babka, Will Deacon,
bcm-kernel-feedback-list, kvm, linux-alpha, linux-arm-kernel,
linux-crypto, linux-csky, linux-ia64, linux-mips, linux-mm,
linux-perf-users, linux-riscv, linux-s390, linux-snps-arc,
linuxppc-dev
On Sun, 28 Nov 2021 at 18:43, Yury Norov <yury.norov@gmail.com> wrote:
> On Sun, Nov 28, 2021 at 09:07:52AM -0800, Joe Perches wrote:
> > On Sat, 2021-11-27 at 19:57 -0800, Yury Norov wrote:
> > > Add num_{possible,present,active}_cpus_{eq,gt,le} and replace num_*_cpus()
> > > with one of new functions where appropriate. This allows num_*_cpus_*()
> > > to return earlier depending on the condition.
> > []
> > > diff --git a/arch/arc/kernel/smp.c b/arch/arc/kernel/smp.c
> > []
> > > @@ -103,7 +103,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
> > > * if platform didn't set the present map already, do it now
> > > * boot cpu is set to present already by init/main.c
> > > */
> > > - if (num_present_cpus() <= 1)
> > > + if (num_present_cpus_le(2))
> > > init_cpu_present(cpu_possible_mask);
> >
> > ? is this supposed to be 2 or 1
>
> X <= 1 is the equivalent of X < 2.
Ah, then the function is confusing. Usually it's lt = less than and lt
= less than or equal. Same idea for gt vs ge.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 7/9] lib/cpumask: add num_{possible,present,active}_cpus_{eq,gt,le}
2021-11-28 17:43 ` Yury Norov
2021-11-28 17:54 ` Dennis Zhou
2021-11-28 17:56 ` Emil Renner Berthing
@ 2021-11-28 17:57 ` Joe Perches
2 siblings, 0 replies; 7+ messages in thread
From: Joe Perches @ 2021-11-28 17:57 UTC (permalink / raw)
To: Yury Norov
Cc: linux-kernel, James E.J. Bottomley, Martin K. Petersen,
Paul E. McKenney, Rafael J. Wysocki, Alexander Shishkin,
Alexey Klimov, Amitkumar Karwar, Andi Kleen, Andrew Lunn,
Andrew Morton, Andy Gross, Andy Lutomirski, Andy Shevchenko,
Anup Patel, Ard Biesheuvel, Arnaldo Carvalho de Melo,
Arnd Bergmann, Borislav Petkov, Catalin Marinas,
Christoph Hellwig, Christoph Lameter, Daniel Vetter, Dave Hansen,
David Airlie, David Laight, Dennis Zhou, Dinh Nguyen,
Geetha sowjanya, Geert Uytterhoeven, Greg Kroah-Hartman, Guo Ren,
Hans de Goede, Heiko Carstens, Ian Rogers, Ingo Molnar,
Jakub Kicinski, Jason Wessel, Jens Axboe, Jiri Olsa,
Jonathan Cameron, Juri Lelli, Kalle Valo, Kees Cook,
Krzysztof Kozlowski, Lee Jones, Marc Zyngier, Marcin Wojtas,
Mark Gross, Mark Rutland, Matti Vaittinen, Mauro Carvalho Chehab,
Mel Gorman, Michael Ellerman, Mike Marciniszyn, Nicholas Piggin,
Palmer Dabbelt, Peter Zijlstra, Petr Mladek, Randy Dunlap,
Rasmus Villemoes, Roy Pledge, Russell King, Saeed Mahameed,
Sagi Grimberg, Sergey Senozhatsky, Solomon Peachy, Stephen Boyd,
Stephen Rothwell, Steven Rostedt, Subbaraya Sundeep, Sudeep Holla,
Sunil Goutham, Tariq Toukan, Tejun Heo, Thomas Bogendoerfer,
Thomas Gleixner, Ulf Hansson, Vincent Guittot, Vineet Gupta,
Viresh Kumar, Vivien Didelot, Vlastimil Babka, Will Deacon,
bcm-kernel-feedback-list, kvm, linux-alpha, linux-arm-kernel,
linux-crypto, linux-csky, linux-ia64, linux-mips, linux-mm,
linux-perf-users, linux-riscv, linux-s390, linux-snps-arc,
linuxppc-dev
On Sun, 2021-11-28 at 09:43 -0800, Yury Norov wrote:
> On Sun, Nov 28, 2021 at 09:07:52AM -0800, Joe Perches wrote:
> > On Sat, 2021-11-27 at 19:57 -0800, Yury Norov wrote:
> > > Add num_{possible,present,active}_cpus_{eq,gt,le} and replace num_*_cpus()
> > > with one of new functions where appropriate. This allows num_*_cpus_*()
> > > to return earlier depending on the condition.
> > []
> > > diff --git a/arch/arc/kernel/smp.c b/arch/arc/kernel/smp.c
> > []
> > > @@ -103,7 +103,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
> > > * if platform didn't set the present map already, do it now
> > > * boot cpu is set to present already by init/main.c
> > > */
> > > - if (num_present_cpus() <= 1)
> > > + if (num_present_cpus_le(2))
> > > init_cpu_present(cpu_possible_mask);
> >
> > ? is this supposed to be 2 or 1
>
> X <= 1 is the equivalent of X < 2.
True. The call though is _le not _lt
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 7/9] lib/cpumask: add num_{possible,present,active}_cpus_{eq,gt,le}
2021-11-28 17:54 ` Dennis Zhou
@ 2021-11-28 18:47 ` Yury Norov
0 siblings, 0 replies; 7+ messages in thread
From: Yury Norov @ 2021-11-28 18:47 UTC (permalink / raw)
To: Dennis Zhou
Cc: Joe Perches, linux-kernel, James E.J. Bottomley,
Martin K. Petersen, Paul E. McKenney, Rafael J. Wysocki,
Alexander Shishkin, Alexey Klimov, Amitkumar Karwar, Andi Kleen,
Andrew Lunn, Andrew Morton, Andy Gross, Andy Lutomirski,
Andy Shevchenko, Anup Patel, Ard Biesheuvel,
Arnaldo Carvalho de Melo, Arnd Bergmann, Borislav Petkov,
Catalin Marinas, Christoph Hellwig, Christoph Lameter,
Daniel Vetter, Dave Hansen, David Airlie, David Laight,
Dinh Nguyen, Geetha sowjanya, Geert Uytterhoeven,
Greg Kroah-Hartman, Guo Ren, Hans de Goede, Heiko Carstens,
Ian Rogers, Ingo Molnar, Jakub Kicinski, Jason Wessel, Jens Axboe,
Jiri Olsa, Jonathan Cameron, Juri Lelli, Kalle Valo, Kees Cook,
Krzysztof Kozlowski, Lee Jones, Marc Zyngier, Marcin Wojtas,
Mark Gross, Mark Rutland, Matti Vaittinen, Mauro Carvalho Chehab,
Mel Gorman, Michael Ellerman, Mike Marciniszyn, Nicholas Piggin,
Palmer Dabbelt, Peter Zijlstra, Petr Mladek, Randy Dunlap,
Rasmus Villemoes, Roy Pledge, Russell King, Saeed Mahameed,
Sagi Grimberg, Sergey Senozhatsky, Solomon Peachy, Stephen Boyd,
Stephen Rothwell, Steven Rostedt, Subbaraya Sundeep, Sudeep Holla,
Sunil Goutham, Tariq Toukan, Tejun Heo, Thomas Bogendoerfer,
Thomas Gleixner, Ulf Hansson, Vincent Guittot, Vineet Gupta,
Viresh Kumar, Vivien Didelot, Vlastimil Babka, Will Deacon,
bcm-kernel-feedback-list, kvm, linux-alpha, linux-arm-kernel,
linux-crypto, linux-csky, linux-ia64, linux-mips, linux-mm,
linux-perf-users, linux-riscv, linux-s390, linux-snps-arc,
linuxppc-dev
On Sun, Nov 28, 2021 at 12:54:00PM -0500, Dennis Zhou wrote:
> Hello,
>
> On Sun, Nov 28, 2021 at 09:43:20AM -0800, Yury Norov wrote:
> > On Sun, Nov 28, 2021 at 09:07:52AM -0800, Joe Perches wrote:
> > > On Sat, 2021-11-27 at 19:57 -0800, Yury Norov wrote:
> > > > Add num_{possible,present,active}_cpus_{eq,gt,le} and replace num_*_cpus()
> > > > with one of new functions where appropriate. This allows num_*_cpus_*()
> > > > to return earlier depending on the condition.
> > > []
> > > > diff --git a/arch/arc/kernel/smp.c b/arch/arc/kernel/smp.c
> > > []
> > > > @@ -103,7 +103,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
> > > > * if platform didn't set the present map already, do it now
> > > > * boot cpu is set to present already by init/main.c
> > > > */
> > > > - if (num_present_cpus() <= 1)
> > > > + if (num_present_cpus_le(2))
> > > > init_cpu_present(cpu_possible_mask);
> > >
> > > ? is this supposed to be 2 or 1
> >
> > X <= 1 is the equivalent of X < 2.
> >
> > > > diff --git a/drivers/cpufreq/pcc-cpufreq.c b/drivers/cpufreq/pcc-cpufreq.c
> > > []
> > > > @@ -593,7 +593,7 @@ static int __init pcc_cpufreq_init(void)
> > > > return ret;
> > > > }
> > > >
> > > > - if (num_present_cpus() > 4) {
> > > > + if (num_present_cpus_gt(4)) {
> > > > pcc_cpufreq_driver.flags |= CPUFREQ_NO_AUTO_DYNAMIC_SWITCHING;
> > > > pr_err("%s: Too many CPUs, dynamic performance scaling disabled\n",
> > > > __func__);
> > >
> > > It looks as if the present variants should be using the same values
> > > so the _le test above with 1 changed to 2 looks odd.
> >
>
> I think the confusion comes from le meaning less than rather than lt.
> Given the general convention of: lt (<), le (<=), eg (=), ge (>=),
> gt (>), I'd consider renaming your le to lt.
Ok, makes sense. I'll rename in v2 and add <= and >= versions.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-11-28 18:47 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <YaMME60Jfiz5BeJF@qmqm.qmqm.pl>
2021-11-28 6:34 ` [PATCH 7/9] lib/cpumask: add num_{possible,present,active}_cpus_{eq,gt,le} Yury Norov
2021-11-28 3:56 [PATCH 0/9] lib/bitmap: optimize bitmap_weight() usage Yury Norov
[not found] ` <20211128035704.270739-8-yury.norov@gmail.com>
2021-11-28 17:07 ` [PATCH 7/9] lib/cpumask: add num_{possible,present,active}_cpus_{eq,gt,le} Joe Perches
2021-11-28 17:43 ` Yury Norov
2021-11-28 17:54 ` Dennis Zhou
2021-11-28 18:47 ` Yury Norov
2021-11-28 17:56 ` Emil Renner Berthing
2021-11-28 17:57 ` Joe Perches
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).