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
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 14 May 2024 09:16:04 -0700
From: Yury Norov <yury.norov@...il.com>
To: Jinjie Ruan <ruanjinjie@...wei.com>
Cc: linux-kernel@...r.kernel.org, 
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>, "Paul E. McKenney" <paulmck@...nel.org>, 
	"Rafael J. Wysocki" <rafael@...nel.org>, Anna-Maria Behnsen <anna-maria@...utronix.de>, 
	Ben Segall <bsegall@...gle.com>, Daniel Bristot de Oliveira <bristot@...hat.com>, 
	Dietmar Eggemann <dietmar.eggemann@....com>, Frederic Weisbecker <frederic@...nel.org>, 
	Imran Khan <imran.f.khan@...cle.com>, Ingo Molnar <mingo@...hat.com>, 
	Johannes Weiner <hannes@...xchg.org>, Juri Lelli <juri.lelli@...hat.com>, 
	Leonardo Bras <leobras@...hat.com>, Mel Gorman <mgorman@...e.de>, 
	Peter Zijlstra <peterz@...radead.org>, Rik van Riel <riel@...riel.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>, Waiman Long <longman@...hat.com>, 
	Zefan Li <lizefan.x@...edance.com>, cgroups@...r.kernel.org
Subject: Re: [PATCH 4/6] genirq: optimize irq_do_set_affinity()

On Tue, May 14, 2024 at 5:51 AM Jinjie Ruan <ruanjinjie@...wei.com> wrote:
>
>
>
> On 2024/5/14 6:01, Yury Norov wrote:
> > If mask == desc->irq_common_data.affinity, copying one to another is
> > useless, and we can just skip it.
> >
> > Signed-off-by: Yury Norov <yury.norov@...il.com>
> > ---
> >  kernel/irq/manage.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
> > index bf9ae8a8686f..ad9ed9fdf919 100644
> > --- a/kernel/irq/manage.c
> > +++ b/kernel/irq/manage.c
> > @@ -285,7 +285,8 @@ int irq_do_set_affinity(struct irq_data *data, const struct cpumask *mask,
> >       switch (ret) {
> >       case IRQ_SET_MASK_OK:
> >       case IRQ_SET_MASK_OK_DONE:
> > -             cpumask_copy(desc->irq_common_data.affinity, mask);
> > +             if (desc->irq_common_data.affinity != mask)
> > +                     cpumask_copy(desc->irq_common_data.affinity, mask);
>
> It seems that mask is a pointer, shouldn't use "cpumask_equal"?

cpumask_equal() is O(N), just as cpumask_copy(), so we'll have no
benefit if the masks are equal, and will double slow it if they aren't
in the worst case.

On the other hand, pointers comparison is O(1), a very quick tasks,
even more the pointers are already in registers.

> >               fallthrough;
> >       case IRQ_SET_MASK_OK_NOCOPY:
> >               irq_validate_effective_affinity(data);

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ