Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp446433ybg; Fri, 12 Jun 2020 05:55:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwRoQwHM2p9hRQNhoHmfj24/J42P3YzltJOj3qKhmhjlWayJTEFVqkDCYHNXTITLlGeCqQ/ X-Received: by 2002:a17:906:c317:: with SMTP id s23mr11159581ejz.311.1591966527011; Fri, 12 Jun 2020 05:55:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591966527; cv=none; d=google.com; s=arc-20160816; b=O038OpyhSel7aoPqxh2QgJq3UD8/yC/7TB4hq1lIZ8J1FyvsSELl9hOaYPsuEeQgvl SLsl/++iBA5OiyNgSv8GryHh285Ipx7q8gHgAb19FtWJ9XSrT2d7Z5wZ40gKWJw4aOav JzLlp632qtASxPWLYP7yjeWlRX3kSPNkY2hm/KuCFRACnPo/8HralIayKCZozaSNgTv9 ykQETCjp4LnkM8/TaSc85t6hQ3GSzgZSjMJfHOVTHwc1UTijqqa9eBuHzPfgI6xBCbyJ YSFfh5a4vnYHqE4fclHM00aenIZR5VbKNadZR2J4EKV7Tyfn4b4wrHXDnlOZModw/Csr FHBw== 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=FrVjH/yBHMbUTqmRxHtYXDZcuoLyKomNCSMXXflgh9s=; b=gwNsnw6OPstNGCJkP/hNKSErxxga17c6tve2dixRaaqb11bKjS6o9YqTkqM3UhyPxm yyMuHC2tl5RHmy+hCCmz/U95LPENl5UovfBzXOXhjoMks8b2O7WzsdzOd4twwn1UHOrR agVzNbu4sx285EqiDrnyZ0mCDl3Ru7vL1ET0naKl78KmgyHL6HGBLG0MLu5LmROwHrg2 CMEDbeFxHAGgTDZxGCF2yOoePfuhA0IDsgqWSRurY1gB9rolSv1dotdlhmgpO2JtVK1t iL7H8idVIl0MErg21X3XxdtWfFST5tStWvU+g5kDBeVfE1DJBe/TrXgkYNIQIZVdy4lz nTbw== 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 g30si3435984ede.28.2020.06.12.05.55.03; Fri, 12 Jun 2020 05:55:26 -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 S1726262AbgFLMw4 (ORCPT + 99 others); Fri, 12 Jun 2020 08:52:56 -0400 Received: from foss.arm.com ([217.140.110.172]:35894 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726085AbgFLMwz (ORCPT ); Fri, 12 Jun 2020 08:52:55 -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 D4360D6E; Fri, 12 Jun 2020 05:52:54 -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 258763F6CF; Fri, 12 Jun 2020 05:52:53 -0700 (PDT) Date: Fri, 12 Jun 2020 13:52:50 +0100 From: Qais Yousef To: Douglas Anderson Cc: Benson Leung , Enric Balletbo i Serra , hsinyi@chromium.org, joelaf@google.com, peterz@infradead.org, drinkcat@chromium.org, gwendal@chromium.org, qperret@google.com, ctheegal@codeaurora.org, Guenter Roeck , linux-kernel@vger.kernel.org Subject: Re: [PATCH] cros_ec_spi: Even though we're RT priority, don't bump cpu freq Message-ID: <20200612125250.7bwjfnxhurdf5bwj@e107158-lin.cambridge.arm.com> References: <20200610151818.1.I666ecd9c6f3c6405bd75831a21001b8109b6438c@changeid> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200610151818.1.I666ecd9c6f3c6405bd75831a21001b8109b6438c@changeid> 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/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/ > }; > 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. Why can't you manage the priority and boost value of such tasks via your init scripts instead? 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. Thanks -- Qais Yousef > -- > 2.27.0.290.gba653c62da-goog >