Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp86019pxx; Wed, 28 Oct 2020 19:07:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzmBstArcMzxs3wuyMJqYhMnUnQz3J9UCVlC975gPkseT/LABPnfhWCtJjl+xEql4vRjEEJ X-Received: by 2002:a17:906:1bea:: with SMTP id t10mr1868165ejg.305.1603937259234; Wed, 28 Oct 2020 19:07:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603937259; cv=none; d=google.com; s=arc-20160816; b=jzw+2ti4GZy+5ocI0J0DUC+iUAT03gavOfSwq2fM9/1ACYy0HXuYRURNFwL2cBLuZB XylnEWiMXa3NUUDTh19vqd/K3TYhGm/f5sBZFmDkWnMk0EfjKvc0zb9T+IopYypeIkYX aUPPcdyaF7slqfL/ePpVdE01WH1ZFP/tgxRufS7HjUxp4sm2z8tMwSeV+LW3Bq5I60Bx Vb1LSptOcD8yd/D3GNo1YeWiu9eV8eLyZ7w7lz0UiDDglvkA3Ebbs2e5UwANgEM9m3lI cK4TJ/IlBrlg0B755DN12ylN8SDyI8G3EHrq4KTRyyCYh/uyxOp49OR0Jr/D8NitPabd tApQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=tY62jOozVFWsLgtCKVIohKxROUiqal53y5VibCuTvtk=; b=NH6GRqEQCIUDg/h1z7i1tM2K1PzVxNe7OuTC2jZggjZx+Nbx3E4z1+uPTUuE/Tog9+ YaR7PlQQOf0P2D96tZ45p77mFAgSgHTyX9yIH1p/kY5YJNR55FEP4Lr9+fdIHJkLKwXb bhwXPL1weUzaTDfLChGR+afY7r71KZJ61LnV0Q8gcGrEP8EFFHDwC2eLuONIdDGw0kRr tBCIvy+BAtsfuHIfQc96cS+iu8HT1adES/KWk0zfQ20k392DqUUo2d9b1y5AwFo8Tghs iF584GB/ymYFIbGs/6Yxh795ZWCOndbsS6bB5hyE4JBl1URiwB0/PN6a6fcrSXr0kX42 z3Uw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dn22si160790edb.239.2020.10.28.19.07.16; Wed, 28 Oct 2020 19:07:39 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730433AbgJ1WIq (ORCPT + 99 others); Wed, 28 Oct 2020 18:08:46 -0400 Received: from foss.arm.com ([217.140.110.172]:38890 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729546AbgJ1WHQ (ORCPT ); Wed, 28 Oct 2020 18:07:16 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 204E21AC1; Wed, 28 Oct 2020 11:29:50 -0700 (PDT) Received: from e107158-lin (e107158-lin.cambridge.arm.com [10.1.194.78]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5434A3F719; Wed, 28 Oct 2020 11:29:49 -0700 (PDT) Date: Wed, 28 Oct 2020 18:29:46 +0000 From: Qais Yousef To: Patrick Bellasi Cc: Yun Hsiang , Dietmar Eggemann , peterz@infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 1/1] sched/uclamp: add SCHED_FLAG_UTIL_CLAMP_RESET flag to reset uclamp Message-ID: <20201028182946.6qfmt7q35ewrjjua@e107158-lin> References: <20201025073632.720393-1-hsiang023167@gmail.com> <08b7cdda-291c-bdf1-b72d-0a3ef411fcf3@arm.com> <20201026154538.GA807103@ubuntu> <605c21f7-3c4d-5c24-6d23-9f2604e6757b@arm.com> <20201027155813.GA818508@ubuntu> <87v9eumzic.derkling@matbug.net> <20201028113943.7jzxbytizrv7wsm3@e107158-lin> <87sg9ymdmw.derkling@matbug.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <87sg9ymdmw.derkling@matbug.net> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/28/20 19:03, Patrick Bellasi wrote: > > On Wed, Oct 28, 2020 at 12:39:43 +0100, Qais Yousef wrote... > > > On 10/28/20 11:11, Patrick Bellasi wrote: > >> >> > >> >> /* > >> >> * RT by default have a 100% boost value that could be modified > >> >> * at runtime. > >> >> */ > >> >> if (unlikely(rt_task(p) && clamp_id == UCLAMP_MIN)) > >> >> - __uclamp_update_util_min_rt_default(p); > >> >> + value = sysctl_sched_uclamp_util_min_rt_default; > >> > >> By removing this usage of __uclamp_updadate_util_min_rt_default(p), > >> the only other usage remaining is the call from: > >> uclamp_udpate_util_min_rt_default(). > >> > >> What about an additional cleanup by in-lining the only surviving usage? > > > > This is not a cleanup IMO. There is special rule about updating that are > > encoded and documented in this helper function. Namely: > > > > * p->pi_lock must be held. > > * p->uclamp_req[].user_defined must be false. > > Both these conditions are satisfied in the above call site: > - user_defined is tested just 4 lines above > - pi_lock is taken by the caller, i.e. __sched_setscheduler() > Thus, there is no need to test them two times. > Moreover, the same granted pi_lock you check in > __ucalmp_update_util_min_rt_default() is not checked at all in the rest > of __setscheduler_uclamp(). Updating the default rt value is done from different contexts. Hence it is important to document the rules under which this update must happen and ensure the update happens through a common path. __setscheduler_uclamp() is not called from 2 different contexts. > Thus, perhaps we should have just avoided to add > __uclamp_update_util_min_rt_default() since the beginning and: > - have all its logic in the _only_ place where it's required > - added the lockdep_assert_held() in __setscheduler_uclamp() > > That's why I consider this a very good cleanup opportunity. I disagree. This is unnecessary churn. Thanks -- Qais Yousef > > I don't see open coding helps but rather makes the code harder to read and > > prone to introduce bugs if anything gets reshuffled in the future. > > It's not open coding IMHO, it's just adding the code that's required.