Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp584006ybt; Fri, 19 Jun 2020 08:42:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyaYKyzNUe0t2BpInd2yyyRHVhgn+T6kDwJfJVWuOzcg2fD6OeCJghKeKxjqk7uIh8xxIca X-Received: by 2002:a50:bb29:: with SMTP id y38mr3923908ede.358.1592581332739; Fri, 19 Jun 2020 08:42:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592581332; cv=none; d=google.com; s=arc-20160816; b=IQd1FS5xJx5P4z4yvZ9GXijUWYXVGBrtkRSityT6ql9X3NfOEnIuZUBK3yy4c3t7rk VAV96ZL01RauF+bWWV53xSOuy3UV/NWft6fAX/MPPNaeyvhvREQimXtGwu9mpgHZLiiG NtY967gny9KOXls7oH4DyCZJN5+2ZosthK2+rKM/A5yYE8TcVvj+TjnLf0eJNPlLeH5Q vb6KBpu3UMfU6MayyWCLkD/BbE/cDr8dYmdAZnXBtEGOkeO05vtJvmy7FqUvuCtoSVBA Ct5f04Zihxem8gs8uaSf8OTXR8gjQ3TXvGuwhFJQtBp7BrgSC0PWEFyE+K+/sdRscm4b stmA== 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=PUhcu1MZclCQixaE/0nT98wKZ1keU3ikgP1Xm9n6ack=; b=JWfbi4N2rz5XembEoKx6AGn7X+6x/GNyAJHoflqi6eoOLjNDM4HHVMYdz3dgn/PTm+ 706eL+8xYXy9sx1VLcwCLe6gCKMndMzzD0r+2p73n6EeByw69W2mRFEjwo5rVOPg+WSB 9zpXfGH0X3ZIX7VTZ0JuTpuJ70WDO2nnAU9R/b5pI7L8dGD6Om4tVsin0XnpsgsNVahT bYH2lsYrYu/COJ5d9i5+LmpylvMUWdmCnDG/BI19oHz/Ga/Kut+pWHUFW49oezsmLRhx xAm5bEnu1+Gm51/NMsi12iXVJHEJ986VEvQ+OaX4RxRyCJ4RMIe36Mn5E8G5R/1PZC+w 7a6A== 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 a13si3962614ejb.241.2020.06.19.08.41.50; Fri, 19 Jun 2020 08:42: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; 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 S2404480AbgFSPjA (ORCPT + 99 others); Fri, 19 Jun 2020 11:39:00 -0400 Received: from foss.arm.com ([217.140.110.172]:40230 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391845AbgFSPi4 (ORCPT ); Fri, 19 Jun 2020 11:38:56 -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 8184B101E; Fri, 19 Jun 2020 08:38:55 -0700 (PDT) Received: from e107158-lin.cambridge.arm.com (e107158-lin.cambridge.arm.com [10.1.195.21]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id F0CC63F71F; Fri, 19 Jun 2020 08:38:53 -0700 (PDT) Date: Fri, 19 Jun 2020 16:38:51 +0100 From: Qais Yousef To: Doug Anderson Cc: Benson Leung , Enric Balletbo i Serra , hsinyi@chromium.org, Joel Fernandes , Peter Zijlstra , Nicolas Boichat , Gwendal Grignou , Quentin Perret , ctheegal@codeaurora.org, Guenter Roeck , LKML Subject: Re: [PATCH] cros_ec_spi: Even though we're RT priority, don't bump cpu freq Message-ID: <20200619153851.vigshoae3ahiy63x@e107158-lin.cambridge.arm.com> References: <20200610151818.1.I666ecd9c6f3c6405bd75831a21001b8109b6438c@changeid> <20200612125250.7bwjfnxhurdf5bwj@e107158-lin.cambridge.arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20171215 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/18/20 14:18, Doug Anderson wrote: > Hi, > > On Fri, Jun 12, 2020 at 5:52 AM Qais Yousef wrote: > > > > On 06/10/20 15:18, Douglas Anderson wrote: > > > The cros_ec_spi driver is realtime priority so that it doesn't get > > > preempted by other taks while it's talking to the EC but overall it > > > really doesn't need lots of compute power. Unfortunately, by default, > > > the kernel assumes that all realtime tasks should cause the cpufreq to > > > jump to max and burn through power to get things done as quickly as > > > possible. That's just not the correct behavior for cros_ec_spi. > > > > > > Switch to manually overriding the default. > > > > > > This won't help us if our work moves over to the SPI pump thread but > > > that's not the common code path. > > > > > > Signed-off-by: Douglas Anderson > > > --- > > > NOTE: This would cause a conflict if the patch > > > https://lore.kernel.org/r/20200422112831.870192415@infradead.org lands > > > first > > > > > > drivers/platform/chrome/cros_ec_spi.c | 10 ++++++---- > > > 1 file changed, 6 insertions(+), 4 deletions(-) > > > > > > diff --git a/drivers/platform/chrome/cros_ec_spi.c b/drivers/platform/chrome/cros_ec_spi.c > > > index debea5c4c829..76d59d5e7efd 100644 > > > --- a/drivers/platform/chrome/cros_ec_spi.c > > > +++ b/drivers/platform/chrome/cros_ec_spi.c > > > @@ -709,8 +709,11 @@ static void cros_ec_spi_high_pri_release(void *worker) > > > static int cros_ec_spi_devm_high_pri_alloc(struct device *dev, > > > struct cros_ec_spi *ec_spi) > > > { > > > - struct sched_param sched_priority = { > > > - .sched_priority = MAX_RT_PRIO / 2, > > > + struct sched_attr sched_attr = { > > > + .sched_policy = SCHED_FIFO, > > > + .sched_priority = MAX_RT_PRIO / 2, > > > + .sched_flags = SCHED_FLAG_UTIL_CLAMP_MIN, > > > + .sched_util_min = 0, > > > > Hmm I thought Peter already removed all users that change RT priority directly. > > > > https://lore.kernel.org/lkml/20200422112719.826676174@infradead.org/ > > Yeah, I mentioned that patch series "after the cut" in my patch and > also made sure to CC Peter on my patch. I'm not sure what happened to > that series since I don't see it in linuxnext... Apologies I missed that. > > > > > }; > > > int err; > > > > > > @@ -728,8 +731,7 @@ static int cros_ec_spi_devm_high_pri_alloc(struct device *dev, > > > if (err) > > > return err; > > > > > > - err = sched_setscheduler_nocheck(ec_spi->high_pri_worker->task, > > > - SCHED_FIFO, &sched_priority); > > > + err = sched_setattr_nocheck(ec_spi->high_pri_worker->task, &sched_attr); > > > if (err) > > > dev_err(dev, "Can't set cros_ec high pri priority: %d\n", err); > > > return err; > > > > If I read the code correctly, if you fail here cros_ec_spi_probe() will fail > > too and the whole thing will not be loaded. If you compile without uclamp then > > sched_setattr_nocheck() will always fail with -EOPNOTSUPP. > > Oops, definitely need to send out a v2 for that if nothing else. Is > there any good way for me to code this up or do I need a big #ifdef > somewhere in my code? A big #ifdef. But this kind of use I don't think was anticipated. And generally if we want to allow that, it has to be done via a proper API. Drivers picking random uclamp values is as bad as them picking random RT priority. > > > > Why can't you manage the priority and boost value of such tasks via your init > > scripts instead? > > I guess I feel like it's weird in this case. Userspace isn't creating > this task and isn't the one marking it as realtime. ...and, if we > ever manage to upgrade the protocol which we use to talk to the EC we > might fully get rid of this task the need to have something boosted up > to realtime. > > Said another way: the fact that we even have this task at all and the > fact that it's realtime is an implementation detail of the kernel. It > seems really weird to add initscripts for it. Yes this is the problem of RT for a general purpose systems. It's hard to reason about their priorities/importance since it's not a special purpose system with well defined spec of what hardware/software will be running on it and their precise requirements is not known before hand. > > > > I have to admit I need to think about whether it makes sense to have a generic > > API that allows drivers to opt-out of the default boosting behavior for their > > RT tasks. > > Seems like it would be useful. If you propose something that will help the discussion. I think based on the same approach Peter has taken to prevent random RT priorities. In uclamp case I think we just want to allow driver to opt RT tasks out of the default boosting behavior. I'm a bit wary that this extra layer of tuning might create a confusion, but I can't reason about why is it bad for a driver to say I don't want my RT task to be boosted too. Thanks -- Qais Yousef