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, 3 Oct 2023 14:32:36 -0400
From:   Waiman Long <longman@...hat.com>
To:     Ingo Molnar <mingo@...nel.org>
Cc:     Ingo Molnar <mingo@...hat.com>,
        Peter Zijlstra <peterz@...radead.org>,
        Juri Lelli <juri.lelli@...hat.com>,
        Vincent Guittot <vincent.guittot@...aro.org>,
        Dietmar Eggemann <dietmar.eggemann@....com>,
        Steven Rostedt <rostedt@...dmis.org>,
        Ben Segall <bsegall@...gle.com>, Mel Gorman <mgorman@...e.de>,
        Daniel Bristot de Oliveira <bristot@...hat.com>,
        Valentin Schneider <vschneid@...hat.com>,
        linux-kernel@...r.kernel.org, Phil Auld <pauld@...hat.com>,
        Brent Rowsell <browsell@...hat.com>,
        Peter Hunt <pehunt@...hat.com>
Subject: Re: [PATCH v3] sched/core: Use empty mask to reset cpumasks in
 sched_setaffinity()


On 10/3/23 05:17, Ingo Molnar wrote:
> * Waiman Long <longman@...hat.com> wrote:
>
>> Since commit 8f9ea86fdf99 ("sched: Always preserve the user requested
>> cpumask"), user provided CPU affinity via sched_setaffinity(2) is
>> perserved even if the task is being moved to a different cpuset. However,
>> that affinity is also being inherited by any subsequently created child
>> processes which may not want or be aware of that affinity.
>>
>> One way to solve this problem is to provide a way to back off from
>> that user provided CPU affinity.  This patch implements such a scheme
>> by using an empty cpumask to signal a reset of the cpumasks to the
>> default as allowed by the current cpuset.
>>
>> Before this patch, passing in an empty cpumask to sched_setaffinity(2)
>> will always return an -EINVAL error. With this patch, an alternative
>> error of -ENODEV will be returned returned if sched_setaffinity(2)
>> has been called before to set up user_cpus_ptr. In this case, the
>> user_cpus_ptr that stores the user provided affinity will be cleared and
>> the task's CPU affinity will be reset to that of the current cpuset. This
>> alternative error code of -ENODEV signals that the no CPU is specified
>> and, at the same time, a side effect of resetting cpu affinity to the
>> cpuset default.
> I agree that this problem needs a solution, but I don't really agree
> with the -ENODEV ABI hack.
>
> Why not just return success in that case? The 'reset' of the mask was
> successful after all.

I believe the v1 patch just returns success like what you said. However, 
there are existing tests that assume a sched_setaffinity() call with 
empty cpumask in the valid cpu range will return error. It is also 
sometime used to check if the CPU number is out of the valid range. That 
is the reason why I change the patch to return error as well to avoid 
breaking existing use cases. I purposely return a different error to 
indicate a reset has happened. Let me know if you have other suggestions 
on the best way forward.

Thanks,
Longman

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ