Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1124486ybh; Mon, 13 Jul 2020 09:57:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz2l6iE7bkRPkEYQC2E4fzBC+kMG5g1obnHU/7zptLzyaipNEhozYlCWwPKZ5minyLvEmvU X-Received: by 2002:a05:6402:2212:: with SMTP id cq18mr328669edb.173.1594659432635; Mon, 13 Jul 2020 09:57:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594659432; cv=none; d=google.com; s=arc-20160816; b=MafBNtqrtIKD68msjz1vxOYT+GavNcHOwGC1vJKmIVeJxIMOzvPMWsi34brcSGuHBd mM7vJH189euEnXPH0DfLTLk6fB9VQSGNd4kiH+IfNSdRuwf40+qAKL4Dk7Wtpr8J8KQD V4a4SXebdF89IyNFyUREdZYsiXae4SDzXD2It6GhZRozdcEDDayP1wK5q61yz1lAsbZE kM9dp8ESkqePxti9xfq790nrWs/SZR5I5yWKy0iw3eDT6v9AYmc1AsTl7fLYn7MecCIE ozKcCvKYB2zSc9LtqDaJvnpSwz53ggWDZTYpFnZYrn4YEJklYaDmffIspl7dt18IUV/K 1ddg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=HuDdCAe7E/MURwBsmW1Ls9iUs+3VUz9I3ziwdok6E+A=; b=QFRy9ydXCS3ykROtQPmZOMN3cdqdKx7sn5qdtF1F7DV/Ks7WtFYZ1akv25FOqG7nO5 ydkv77efQCu8SPaMeO5tYS2Z98g0o4hgHhbkofW81GgJLJg5KNhAYKzE0bqTxvLIPoOI YlAfruKSmAPrrCV+p9Tw/JjN6SzBXK3Ryeqr9r4V0ROmkUoSCvefH6K41oE5jsmfu6oC 1vcvL0oiVymday7qGyMvhsEDQPlcrCOwr7Mia2Goo/haJ8H0mAa3s+uCgChMbptRN3OO qmfCR1XlBM9LXVHrW1rUYDyZWarVHefNix5i+pVwph5yFVPquHkRifcA4+818iSP74n7 CgtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=LWb7VIGp; 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 g15si9715919edy.200.2020.07.13.09.56.49; Mon, 13 Jul 2020 09:57:12 -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; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=LWb7VIGp; 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 S1730194AbgGMQzM (ORCPT + 99 others); Mon, 13 Jul 2020 12:55:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729659AbgGMQzM (ORCPT ); Mon, 13 Jul 2020 12:55:12 -0400 Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CB39C061794; Mon, 13 Jul 2020 09:55:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=HuDdCAe7E/MURwBsmW1Ls9iUs+3VUz9I3ziwdok6E+A=; b=LWb7VIGpl0H9u+jUhBSNqsfnkh bI7HOZD2MHbpne8P2z3FF2pANyq/O8ttXKz04u7N2xaiedmLEqGd7qOcFY968v9TUKHQcTqqL20Pj xg7dow/Qn1uV2dvTd1URZW80j6On7agD3JZkY64Vl13C7EVuq5rvK8R3oosHdsHeal3ejwztgJoAq QlFoNCgY1gQ5BnT1IW9JY3YBcnbg78ejezNjzOSS3rtMjNoBARVCMx5ckbwcX3Ig7VBuWikmnkQEI GBZE8bahcF2hRsRXOQeIN67F1ZxxHaiCnIX0mnSlZoZdfbE0vIseds6GoqtLPbjxMMHoM7S1LZr7s ro7N6bwA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jv1jA-00043K-2o; Mon, 13 Jul 2020 16:54:52 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id E60EE303A02; Mon, 13 Jul 2020 18:54:49 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id CCBF020D28BB0; Mon, 13 Jul 2020 18:54:49 +0200 (CEST) Date: Mon, 13 Jul 2020 18:54:49 +0200 From: Peter Zijlstra To: Qais Yousef Cc: Ingo Molnar , Doug Anderson , Jonathan Corbet , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Luis Chamberlain , Kees Cook , Iurii Zaikin , Quentin Perret , Valentin Schneider , Patrick Bellasi , Pavan Kondeti , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH v6 1/2] sched/uclamp: Add a new sysctl to control RT default boost value Message-ID: <20200713165449.GM10769@hirez.programming.kicks-ass.net> References: <20200706142839.26629-1-qais.yousef@arm.com> <20200706142839.26629-2-qais.yousef@arm.com> <20200713112125.GG10769@hirez.programming.kicks-ass.net> <20200713121246.xjif3g4zpja25o5r@e107158-lin.cambridge.arm.com> <20200713133558.GK10769@hirez.programming.kicks-ass.net> <20200713142754.tri5jljnrzjst2oe@e107158-lin.cambridge.arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200713142754.tri5jljnrzjst2oe@e107158-lin.cambridge.arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 13, 2020 at 03:27:55PM +0100, Qais Yousef wrote: > On 07/13/20 15:35, Peter Zijlstra wrote: > > > I protect this with rcu_read_lock() which as far as I know synchronize_rcu() > > > will ensure if we do the update during this section; we'll wait for it to > > > finish. New forkees entering the rcu_read_lock() section will be okay because > > > they should see the new value. > > > > > > spinlocks() and mutexes seemed inferior to this approach. > > > > Well, didn't we just write in another patch that p->uclamp_* was > > protected by both rq->lock and p->pi_lock? > > __setscheduler_uclamp() path is holding these locks, not sure by design or it > just happened this path holds the lock. I can't see the lock in the > uclamp_fork() path. But it's hard sometimes to unfold the layers of callers, > especially not all call sites are annotated for which lock is assumed to be > held. > > Is it safe to hold the locks in uclamp_fork() while the task is still being > created? My new code doesn't hold it of course. > > We can enforce this rule if you like. Though rcu critical section seems lighter > weight to me. > > If all of this does indeed start looking messy we can put the update in > a delayed worker and schedule that instead of doing synchronous setup. sched_fork() doesn't need the locks, because at that point the task isn't visible yet. HOWEVER, sched_post_fork() is after pid-hash (per design) and thus the task is visible, so we can race against sched_setattr(), so we'd better hold those locks anyway.