Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp2967949ybz; Sun, 3 May 2020 13:50:00 -0700 (PDT) X-Google-Smtp-Source: APiQypKSpHslELuBVlIW9UhXr4gQx+h+hzdP2VHk3XgGRvmuGq6pZwxnlsfF46Zp3gmYgaDnHsh3 X-Received: by 2002:aa7:d78a:: with SMTP id s10mr12583420edq.319.1588539000516; Sun, 03 May 2020 13:50:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588539000; cv=none; d=google.com; s=arc-20160816; b=FaYNoKwds8Gwd4ZMoXArAVdWjvZJbUsN5+QP5lf2QOko3cDx7oFSBoZ3/4zgLNv/DP DMK1yo5MU5VF1nxaMfOPjOTfc5JTv4TWxvw967+nL/jhal0KyPhK0HUM6vkoQfqe0062 S6G9waKmIcvHPZVacgCxs+qO8pVm2WUubmSV7T+Yh3hhTJMOjkb5+KkUc++iowRPDUX+ wxKmp2eBwcYp5a+JY1YCV/Gvo3JXaprquPYbjtHZzlqiJuOW/bVovHWrjZU5kX9MOLRl pp33FVmnV5d4d3V6fR6SY1Zml0JFrx/dqo2VJaFjQmilnqZLgfsN/FNiqEsLF1MnTwpP pu7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=+0sdnkVZbsyiwR4ogx2xRdmr3SLasPRkq7vJKuYtrDs=; b=J+KLNO9Cc1tusLlRLDB8qTFLn4VUeAfKvaWq7/8PuMLjjJMrvyFKXE3Y/N3a3LVP3j w2GFx1ru9VRkZnzrea8Ym3LeWrcQXWKBy7j5Mz9cKdkt51dbJWbQaXScPAL2PAG1T0jr akHtJiObuh38JqDXkOzyJDakKXSO/GkvPw9lC9knkxVgoDBeMBv7ZGaH58Tvn4XuM2Da G4scNqNbPFk76EDqeQpUx2zan8aWV+RZRDjNuUVE+m/k+Z9jQan6R5b6Nk96nNjZpNQ8 99ncN9hXEX1vhRGk3iFhOdTK25x9EIbSuezUUsrDnqUKuKy/atClsvJaYPBFbwYKJdXq YxCQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x25si5746174eds.136.2020.05.03.13.49.35; Sun, 03 May 2020 13:50:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729081AbgECUre (ORCPT + 99 others); Sun, 3 May 2020 16:47:34 -0400 Received: from mx2.suse.de ([195.135.220.15]:36770 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729002AbgECUre (ORCPT ); Sun, 3 May 2020 16:47:34 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 64416AAC7; Sun, 3 May 2020 20:47:33 +0000 (UTC) Date: Sun, 3 May 2020 13:43:15 -0700 From: Davidlohr Bueso To: Peter Zijlstra Cc: akpm@linux-foundation.org, tglx@linutronix.de, mingo@kernel.org, mgorman@techsingularity.net, bp@suse.de, linux-kernel@vger.kernel.org, Davidlohr Bueso , oleg@redhat.com Subject: Re: [PATCH] kernel/sys: do not use tasklist_lock to set/get scheduling priorities Message-ID: <20200503204315.lmk66kludmjaoxbq@linux-p48b> References: <20200502030539.32581-1-dave@stgolabs.net> <20200502093105.GJ3762@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20200502093105.GJ3762@hirez.programming.kicks-ass.net> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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