Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp19758408ybl; Sat, 4 Jan 2020 08:28:58 -0800 (PST) X-Google-Smtp-Source: APXvYqwI5Lp688MvHfE5a+0UCdEDCudGGQB6Cf90Uk1CAnFRILdAhnqP3kduVi7lrcBhydMSXIqx X-Received: by 2002:a9d:7586:: with SMTP id s6mr104608992otk.342.1578155338015; Sat, 04 Jan 2020 08:28:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578155338; cv=none; d=google.com; s=arc-20160816; b=HQBKjBpjYwzezDw7MU5qbYGnB5UjykeokjIl+zcj2iMst3pW2l8gdOj9gB9+xyucZ+ TCFHFx33AEWA9R5zNx10q1CE1VQSX49ns4Y3BygxIMfh+24XJ6he1pmoz+VFBYR7PFc2 TsHkB+IM1dNhYt6AyhajwqABVQrrSl3EtHKqPRaM0rMZSc/KZUzsqAsAyv4+ShmLDNUm AueVR2V7G/WV+SxHxcQguDPAJ7LyxS/1wA478j2rwFY4ONguGEMqifapWiNmJwnkOpsa EGlCbdnrwJ+I7XIuExTk7em9kawJhKfgYiEWoTSrK5v6qP9+6xopM4trJ8dDICrExOQI UNZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:content-transfer-encoding :mime-version:subject:from:message-id:date:dkim-signature; bh=Le8t8L4UdoCHnVRz4xJBsRIF+gkwb+FkfJ+nFnySQWU=; b=bp5tIP/QBZmDlEL9NM4oFZrTqfrSkbtTXPhR6Ww3Wkfhxqxz9lcwuL2j9P15K0FHLR Ady6sRfm1wZcd8fWnzuFdOlpBm1lRW5PnqN9IjH3bDUby3sjC15rkLhKJQIck5xf1sXT Q+jyakUBxBzNTPsEelC24nC50Q4GUDmeyN5RguFkvcYmFAi1+Q3ZLWToqLLNuO5BWIfX nNk3sV0ugk3o9gAOcXXGd6tV7UAo1zsJbcEv6HL+lKrrCXHRZ3SHm2vSxAHpNd9dn7ue Jd/joqdEvTc7njNTlS8VTTc0C/0BbiECNY8cxW6PVBKrSQQYSt+Wo6U9UFCwo8I8C5z8 Xwyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rere.qmqm.pl header.s=1 header.b=EXfdxlNh; 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 x24si31369947oto.255.2020.01.04.08.28.44; Sat, 04 Jan 2020 08:28:58 -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=EXfdxlNh; 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 S1726135AbgADQ2C (ORCPT + 99 others); Sat, 4 Jan 2020 11:28:02 -0500 Received: from rere.qmqm.pl ([91.227.64.183]:3383 "EHLO rere.qmqm.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726004AbgADQ2C (ORCPT ); Sat, 4 Jan 2020 11:28:02 -0500 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 47qnHx6lz9zGW; Sat, 4 Jan 2020 17:27:57 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1578155279; bh=GLCJ+xn1C18+8zix7hQRYKYNNDap+S2nPn1PT1f0fAo=; h=Date:From:Subject:To:Cc:From; b=EXfdxlNhkqjQRtYM8nO5nXcAQgeOkSeHTz1Gq2GdzrL5BuaTmIpoVK/bU+FxolnXb Q/UNlWv+tg+WljGOfuiCgAxugAWpso8C6fXgm5DRMAu+3syGS1GdIBjA6eebokd7Qx bFN6TzSwrnd6ubV+l3fHAw1NfgUPbpuVYqMTfIpf+sWchUkooPebRhYUEcAGhB1X55 FOEiliVRbYVaFHRRbQgxT3aql8NHcAkBpTvVoShqLYzScy1gqCwAASVDJl2DRbUYWU L7ADjnp+dduBD13sUXL4HRk3NCJsx+4tHhJTZIpYdJkYXKhdgUk+K5uaah/qAd/bhh b4590hMWlokZg== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.101.4 at mail Date: Sat, 04 Jan 2020 17:27:57 +0100 Message-Id: From: =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= Subject: [PATCH] PM-runtime: add tracepoints for usage_count changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To: "Rafael J. Wysocki" , Len Brown , Pavel Machek , Greg Kroah-Hartman , Steven Rostedt , Ingo Molnar Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); 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); 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); out: spin_unlock_irq(&dev->power.lock); @@ -1501,6 +1508,8 @@ static void update_autosuspend(struct device *dev, int old_delay, int old_use) if (!old_use || old_delay >= 0) { atomic_inc(&dev->power.usage_count); rpm_resume(dev, 0); + } else { + trace_rpm_usage_rcuidle(dev, 0); } } diff --git a/include/trace/events/rpm.h b/include/trace/events/rpm.h index 26927a560eab..3c716214dab1 100644 --- a/include/trace/events/rpm.h +++ b/include/trace/events/rpm.h @@ -74,6 +74,12 @@ DEFINE_EVENT(rpm_internal, rpm_idle, TP_ARGS(dev, flags) ); +DEFINE_EVENT(rpm_internal, rpm_usage, + + TP_PROTO(struct device *dev, int flags), + + TP_ARGS(dev, flags) +); TRACE_EVENT(rpm_return_int, TP_PROTO(struct device *dev, unsigned long ip, int ret), -- 2.20.1