Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp147861imj; Thu, 14 Feb 2019 17:22:04 -0800 (PST) X-Google-Smtp-Source: AHgI3Ibw1SWdxh9gDKWE4K1OfgfT1At7SBctzw2XZjQjzOKU7CSsLWn18buu0oMBhbycqs7aZ0Jb X-Received: by 2002:a63:354a:: with SMTP id c71mr2855551pga.150.1550193724323; Thu, 14 Feb 2019 17:22:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550193724; cv=none; d=google.com; s=arc-20160816; b=v6QLf4FDZrpTMB/KabCYF08G5nB0C9pPz+cIII9WI9bsaIjCad5oytmln/HoeLN7Cm ORhSw6mfHfIFmaHIlJTD8hvoZZFqUSDyrmHEWg/fVvfheVJnm1ZzN7cQ5enSD57u+aiV WrCBAhbLtS9D0Dg0Phk+ZlzBHiaxx244z7lTtSYYy9/Rwl44yLHweF9+ynoztESKv73A CA9TXZrJnSKS7JIrdwMShj+dgJm+/t52lia+iovYUDRzoVYtWeQY6LmAlvSCSyMJSzHJ SSEiZ5WsJzsCe5SpQKOkkGDGv0mXtwHgIONTTZF84ug7dGsxcZmEkfe7R6dBj+0mm5qx a0Eg== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=0t1v1OuKZbxtqvHBYBeHW8maDqWGT55mJUN35OAsXkA=; b=Rx9nZXGGRDl+VVqw9ugPl7l1y20ieO2gSJuHf40q5+xlVUm092dgraR3Qq1agzxRRn opV/IVnZo7+LGaJ36kfBKi/eon03oA5QKHdgkWTzglv3Czj+ZAItihxV1WlaOCvvAqDg NEqpPqLSdHv1gcoyBlNwYC6pCs0rZnt9/WosMMiAGkgXgoDYTpgSF+VKZHT5Jvn7Wh7Y LnpuWYF0DpszQ9VErEhx+coa8Wn1ipA4SDt4Rh+fvucEOVyURsuX1UEopGSqu1Maj9ET b8cp7R1GGII3h+VH+ru+Pb931DtijcewldBTWRWA/2fycuAVhcRXmJeHDYt3raFk4hAu fCww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=j9dhbMbx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r10si311389pgk.234.2019.02.14.17.21.47; Thu, 14 Feb 2019 17:22:04 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=j9dhbMbx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405677AbfBNRrW (ORCPT + 99 others); Thu, 14 Feb 2019 12:47:22 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:46190 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392765AbfBNRrW (ORCPT ); Thu, 14 Feb 2019 12:47:22 -0500 Received: by mail-pl1-f193.google.com with SMTP id o6so3508097pls.13 for ; Thu, 14 Feb 2019 09:47:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=0t1v1OuKZbxtqvHBYBeHW8maDqWGT55mJUN35OAsXkA=; b=j9dhbMbxxkZcqdkzc2916PHF6QFB6wAvgmcouEUSD/NxCOJOlStMkTnoxOIl3GLUzF L5OGlo80wAkIVsInv2aAw1EpmgGGLfElnticrZ1JAjbNsHWFaVUAukaf3owSYBB820nx O4mm0gr5R6ptEfLsJmoj1Z9ErbKX/wPkiuAtw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=0t1v1OuKZbxtqvHBYBeHW8maDqWGT55mJUN35OAsXkA=; b=jhaC/jxjpCAu6pseRN3vBSqveUJG7aKsaUrgcN/wnBD47iC4P5ojFvg7yJ1LKui8yj KfubOLv3oi8MX54JDl7+bC0p/8QXAAmpPGndyyzjV2rlNvGMuF5Ce75jLWRb0cve64Jf gzAAACEPGJosTrjvetcj5CcO4aLyzO6QFdQPgctr7bcYPlf+vDfMwlC39oNMa3HSyC5r Jy87Ny6oW3/rJg8lR9PYJBpDtYJk3I2yxj5PPUc1jW1aYSdxd7SPRS2IrrhMvbCdxaEb 1qFHzCcUh53fV2BD6LNQgSQdh2b2sXizVc82KwPZT9Qv0TrHDjXLKeGN4iXgrUfPXk5b MMdA== X-Gm-Message-State: AHQUAuauGaTBTBxoE2eAr1afGc4KEb2QHaBn3cgR3x8dMsN9ybdnT3Pc GmBYa4N6ceZ1L75OCAS5yrKwzw== X-Received: by 2002:a17:902:64:: with SMTP id 91mr5569509pla.229.1550166441213; Thu, 14 Feb 2019 09:47:21 -0800 (PST) Received: from localhost ([2620:15c:202:1:75a:3f6e:21d:9374]) by smtp.gmail.com with ESMTPSA id b9sm4184559pfi.118.2019.02.14.09.47.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 14 Feb 2019 09:47:20 -0800 (PST) Date: Thu, 14 Feb 2019 09:47:19 -0800 From: Matthias Kaehlcke To: Chanwoo Choi Cc: MyungJoo Ham , Kyungmin Park , Chanwoo Choi , Thierry Reding , Jonathan Hunter , Linux PM list , linux-kernel , linux-tegra@vger.kernel.org, Lukasz Luba Subject: Re: [PATCH 2/4] PM / devfreq: Handle monitor suspend/resume in the devfreq core Message-ID: <20190214174719.GZ117604@google.com> References: <20190214013042.254790-1-mka@chromium.org> <20190214013042.254790-3-mka@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Chanwoo, On Thu, Feb 14, 2019 at 11:10:00PM +0900, Chanwoo Choi wrote: > Hi Matthias, > > 2019년 2월 14일 (목) 오후 7:16, Matthias Kaehlcke 님이 작성: > > > > devfreq expects governors to call devfreq_monitor_suspend/resume() > > in response to DEVFREQ_GOV_SUSPEND/RESUME events. Since the devfreq > > core itself generates these events and invokes the governor's event > > handler the suspend/resume of the load monitoring can be done in the > > common code. > > > > Call devfreq_monitor_suspend/resume() when the governor reports a > > successful handling of DEVFREQ_GOV_SUSPEND/RESUME and remove these > > calls from the simpleondemand and tegra governors. Make > > devfreq_monitor_suspend/resume() static since these functions are now > > only used by the devfreq core. > > The devfreq core generates the all events including > DEVFREQ_GOV_START/STOP/INTERVAL. > It is possible to make 'devfreq_monitor_*()' function as the static > instead of exported function. > And call them in devfreq.c as this patch as following: > > --- a/drivers/devfreq/devfreq.c > +++ b/drivers/devfreq/devfreq.c > @@ -728,6 +728,8 @@ struct devfreq *devfreq_add_device(struct device *dev, > goto err_init; > } > > + devfreq_monitor_start(devfreq); > + > list_add(&devfreq->node, &devfreq_list); > > mutex_unlock(&devfreq_list_lock); > @@ -760,6 +762,7 @@ int devfreq_remove_device(struct devfreq *devfreq) > if (devfreq->governor) > devfreq->governor->event_handler(devfreq, > DEVFREQ_GOV_STOP, NULL); > + devfreq_monitor_stop(devfreq); > device_unregister(&devfreq->dev); > > return 0; > @@ -1259,6 +1262,9 @@ static ssize_t polling_interval_store(struct device *dev, > df->governor->event_handler(df, DEVFREQ_GOV_INTERVAL, &value); > ret = count; > > + if (!ret) > + devfreq_interval_update(devfreq, (unsigned int *)data); > + > return ret; > } > static DEVICE_ATTR_RW(polling_interval); > diff --git a/drivers/devfreq/tegra-devfreq.c b/drivers/devfreq/tegra-devfreq.c > index 79efa1e..515fb85 100644 > --- a/drivers/devfreq/tegra-devfreq.c > +++ b/drivers/devfreq/tegra-devfreq.c > @@ -580,13 +580,11 @@ static int tegra_governor_event_handler(struct > devfreq *devfreq, > > switch (event) { > case DEVFREQ_GOV_START: > - devfreq_monitor_start(devfreq); > tegra_actmon_enable_interrupts(tegra); > break; > > case DEVFREQ_GOV_STOP: > tegra_actmon_disable_interrupts(tegra); > - devfreq_monitor_stop(devfreq); > break; indeed, that's similar to "[4/4] PM / devfreq: Handle monitor start/stop in the devfreq core" of this series. > Instead, > > If the governor should execute some codes before and after of > DEVFREQ_GOV_SUSPEND, DEVFREQ_GOV_RESUME, > it is impossible to change the order between devfreq_monitor_*() function > and the specific governor in the event_handler callback function of > each governor. > > For example, if some govenor requires the following sequencue, > after this patch, it is not possible. > > case DEVFREQ_GOV_SUSPEND: > /* execute some code before devfreq_monitor_suspend() */ > devfreq_monitor_suspend() > /* execute some code after devfreq_monitor_suspend() */ I agree that the patch introduces this limitation, however I'm not convinced it is a problem in practice. For suspend we'd essentially end up with: governor_suspend governor->suspend monitor_suspend update_status stop polling What would a governor want to do after polling is stopped? Is there any real world or halfway reasonable hypothetical example? And for resume: governor_resume governor->resume monitor_resume start polling Same question here, what would the governor realistically want to do after polling has started that it couldn't have done before? Cheers Matthias