Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp2002524ybi; Thu, 4 Jul 2019 03:32:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqxK+Q7r6nMbFmIvbzrqM2feuFiPsHKt/WeWthiv6L9u7gJ9o3jU6dhXxN9inkcOU44QqrPr X-Received: by 2002:a63:24c1:: with SMTP id k184mr12209615pgk.120.1562236355285; Thu, 04 Jul 2019 03:32:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562236355; cv=none; d=google.com; s=arc-20160816; b=aZabYc8iqZ5jdfMEPZWkG1Ua8pibsTqYx+lWmenzJMTsX/CFhC/6qdHyrX3FKL2g3P onfa4/Mn7jW0ozvesc9knhD9mydITbtUyHMQflj1/ZHCYSvarMnlXSKXu8EbYar1r7ax r/UJmKXCDwCs01pkt8QELec6XpmG0uHJl85EajNnWUuMhi9/byA1icx2MoNSrMjuRiEp B+gDKjNcIgH7CYP4hZaqeI0O4yJ9FgxqkoHJQGs34rlI+dYMcP2oUY9wNoASU3TfJqrR i35Ud3FeMLWq6CSkbXjgwXZMfctgPfSff4QefnWI7Ec2DNH6yE1bCG25NVHwLBUJy0Jy K5rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Z+I2Q+MNa8Ppm5dqFxQhjkLRJndHcMSyTS7jmgCLsds=; b=PP0XWmc5mJDgNzDDVjwZzTfuJfX1rq7ORkYgL769v01mP9CrxfwB/aNvUvrX6KLYjI NOEeU0t546Tz3srS6rEJFgTAyA0Hu6TU38NsBrWsrlvQ7/MYV6KPqMHOHrTUFRtEJIi6 qWx6426VLPSVF1WRP4xwU09egbCuYAn7XgNbho5qxerqtVwbCQVz2l1WZpZSEH6F7AgV ruiJsfZKmzOrBVH4rYfOBtAJJLB1qI+DuMNs6od2KAFAfSdeGEJ20mVjZ3lQm/yctcXJ NS85uZG5O2Um43NA08VIq9mWSdiKeKE/SCxYvLPOV5tC05s+WwAHaYpPtiKGgzhVcVbT tpMA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s11si4938641pgp.326.2019.07.04.03.32.19; Thu, 04 Jul 2019 03:32:35 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727576AbfGDKb2 (ORCPT + 99 others); Thu, 4 Jul 2019 06:31:28 -0400 Received: from cloudserver094114.home.pl ([79.96.170.134]:47330 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727303AbfGDKb1 (ORCPT ); Thu, 4 Jul 2019 06:31:27 -0400 Received: from 79.184.254.216.ipv4.supernova.orange.pl (79.184.254.216) (HELO kreacher.localnet) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.267) id 8f56e755e5c9ce7d; Thu, 4 Jul 2019 12:31:25 +0200 From: "Rafael J. Wysocki" To: Greg KH Cc: Tri Vo , viresh.kumar@linaro.org, rafael@kernel.org, hridya@google.com, sspatil@google.com, kaleshsingh@google.com, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, kernel-team@android.com Subject: Re: [PATCH v2] PM / wakeup: show wakeup sources stats in sysfs Date: Thu, 04 Jul 2019 12:31:24 +0200 Message-ID: <3451189.hAX5mKGt1u@kreacher> In-Reply-To: <20190628151040.GA14074@kroah.com> References: <20190627000412.GA527@kroah.com> <20190627225335.72107-1-trong@android.com> <20190628151040.GA14074@kroah.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Friday, June 28, 2019 5:10:40 PM CEST Greg KH wrote: > On Thu, Jun 27, 2019 at 03:53:35PM -0700, 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, expose wakeup > > sources statistics in sysfs under /sys/power/wakeup_sources// > > > > Embedding a struct kobject into struct wakeup_source changes lifetime > > requirements on the latter. To that end, change deallocation of struct > > wakeup_source using kfree to kobject_put(). > > > > Change struct wakelock's wakeup_source member to a pointer to decouple > > lifetimes of struct wakelock and struct wakeup_source for above reason. > > > > Introduce CONFIG_PM_SLEEP_STATS that enables/disables showing wakeup > > source statistics in sysfs. > > > > Signed-off-by: Tri Vo > > Ok, this looks much better, but I don't like the use of a "raw" kobject > here. It is much simpler, and less code, to use 'struct device' > instead. > > As proof, I reworked the patch to do just that, and it saves over 50 > lines of .c code, which is always nice :) Thanks for taking the time to do that! > Attached below is the reworked code, along with the updated > documentation file. It creates devices in a virtual class, and you can > easily iterate over them all by looking in /sys/class/wakeup/. That actually is nice - no need to add anything under /sys/power/. > Note, I'm note quite sure you need all of the changes you made in > kernel/power/wakelock.c when you make the structure contain a pointer to > the wakeup source and not the structure itself, but I just went with it > and got it all to build properly. I'm not really sure about it either. > Also note, I've not actually tested this at all, only built it, so I > _strongly_ suggest that you test this to make sure it really works :) > > What do you think? I agree with the direction. :-) Cheers!