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 22:47:57 +0200
From: Thomas Gleixner <tglx@...utronix.de>
To: Yury Norov <yury.norov@...il.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>, 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 6/6] tick/common: optimize cpumask_equal() usage

On Tue, May 14 2024 at 09:47, Yury Norov wrote:
>> Instead of sprinkling these conditional all over the place, can't you
>> just do the obvious and check for ptr1 == ptr2 in bitmap_copy() and
>> bitmap_equal()?
>
> I proposed this a while (few years) ago, and it has been rejected. On
> bitmaps level we decided not to do that for the reasons memcpy() and
> memcmp() doesn't, and on cpumasks and nodemasks level it hasn't
> been discussed at all.
>
> Now that most of bitmap ops have inline and outline implementation,
> we technically can move this checks in outline code, as inline bitmap
> ops are very lightweight already.
>
> So I see the following options:
>  - Implement these sanity checks in outline bitmap API (lib/bitmap.c);
>  - Implement them on cpumask and nodemask level; or
>  - add a new family of helpers that do this check, like
>   bitmap_copy_if_needed() (better name appreciated).
>
> The argument against #1 and #2 these days was that memcpy() and
> similarly bitmap_copy() with dst == src may be a sign of error, and
> we don't want to add a code that optimizes for it.

That's a fair argument.

> Now, I ran the kernel through the LTP test and in practice all the
> cases that I spot look pretty normal. So I can continue sprinkling
> the checks once a few years, or do something like described above.

I don't see these checks as valuable in most cases and I detest them as
they make the code harder to read.

Except for smp_call_function_many_cond() and to a lesser extent
irq_do_set_affinity() none of them you added really matters.

Though it might be worth to have helper functions which make it obvious
that the src == dst case is intentional.

Thanks,

        tglx

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ