Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp21307828ybl; Mon, 6 Jan 2020 02:01:05 -0800 (PST) X-Google-Smtp-Source: APXvYqzzZNRLybnIqkg4c61uM/caemZjUH9H9seHiOSnBAnu/HvE0kh7QVLkrO5ReMLsqo4PGNhO X-Received: by 2002:a05:6830:4a4:: with SMTP id l4mr115876315otd.91.1578304864490; Mon, 06 Jan 2020 02:01:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578304864; cv=none; d=google.com; s=arc-20160816; b=DmLi1kFWhH4OlJr7XB3/0QFlOY8MLTYKYzjaRTRKsxy0xEQuC+i1+wM9YvvbtFGXi2 6g8n/pE0giDSccW4f3gXQJmBvP1zh0/BeScJpYObmPDqJVS3DgDuZ1vgPEXk89OPjaZc Su2Jqx/uPWvyGJeXMniERrcNjsq2P4oHG5qP01ECkdMgkwHApUCi7XGc/j0qkrFIG1sA 5EWycAlcP+xV7s8KG3zv2wDLkH5mJM5EG9/Bp2ZZgHtlbWU5l3l2kOYr5xfNqx19DteJ RiatdL775hFgZ8hytqSNrzkJ81dJlefhXUb49t8emgcFbPVuF19AEeYkucrn3P2HqADt KXtg== 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=R7RqsEDqb2ql5J27DD/h+d/bgW8bH918qBkeaQVjyjA=; b=Js9VrgRZaORKOTLoaX9kFk8a0A3xCwfV4wxhcAX6nXXrWmpyLluQJ0OOSLb6p6XD7s dMlCanYHcHRjfIb1IYXS+gFXHe32LZYFiRYr948tVJ9RIc4ZUbsU/GmLowZtdsS+XoRt F9miikF9qqXf4GysCicXqnNABodfMDFA0PiGi2FHB4Y/6yT3R6qHcUXZ4W+3nalgGc/+ aufB6XuR1rpbnmsuRU3W/Rl5zwbul7wbi0YFtUuHUzkWemjEoS0DNTXlZ3pe/JuY+Yoy +bArV0tmZSf008wM/cKq6ex8UDtIuwF5kuX7SvBLDuARhvruckGkS0c7b//peyMyuCL+ c86A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rere.qmqm.pl header.s=1 header.b=SQSRAtim; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z10si36495268oto.36.2020.01.06.02.00.51; Mon, 06 Jan 2020 02:01: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=@rere.qmqm.pl header.s=1 header.b=SQSRAtim; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726292AbgAFKAL (ORCPT + 99 others); Mon, 6 Jan 2020 05:00:11 -0500 Received: from rere.qmqm.pl ([91.227.64.183]:58440 "EHLO rere.qmqm.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725446AbgAFKAL (ORCPT ); Mon, 6 Jan 2020 05:00:11 -0500 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 47rrbW64m1zV6; Mon, 6 Jan 2020 11:00:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1578304808; bh=cL4mF1jHUeGe0pKz/0D4gMOsnENC81lNvvo2kdmArbw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=SQSRAtimoT4S5oqIEhtwVHIDIIABk1PQ+gDFywwA12mVBxFRczNTPkaAVOfE3ufl9 L3RIGEGymoOXMqIelWI+HgGTlo1tSmjBaF6zL8sBarb/8EqOcqC3c4Ek45kH9eEo0V zvLNihcBDd0dE7h0G/k7j1iFKP9Vc2Hbt3GKqjUt0CeZypoxOnm+HVbPS0r5y2XSwm YdmfgMAK+ZclPu0b52QY6ekXCCopqoKk0jPQl6AsgRtxQELwtc31nTeXpQujcCOR6a ExD7P1+Ri/LBqJCZ9U5sGe1Nh8jdFaat+iG86csKydya9ziBgCzYXal0U9ndRyUjQS jmKoMoJwdhxtw== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.101.4 at mail Date: Mon, 6 Jan 2020 11:00:04 +0100 From: =?iso-8859-2?Q?Micha=B3_Miros=B3aw?= To: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" , Len Brown , Pavel Machek , Steven Rostedt , Ingo Molnar , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] PM-runtime: add tracepoints for usage_count changes Message-ID: <20200106100004.GA10946@qmqm.qmqm.pl> References: <20200104182123.GA1485543@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-2 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200104182123.GA1485543@kroah.com> 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 On Sat, Jan 04, 2020 at 07:21:23PM +0100, Greg Kroah-Hartman wrote: > On Sat, Jan 04, 2020 at 05:27:57PM +0100, Micha? Miros?aw wrote: > > Add tracepoints to remaining places where device's power.usage_count > > is changed. This helps debugging where and why autosuspend is prevented. > > > > Signed-off-by: Micha? Miros?aw > > --- > > drivers/base/power/runtime.c | 13 +++++++++++-- > > include/trace/events/rpm.h | 6 ++++++ > > 2 files changed, 17 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c > > index 48616f358854..16134a69bf6f 100644 > > --- a/drivers/base/power/runtime.c > > +++ b/drivers/base/power/runtime.c > > @@ -1006,8 +1006,10 @@ 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)) > > + if (!atomic_dec_and_test(&dev->power.usage_count)) { > > + trace_rpm_usage_rcuidle(dev, rpmflags); > > Who and what is really going to use these tracepoints? > > And putting them in these if statements seems odd, are you sure that's > the correct place? What do these show to userspace? > > > return 0; > > + } > > } > > > > might_sleep_if(!(rpmflags & RPM_ASYNC) && !dev->power.irq_safe); > > @@ -1038,8 +1040,10 @@ int __pm_runtime_suspend(struct device *dev, int rpmflags) > > int retval; > > > > if (rpmflags & RPM_GET_PUT) { > > - if (!atomic_dec_and_test(&dev->power.usage_count)) > > + if (!atomic_dec_and_test(&dev->power.usage_count)) { > > + trace_rpm_usage_rcuidle(dev, rpmflags); > > return 0; > > + } > > } > > > > might_sleep_if(!(rpmflags & RPM_ASYNC) && !dev->power.irq_safe); > > @@ -1101,6 +1105,7 @@ int pm_runtime_get_if_in_use(struct device *dev) > > retval = dev->power.disable_depth > 0 ? -EINVAL : > > dev->power.runtime_status == RPM_ACTIVE > > && atomic_inc_not_zero(&dev->power.usage_count); > > + trace_rpm_usage_rcuidle(dev, 0); > > Why this one? > > > > spin_unlock_irqrestore(&dev->power.lock, flags); > > return retval; > > } > > @@ -1434,6 +1439,8 @@ void pm_runtime_allow(struct device *dev) > > dev->power.runtime_auto = true; > > if (atomic_dec_and_test(&dev->power.usage_count)) > > rpm_idle(dev, RPM_AUTO | RPM_ASYNC); > > + else > > + trace_rpm_usage_rcuidle(dev, RPM_AUTO | RPM_ASYNC); > > Are you sure this is correct? > > These feel odd... This covers all places where power.usage_count might have changed. If atomic_dec_and_test() decrements usage_count but not to zero, the new value will be traced in rpm_idle(). But if the value drops to zero, then we need to trace it explicitly to be able to have all changes accounted for in the trace. I actually used this patch to track down why USB storage device was not autosuspending correctly. Best Regards, Micha? Miros?aw