Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp416400ybi; Wed, 19 Jun 2019 01:36:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqzwQmqwivITDTXkCCZ9IX6pqwxcccXQ/ypBSC4ueSuTkEvnFASLQOX4D/zLfDFr0jKi+twD X-Received: by 2002:a65:42cd:: with SMTP id l13mr6581997pgp.72.1560933369330; Wed, 19 Jun 2019 01:36:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560933369; cv=none; d=google.com; s=arc-20160816; b=Suuhf/NVaNKCsxtO8lmVj8de7E/Wd6D7oZwx277+BSkTq+/UVRyHkL5urcKikVqsnQ JdID1WebI7KmKwjEPb//724caOVMJpqKdMkKi3Z96C4oqrvwZPf8na5GC5jmkNP+PTvc sjegQ9wQmw3fZmNqNWGKJTW4eWHm1mpGYA76wDK4vfbMybeOWzr3dCYvXTlOCfC0y7Vv Ga1xhjUvx+O15PWTFLZSxLPbHiMGv4S+VNQSJHYXEoWNZ+bm1pF6O1Wve0bqfdHS31l/ t3pBn6y5w0sS8OKTTv3AncmyMlc6kccs/GNGPfD9OoeZ0EfsD34qFjEwy/yvywuviF+U IWJw== 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=K+aGgdCq18WEu7EQPUxRISqQBQ1QUiTsnK0wg2Fi8nU=; b=dTl6xSd/DXDlgAIjXDiCrqD5IZBQWMWo0o+E5Gh4MqqX/RKIbU/UDpnDJYp6f8yUCl qx3UWZj2qWQy9u+ml+AgNfehlDPmMKQdV+/QIKyCKSY6cE0juaq6IpMM3NcDA3mYGGUx ES7Om8/4VmRhQuh+lPCTlbZc6HMC2zONe08c47kqahA9XnppUyu4WrfZUpTGECxSN9B/ h7Ucg0RlmHdPhtmws5rV7YtECbGAdsbUoBqqS6Cpn/OQ1zAZRO9+H/trQzvkzZInP9jj /+UpKJHppncOU9f9gEfu2vu4ab7G8TDlzUG57WfBRsjl3ERzLeeqCGKPUj2Ix9+v3/Qn EcDQ== 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 i3si784943pld.357.2019.06.19.01.35.53; Wed, 19 Jun 2019 01:36:09 -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 S1731310AbfFSIfa (ORCPT + 99 others); Wed, 19 Jun 2019 04:35:30 -0400 Received: from mail-ot1-f66.google.com ([209.85.210.66]:37014 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730783AbfFSIfa (ORCPT ); Wed, 19 Jun 2019 04:35:30 -0400 Received: by mail-ot1-f66.google.com with SMTP id s20so18459269otp.4; Wed, 19 Jun 2019 01:35:30 -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=K+aGgdCq18WEu7EQPUxRISqQBQ1QUiTsnK0wg2Fi8nU=; b=AZeWNQC1MMLPIbILx9t/S0XkvKEQxXoS8SKx/GQTaxWYq9yXFYJXKwPmYSlda158Ql EPWu0P4Whdd72zAufciBzlwIydT7HLJ57c5kpCG46SCw7LiF4YfqoUFoqGvVuEJ+s4ki +umc7JOasatoxYt6H1o9jAYv3wu1gZtdP9XbsPhrbfrgExUBp7vQReYr5njYUDAD6fVy JNXcqFZJp1G7TUSpCoOeFxTYjdliFD7Y6XV4bshlIH0GDq4Gpe3Tn5+It8RCrhqwmCva wtmB1H5BM1H0IPenIHV3F9K6oZndFAT+EUJtI20aewZXsugOt0ERaDR+/Nu7aupl1fU6 xQlw== X-Gm-Message-State: APjAAAVnAm3c90YInB1qsYMapQzpcV3QZH5fZRVmvIOyxwU6PSVPlx20 vum60zpFaHt5dIfsC3As2gkoUcdV97ZY2ijLJhs= X-Received: by 2002:a9d:5d15:: with SMTP id b21mr911689oti.262.1560933329596; Wed, 19 Jun 2019 01:35:29 -0700 (PDT) MIME-Version: 1.0 References: <20190618182502.GC203031@google.com> <4587569.x9DSL43cXO@kreacher> In-Reply-To: From: "Rafael J. Wysocki" Date: Wed, 19 Jun 2019 10:35:17 +0200 Message-ID: Subject: Re: Alternatives to /sys/kernel/debug/wakeup_sources To: Joel Fernandes Cc: Tri Vo , "Rafael J. Wysocki" , Sandeep Patil , Viresh Kumar , Hridya Valsaraju , Linux PM , "Cc: Android Kernel" , Greg Kroah-Hartman , LKML 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 Wed, Jun 19, 2019 at 1:52 AM Joel Fernandes wrote: > > On Tue, Jun 18, 2019 at 7:15 PM Tri Vo wrote: > [snip] > > > > > > > > > > > > Android userspace reading wakeup_sources is not ideal because: > > > > > > - Debugfs API is not stable, i.e. Android tools built on top of it are > > > > > > not guaranteed to be backward/forward compatible. > > > > > > - This file requires debugfs to be mounted, which itself is > > > > > > undesirable for security reasons. > > > > > > > > > > > > To address these problems, we want to contribute a way to expose these > > > > > > statistics that doesn't depend on debugfs. > > > > > > > > > > > > Some initial thoughts/questions: Should we expose the stats in sysfs? > > > > > > Or maybe implement eBPF-based solution? What do you think? > > > > > > > > We are going through Android's out-of-tree kernel dependencies along with > > > > userspace APIs that are not necessarily considered "stable and forever > > > > supported" upstream. The debugfs dependencies showed up on our radar as a > > > > result and so we are wondering if we should worry about changes in debugfs > > > > interface and hence the question(s) below. > > > > > > > > So, can we rely on /d/wakeup_sources to be considered a userspace API and > > > > hence maintained stable as we do for other /proc and /sys entries? > > > > > > > > If yes, then we will go ahead and add tests for this in LTP or > > > > somewhere else suitable. > > > > > > No, debugfs is not ABI. > > > > > > > If no, then we would love to hear suggestions for any changes that need to be > > > > made or we simply just move the debugfs entry into somewhere like > > > > /sys/power/ ? > > > > > > No, moving that entire file from debugfs into sysfs is not an option either. > > > > > > The statistics for the wakeup sources associated with devices are already there > > > under /sys/devices/.../power/ , but I guess you want all wakeup sources? > > > > > > That would require adding a kobject to struct wakeup_source and exposing > > > all of the statistics as separate attributes under it. In which case it would be > > > good to replace the existing wakeup statistics under /sys/devices/.../power/ > > > with symbolic links to the attributes under the wakeup_source kobject. > > > > Thanks for your input, Rafael! Your suggestion makes sense. I'll work > > on a patch for this. > > Does that entail making each wake up source, a new sysfs node under a > particular device, and then adding stats under that new node? Not under a device, because there are wakeup source objects without associated devices. It is conceivable to have a "wakeup_sources" directory under /sys/power/ and sysfs nodes for all wakeup sources in there. Then, instead of exposing wakeup statistics directly under /sys/devices/.../power/, there can be symbolic links from there to the new wakeup source nodes under "wakeup_sources" (so as to avoid exposing the same data in two different places in sysfs, which may be confusing). Cheers!