Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp2914678ybd; Mon, 24 Jun 2019 15:17:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqygvYlX0f/BXwX7JrWc2Efi7Eg7C85EKj9s6yPFuAqSCZ9BK/NuRRuOFSxaGpDWy+gG4a3b X-Received: by 2002:a17:902:b611:: with SMTP id b17mr99536818pls.261.1561414665145; Mon, 24 Jun 2019 15:17:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561414665; cv=none; d=google.com; s=arc-20160816; b=B7dE/E0hIMv2SLHx3vu8ax4ZGcKr4k/vWXWBHYzBTeGef4D5JBNhbdXDk8qoAoFs8T +EpfNojv0HWkNCH7Lj4llByYtTK0VE64NT7gxt54vugJRnYWFehfpEQgMa/1tG3DGR/w OPYbqwa48kLPaetHZMciSiUUU9hBVGD5Gfrvrbnj6AWsuRx9Zwykma0TF+3ynV3nWCe4 9ja6TzrNS8WxHIaTrwb1z63I1AWX3BK4pAit3Cq0v3dScarSg3k/VZJSCyN6I7hzw7li BLYiDsVY+5gwPyqTNIyG7KfCaWLQ+hUvt1TSh35xWNR2J7MhxxZ1nUzExLCn0KaDWzVL E8NA== 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:dkim-signature; bh=TvQC8DOkvFGXBI+06419pP3Fe+HknGb+TWLaD4ysNos=; b=poDOzMYvsGTrESgLE9/f++OfpOV96/nUbcVcugL3BaWqIY3SSvZCyqd0c0nXNWePIW +nR1ZCPug9eezvuUg2YI+c7YiqBjkUzmWjawNXvWlVSbH9CRhnG18jDhRG6/GR+29KKk F86ABvOMv92oWqGGBLI2oBJ1qQQbjLDU4oaVKKjq3SRFGF/sYfvqSaroCtqwGOrjoZjn XXC3ZKw5Dj7ZjYJQAZ1xsdrz4AH0tw9vlQj8hM5OEWVUxRLArp+cddDUuS3aed3Lfq6T GSlrKNuHEJyYEPKY0ac1UEJFUEm1hTtHmlXeKlF7912dqla0dMyT1upqFE7HrQ9wui2k tbhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@android.com header.s=20161025 header.b=jKJ9HZlK; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=android.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b14si668542pjq.0.2019.06.24.15.17.29; Mon, 24 Jun 2019 15:17:45 -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; dkim=pass header.i=@android.com header.s=20161025 header.b=jKJ9HZlK; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=android.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727031AbfFXWOT (ORCPT + 99 others); Mon, 24 Jun 2019 18:14:19 -0400 Received: from mail-ot1-f67.google.com ([209.85.210.67]:43208 "EHLO mail-ot1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726402AbfFXWOT (ORCPT ); Mon, 24 Jun 2019 18:14:19 -0400 Received: by mail-ot1-f67.google.com with SMTP id i8so8031425oth.10 for ; Mon, 24 Jun 2019 15:14:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=android.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=TvQC8DOkvFGXBI+06419pP3Fe+HknGb+TWLaD4ysNos=; b=jKJ9HZlKurzWhA+pVW3nQYsHn9cP1hSdhg2pHcY2uiFp6SgPWu+ZFKn/HChfc6g5ce tMFUpqfXHOBA8ciMzqL/Zd+YScze1vdWCIx5+dmSjWf14Pv/XcMekvHLfLySEprvdHby ukpFpy+INeMaEAQw/vszf5WYEhdcefWquYobiJCdQ/dkT8AnU15I4REsdZcya/3SXz6a LxmOvCSTRWUhwKJJ9+UPsdfgkt6KziTV56IrBcWXnY4l22QSOxEgifT7z8xy0bEGYSsI q0rFcyPl+Mvu08Rj/yoGiYm8M9XUCdu1TruDoteQ7WsN1fQfIJgWj8Pxf43k8v7fH1Xa 79uA== 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=TvQC8DOkvFGXBI+06419pP3Fe+HknGb+TWLaD4ysNos=; b=ndXXn3JempIFGQ6NueoEy1Tfl0dybsnpXh3Bjndh9zTW2+seUgHJHSDIJUD8uPiHuP D1EHlBzOuNMUOB97ncBPE9yJLKrHnLpbwtGpYwR1jYO/vXpgxWG49R6wELes4ctTLhCi SRfifKP0+iTGgjUYWRwM/aspI/BpmKoDoMh/BZ6ax5gYba84BsS872f1+L9IQNW9+hYR lMlrTwqKZrcLqvWlBqF6Q1Fb2xInuVH0Ql2JfoPSPVX8FGWogWsUxyBgk+wKiTPXCmAl bsKbhCUaPH2vI6N41vkYa9WinEcfNlcVWjGppRkmKIkCIha93160bXPTmGlqIueV5Hss F/Sw== X-Gm-Message-State: APjAAAU+VGPEcF6uK9zam4ZLxdTno7kXjA5nbIp50fAz+Arn44tDn1l1 y+5T27uY2qCMZQV5MZow6UjlvIMQExPwNX0zBwphqw== X-Received: by 2002:a9d:5911:: with SMTP id t17mr10938017oth.159.1561414458100; Mon, 24 Jun 2019 15:14:18 -0700 (PDT) MIME-Version: 1.0 References: <20190618182502.GC203031@google.com> <4587569.x9DSL43cXO@kreacher> <20190624073659.GA13957@kroah.com> In-Reply-To: From: Tri Vo Date: Mon, 24 Jun 2019 15:14:07 -0700 Message-ID: Subject: Re: Alternatives to /sys/kernel/debug/wakeup_sources To: "Rafael J. Wysocki" Cc: Joel Fernandes , Greg Kroah-Hartman , "Rafael J. Wysocki" , Sandeep Patil , Viresh Kumar , Hridya Valsaraju , Linux PM , "Cc: Android Kernel" , 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 Mon, Jun 24, 2019 at 2:55 PM Rafael J. Wysocki wrote: > > On Mon, Jun 24, 2019 at 2:27 PM Joel Fernandes wrote: > > > > On Mon, Jun 24, 2019 at 3:37 AM Greg Kroah-Hartman > > wrote: > > > > > > On Sun, Jun 23, 2019 at 06:48:43PM -0700, Tri Vo wrote: > > > > On Wed, Jun 19, 2019 at 1:35 AM Rafael J. Wysocki wrote: > > > > > > > > > > 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). > > > > > > > > This may be a dumb question. Is it appropriate to make symbolic links > > > > in sysfs from one attribute to another attribute? For example, > > > > /sys/devices/.../power/wakeup_count -> > > > > /sys/power/wakeup_sources/.../wakeup_count. > > > > > > Why? would you want that? > > > > This sounds like what Rafael suggested (quoted above), right? > > I did, basically to avoid exposing the same information in two places > via different code paths. > > I tend to forget about this limitation, sorry for the confusion. > > That's not a big deal, though, the attributes under > /sys/devices/.../power/ just need to stay the way they are (for > backwards compatibility). Thanks for the clarification, Rafael!