Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp295797ybh; Wed, 15 Jul 2020 02:07:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZq5Ld/VtrPWp/mQtUwFWiL4GAiZWIlrwAYoa8JHeg0TTdCHcj46O5g+278N/6NqETMnib X-Received: by 2002:a17:906:8392:: with SMTP id p18mr8851367ejx.24.1594804046088; Wed, 15 Jul 2020 02:07:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594804046; cv=none; d=google.com; s=arc-20160816; b=kdtI7Gh0+Tz6M3v4wNiE+kDPaYnbuflq0ZghSBcYg4POwudXbW5nchRlDfYVAn6kc2 Aq1/x2gj5yLlYUgDaS21P01wuR9oh/bw+sbyN0sDt8z/Zr+mArXtZqS4y/luQi2Y4E+r 0bnbMkNB2NanPLGcPoy9rhYvueZRXuyIKOrI2AD/o+J6DijIzibGpCZBm5LwyKCOSHde mwtIx1Dq6iS1oeGNGYVXlYw5b8MuVxYrU/gg1Kaip+9SYsWREHQZi9iazHjkKetK9Aam 2Srvbd4VF2r+s8edTl8CA0wI2eNx228pf9vZUbEHqoWt5BEPt4PensSmI+AQN2rqG9xg Lu7Q== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=zB4G98l05s+h/0DSmeqWcCkIMn540OVYRMaaCDO4yoQ=; b=gBghcSRHbdaxSKh/oOe6w2irZIIUIrBsJOnBCu600Yil5O/27cMIB6E9QP/t3gtzPs a5uXoEpE+bmJENv+5dIXuP1hhUmKrMpaM0KgKhQubxOzfMD6M6ox0CJEKYTnLXWfxNkC XnMoYcEaFd8emw106dEsqFEXGMcmNsI1xbNzuTNTS5ZVz+q5+p8vQoU2fFprbD9qrTHF tWlZ/jq9Uznz7tYDm734oGAVt2x2S0cKiB4H05t3Rr0GTgego5Pgnzl4RrMnRT6Au6kK gwIwElMCVlKNbUhGrKPMGNKrxmyGrND8GiX2yQgfqEGGbdyp6jV98gZcFKUoAC3rM0VB RkMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PTE7YLDe; 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 i21si841717edb.402.2020.07.15.02.07.02; Wed, 15 Jul 2020 02:07: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; dkim=pass header.i=@kernel.org header.s=default header.b=PTE7YLDe; 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 S1730132AbgGOId1 (ORCPT + 99 others); Wed, 15 Jul 2020 04:33:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:40308 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726034AbgGOId1 (ORCPT ); Wed, 15 Jul 2020 04:33:27 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0AB1C20672; Wed, 15 Jul 2020 08:33:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594802006; bh=iOVN0Aj56V7pWppvWBvshuC3/3Wx6PjHbGrnZyydSO0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=PTE7YLDehLY6msegiqFCDsJCkrKstPFQEli4wDa+DYQ0plMqvlHJ00vUMOzOrJCY/ 05CVC2ZuBA3YF5UVB395FVbgyOFuFxd2c+C3Gb9/pHpjTpCyPYcjbchaOybNvNF9Nr 0hAr7IDZ08YHAOgkmGdtM567MY6dwVdj2gl/4Ae4= Date: Wed, 15 Jul 2020 10:33:22 +0200 From: Greg Kroah-Hartman To: Chen Yu Cc: "Rafael J. Wysocki" , Len Brown , Michal Miroslaw , Zhang Rui , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2][RESEND v3] PM-runtime: change the tracepoints to cover all usage_count Message-ID: <20200715083322.GB2716443@kroah.com> References: <395187057e486df9a4328bc6d7d4ee912967fdb3.1594790493.git.yu.c.chen@intel.com> <20200715070614.GA2297388@kroah.com> <20200715081838.GA22379@chenyu-office.sh.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200715081838.GA22379@chenyu-office.sh.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 15, 2020 at 04:18:38PM +0800, Chen Yu wrote: > Hi Greg, > thanks very much for taking a look, > On Wed, Jul 15, 2020 at 09:06:14AM +0200, Greg Kroah-Hartman wrote: > > On Wed, Jul 15, 2020 at 02:28:03PM +0800, Chen Yu wrote: > > > Commit d229290689ae ("PM-runtime: add tracepoints for usage_count changes") > > > has added some tracepoints to monitor the change of runtime usage, and > > > there is something to improve: > > > 1. There are some places that adjust the usage count not > > > been traced yet. For example, pm_runtime_get_noresume() and > > > pm_runtime_put_noidle() > > > 2. The change of the usage count will not be tracked if decreased > > > from 1 to 0. > > > > > > This patch intends to adjust the logic to be consistent with the > > > change of usage_counter, that is to say, only after the counter has > > > been possibly modified, we record it. Besides, all usage changes will > > > be shown using rpm_usage even if included by other trace points. > > > And these changes has helped track down the e1000e runtime issue. > > > > > > Reviewed-by: Michał Mirosław > > > Signed-off-by: Chen Yu > > > --- > > > drivers/base/power/runtime.c | 38 +++++++++++++++++++++++------------- > > > 1 file changed, 24 insertions(+), 14 deletions(-) > > > > > > diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c > > > index 85a248e196ca..5789d2624513 100644 > > > --- a/drivers/base/power/runtime.c > > > +++ b/drivers/base/power/runtime.c > > > @@ -1004,10 +1004,11 @@ int __pm_runtime_idle(struct device *dev, int rpmflags) > > > int retval; > > > > > > if (rpmflags & RPM_GET_PUT) { > > > - if (!atomic_dec_and_test(&dev->power.usage_count)) { > > > - trace_rpm_usage_rcuidle(dev, rpmflags); > > > + bool non_zero = !atomic_dec_and_test(&dev->power.usage_count); > > > + > > > + trace_rpm_usage_rcuidle(dev, rpmflags); > > > > Why not just call trace everywhere before you do the atomic operations? > > Why does the trace need to be called after the operation everywhere? > > > If I understand correctly, besides Michal's comments, if we put the trace > before the atomic operation, we might be unable to judge whether the counter > is going to increase or decrease from rpmflags: it is RPM_GET_PUT which combine > the get() and put() together, then it is a little inconvenient for tracking IMO. A trace can never know the exact value of an atomic value as it could change right before or after the trace function is called, right? So why are you caring about that? Care about the functionality that is happening, not a reference count that you do not control at all. thanks, greg k-h