lkml.org 
[lkml]   [2020]   [May]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] kernel/sys: do not use tasklist_lock to set/get scheduling priorities
Cc'ing Oleg who iirc also like this stuff.

On Sat, 02 May 2020, Peter Zijlstra wrote:

>On Fri, May 01, 2020 at 08:05:39PM -0700, Davidlohr Bueso wrote:
>> For both setpriority(2) and getpriority(2) there's really no need
>> to be taking the tasklist_lock at all - for which both share it
>> for the entirety of the syscall. The tasklist_lock does not protect
>> reading/writing the p->static_prio and task lookups are already rcu
>> safe, providing a stable pointer.
>
>RCU-safe, as in, it will not crash.. However, without tasklist_lock the
>thread iterations (for PRIO_PGRP/PRIO_USER) now race against fork().
>
>That is a user observable change in behaviour.
>
>Do we care about it? No idea, and your Changelog also doesn't provide
>clue.

Yeah, that was convenient of me to leave out, sorry. So copy_process()
will hlist_add_rcu() under the writer tasklist_lock, but pid->tasks rculist
traversals are safe. As such afaiu this fork serialization is for concurrent
changes, something these syscalls do not do.

In any case, we could at least keep the changes to getpriority(2) as even
if there is a race in the list the new priority won't be any higher than
what was observed already, thus maintaining semantics.

Thanks,
Davidlohr

\
 
 \ /
  Last update: 2020-05-03 22:48    [W:0.044 / U:0.588 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site