lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Message-ID: <YtXQGMijINmEoiVi@worktop.programming.kicks-ass.net> Date: Mon, 18 Jul 2022 23:26:48 +0200 From: Peter Zijlstra <peterz@...radead.org> To: Yury Norov <yury.norov@...il.com> Cc: linux-kernel@...r.kernel.org, Alexander Lobakin <alexandr.lobakin@...el.com>, Alexei Starovoitov <ast@...nel.org>, Alexey Klimov <aklimov@...hat.com>, Andrew Morton <akpm@...ux-foundation.org>, Andrii Nakryiko <andrii@...nel.org>, Andy Shevchenko <andriy.shevchenko@...ux.intel.com>, Ben Segall <bsegall@...gle.com>, Christoph Lameter <cl@...ux.com>, Dan Williams <dan.j.williams@...el.com>, Daniel Borkmann <daniel@...earbox.net>, Daniel Bristot de Oliveira <bristot@...hat.com>, Dennis Zhou <dennis@...nel.org>, Dietmar Eggemann <dietmar.eggemann@....com>, Eric Dumazet <edumazet@...gle.com>, Frederic Weisbecker <fweisbec@...il.com>, Guenter Roeck <linux@...ck-us.net>, Ingo Molnar <mingo@...hat.com>, Isabella Basso <isabbasso@...eup.net>, John Fastabend <john.fastabend@...il.com>, Josh Poimboeuf <jpoimboe@...nel.org>, Juergen Gross <jgross@...e.com>, Juri Lelli <juri.lelli@...hat.com>, KP Singh <kpsingh@...nel.org>, Kees Cook <keescook@...omium.org>, Martin KaFai Lau <kafai@...com>, Mel Gorman <mgorman@...e.de>, Miroslav Benes <mbenes@...e.cz>, Nathan Chancellor <nathan@...nel.org>, "Paul E . McKenney" <paulmck@...nel.org>, Randy Dunlap <rdunlap@...radead.org>, Rasmus Villemoes <linux@...musvillemoes.dk>, Sebastian Andrzej Siewior <bigeasy@...utronix.de>, Song Liu <songliubraving@...com>, Steven Rostedt <rostedt@...dmis.org>, Tejun Heo <tj@...nel.org>, Thomas Gleixner <tglx@...utronix.de>, Valentin Schneider <vschneid@...hat.com>, Vincent Guittot <vincent.guittot@...aro.org>, Vlastimil Babka <vbabka@...e.cz>, Yonghong Song <yhs@...com>, linux-mm@...ck.org, netdev@...r.kernel.org, bpf@...r.kernel.org Subject: Re: [PATCH 07/16] smp: optimize smp_call_function_many_cond() On Mon, Jul 18, 2022 at 12:28:35PM -0700, Yury Norov wrote: > diff --git a/kernel/smp.c b/kernel/smp.c > index dd215f439426..7ed2b9b12f74 100644 > --- a/kernel/smp.c > +++ b/kernel/smp.c > @@ -880,6 +880,28 @@ EXPORT_SYMBOL_GPL(smp_call_function_any); > #define SCF_WAIT (1U << 0) > #define SCF_RUN_LOCAL (1U << 1) > > +/* Check if we need remote execution, i.e., any CPU excluding this one. */ > +static inline bool __need_remote_exec(const struct cpumask *mask, unsigned int this_cpu) > +{ > + unsigned int cpu; > + > + switch (num_online_cpus()) { > + case 0: > + return false; > + case 1: > + return cpu_online(this_cpu) ? false : true; > + default: > + if (mask == cpu_online_mask) > + return true; > + } > + > + cpu = cpumask_first_and(mask, cpu_online_mask); > + if (cpu == this_cpu) > + cpu = cpumask_next_and(cpu, mask, cpu_online_mask); > + > + return cpu < nr_cpu_ids; > +} > + > static void smp_call_function_many_cond(const struct cpumask *mask, > smp_call_func_t func, void *info, > unsigned int scf_flags, > @@ -916,12 +938,7 @@ static void smp_call_function_many_cond(const struct cpumask *mask, > if ((scf_flags & SCF_RUN_LOCAL) && cpumask_test_cpu(this_cpu, mask)) > run_local = true; > > - /* Check if we need remote execution, i.e., any CPU excluding this one. */ > - cpu = cpumask_first_and(mask, cpu_online_mask); > - if (cpu == this_cpu) > - cpu = cpumask_next_and(cpu, mask, cpu_online_mask); > - if (cpu < nr_cpu_ids) > - run_remote = true; > + run_remote = __need_remote_exec(mask, this_cpu); > > if (run_remote) { > cfd = this_cpu_ptr(&cfd_data); This is more complex code for, very little to no gain. Why ?!
Powered by blists - more mailing lists