Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4272212ybi; Mon, 29 Jul 2019 22:57:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqylCm9DU8ulEhMJ4GWxfHBvVstxTvm8q/pGTy+PXltSK7bR/klgD5YrmOyh4deau+GgP8Kb X-Received: by 2002:a17:902:7c90:: with SMTP id y16mr115450445pll.238.1564466270436; Mon, 29 Jul 2019 22:57:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564466270; cv=none; d=google.com; s=arc-20160816; b=aht7KIup5sggQAZWqf5WibycNiUzC8O6/w3jSbtBpjvsITEKuiS85pAl8pysU0aapw 230Pidsve3uLE5opk2tA6kG8tKYd/+eGjAnh/VCIRfNRvUg4eau9PYLXKorNsGY1yzHU ydGRgusTNJUSvofQneYHtIohaPuxsdaj+UFtPq9HOk8HZzezlRL62YSX3i9J/9TcEqD+ fuar66kJUZMa2xJwFlxOurQLzmge9WPrFqHXMlu5HqAYEURvm64iluVs0F6U0JLjzuGO fMK6vFq96Ji+7+ru512iaKGtetpFv6ymiqdP72o9O83apkpQVlkziewldER0vlaAVFpv EvcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=jMOUaXgENhw7c5CQJ0IlirbOeRGGcqxTZWNVzp5Nhn4=; b=XRZuUt8/8r4hrDgvJOhmjfJYHwxMT8lXbMjwvfeQipM6pCK03/FR6XKH9dZy725hjE Y09VtwltlNySo53FY0JB25DNwT41RN+nUCpqEzm3oh5V93DmiRH3uH17B2pEQYIY4TPx l0jVJfmPvflEYZ/5DPtmCuDonxg6WAb2F6qR/HMPtbvecuOPhj9AoM8kZCfR/BA4guYM CUHXNkqYlFJhxEUd7fVEX+snz+OBb/FmmxJbBTfEoPdSXxm/d9lEMJYZtWibdcyc/ZmC qEwUARPqHUQdhIzEPrj5gn4F1LXTwTeWk/LnqITAofoE054eCcOxAxUinTNeyXwYUHy7 UsDA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t5si24539847plr.124.2019.07.29.22.57.36; Mon, 29 Jul 2019 22:57:50 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727005AbfG3Fqy (ORCPT + 99 others); Tue, 30 Jul 2019 01:46:54 -0400 Received: from mail-ot1-f67.google.com ([209.85.210.67]:38944 "EHLO mail-ot1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726197AbfG3Fqx (ORCPT ); Tue, 30 Jul 2019 01:46:53 -0400 Received: by mail-ot1-f67.google.com with SMTP id r21so59031707otq.6; Mon, 29 Jul 2019 22:46:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=jMOUaXgENhw7c5CQJ0IlirbOeRGGcqxTZWNVzp5Nhn4=; b=eAcaiU13snkUCtWd2P4Bam8po4kmlLaZ92dQM2chr0Z7NtiXhIYj+j1LdY5rKHNKfw KCFHcRjbp6XsUKhy0M94CxPb8VAPsG62WXCQpDvoZ8DgI1ft6rRegaiGDjY7aZewF7E1 Qih45PrTN2W2I0u9jCLrY7aSQ/SWDBraUVJ3/890MIzrE1IHT7lnBMXwW6P2skryKM46 S9F7pNHyj+/G0G4dKhIRxO33xP611teS8eP8EUHpRY66Y9LFbcYMeDALxl3hjTjehhJR d81Aslnd093q6CQjC92GM4hyFKb1YSSWJSbRvNLYS2AWAtp9jihPEwAUy5M75nNgT7ov D/6w== X-Gm-Message-State: APjAAAVaK6TYtw/u8gcPrehyUVQ+qbeo8frmOmYZoPBDyw4FUoy4yDdF LNVYkpE064FFDI5wlVxHLtmagOlBiJOkF37BsTw= X-Received: by 2002:a05:6830:1516:: with SMTP id k22mr78953797otp.189.1564465612966; Mon, 29 Jul 2019 22:46:52 -0700 (PDT) MIME-Version: 1.0 References: <20190730024309.233728-1-trong@android.com> In-Reply-To: <20190730024309.233728-1-trong@android.com> From: "Rafael J. Wysocki" Date: Tue, 30 Jul 2019 07:46:44 +0200 Message-ID: Subject: Re: [PATCH v5] PM / wakeup: show wakeup sources stats in sysfs To: Tri Vo Cc: "Rafael J. Wysocki" , Greg Kroah-Hartman , Viresh Kumar , "Rafael J. Wysocki" , Hridya Valsaraju , Sandeep Patil , Kalesh Singh , Ravi Chandra Sadineni , Stephen Boyd , Linux Kernel Mailing List , Linux PM , "Cc: Android Kernel" , kbuild test robot Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 30, 2019 at 4:45 AM Tri Vo wrote: > > Userspace can use wakeup_sources debugfs node to plot history of suspend > blocking wakeup sources over device's boot cycle. This information can > then be used (1) for power-specific bug reporting and (2) towards > attributing battery consumption to specific processes over a period of > time. > > However, debugfs doesn't have stable ABI. For this reason, create a > 'struct device' to expose wakeup sources statistics in sysfs under > /sys/class/wakeup/wakeup/*. > > Co-developed-by: Greg Kroah-Hartman > Signed-off-by: Greg Kroah-Hartman > Co-developed-by: Stephen Boyd > Signed-off-by: Stephen Boyd > Signed-off-by: Tri Vo > Tested-by: Tri Vo > Tested-by: Kalesh Singh > Reported-by: kbuild test robot > --- > Documentation/ABI/testing/sysfs-class-wakeup | 76 +++++++++ > drivers/acpi/device_pm.c | 3 +- > drivers/base/power/Makefile | 2 +- > drivers/base/power/wakeup.c | 21 ++- > drivers/base/power/wakeup_stats.c | 171 +++++++++++++++++++ > fs/eventpoll.c | 4 +- > include/linux/pm_wakeup.h | 15 +- > kernel/power/autosleep.c | 2 +- > kernel/power/wakelock.c | 10 ++ > kernel/time/alarmtimer.c | 2 +- > 10 files changed, 294 insertions(+), 12 deletions(-) > create mode 100644 Documentation/ABI/testing/sysfs-class-wakeup > create mode 100644 drivers/base/power/wakeup_stats.c > > v2: > - Updated Documentation/ABI/, as per Greg. > - Removed locks in attribute functions, as per Greg. > - Lifetimes of struct wakelock and struck wakeup_source are now different due to > the latter embedding a refcounted kobject. Changed it so that struct wakelock > only has a pointer to struct wakeup_source, instead of embedding it. > - Added CONFIG_PM_SLEEP_STATS that enables/disables wakeup source statistics in > sysfs. > > v3: > Changes by Greg: > - Reworked code to use 'struct device' instead of raw kobjects. > - Updated documentation file. > - Only link wakeup_stats.o when CONFIG_PM_SLEEP_STATS is enabled. > Changes by Tri: > - Reverted changes to kernel/power/wakelock.c. 'struct device' hides kobject > operations. So no need to handle lifetimes in wakelock.c > > v4: > - Added 'Co-developed-by:' and 'Tested-by:' fields to commit message. > - Moved new documentation to a separate file > Documentation/ABI/testing/sysfs-class-wakeup, as per Greg. > - Fixed copyright header in drivers/base/power/wakeup_stats.c, as per Greg. > > v5: > - Removed CONFIG_PM_SLEEP_STATS > - Used PTR_ERR_OR_ZERO instead of if(IS_ERR(...)) + PTR_ERR, reported by > kbuild test robot > - Stephen reported that a call to device_init_wakeup() and writing 'enabled' to > that device's power/wakeup file results in multiple wakeup source being > allocated for that device. Changed device_wakeup_enable() to check if device > wakeup was previously enabled. > Changes by Stephen: > - Changed stats location from /sys/class/wakeup//* to > /sys/class/wakeup/wakeup/*, where ID is an IDA-allocated integer. This > avoids name collisions in /sys/class/wakeup/ directory. > - Added a "name" attribute to wakeup sources, and updated documentation. > - Device registering the wakeup source is now the parent of the wakeup source. > Updated wakeup_source_register()'s signature and its callers accordingly. And I really don't like these changes. Especially having "wakeup" twice in the path. Couldn't you find a simpler way to avoid the name collisions?