Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp167500ybi; Thu, 1 Aug 2019 16:47:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqxLMLZc/Jdk00LPuhuknx4eJ1kKeRzDutyc9EYTiJipKYDZlpvp67S/130x/LSwOf/OQKxc X-Received: by 2002:a17:902:830c:: with SMTP id bd12mr131119829plb.237.1564703275246; Thu, 01 Aug 2019 16:47:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564703275; cv=none; d=google.com; s=arc-20160816; b=S7fS1NurfIR2qm4SCQXsrg2ERnHMjV/IYWLgIxzUC+Lj2LkK5XlwEI1eQvLvVYwh36 7xJjmzvvE4GplEHHmxMSh8PBXlI8A3zRE22uVjW91vdZp9Wrqcig84dlnNPqBYbmgXBl MhiDnyEvJMN8ncStmR255ZAXXLFnt5qAi1S2lBsIf50B/cca/V8yBw3JJBPp2SgP/dqH mukp7x5S5BHldGtp+LQeAktNcwAbxRMwwCAqVB1+60U3LG2dk2XLtgFwG4cOOkoOnQLh ay7yLfrbnAZ5WqSpwfTUHQuEGeifb6Pu2stNGLF56gR9c3au7xJcA0k/XXJ/qho9Sugn +1qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:user-agent:subject:to:from:cc :references:in-reply-to:content-transfer-encoding:mime-version :message-id:dkim-signature; bh=YaxBDmm4w6BxFdLcy1jn89PkJwYAWRGHPRdVfiDQRHM=; b=IHbrjuCQh9r3qOLjsuEdfCeg0nvvMJ6M4mmM5P9WPRzhh8BG6UyO/RWo3FvbPGMqtR mvE5stBpC1tcVoqyMFp6rNV8Si8aL4NHVKs9it+u+0KkXmsyO42zWg3x0k+elebfJMd4 zw2jyDHlmQkwX1U//bWGRtqxv7GYzI+8tmb4BbAYTDY2wVaaC///ptxyMT3fDhAtHO0q nJ/XrMAgK7zP3WVNo3JdOOLmB68vgNax1lTdoW0hZl+BVQfv4roaqzWq/H5jCnkz/gis AensYoMyucTQrwjI01g4TCpTBT89oLbfY7E1VJNvziokJ72YsoFwEO96qc4vMUI5E91w mvxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ngdU8xy+; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bg3si31476932plb.83.2019.08.01.16.47.39; Thu, 01 Aug 2019 16:47:55 -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=@chromium.org header.s=google header.b=ngdU8xy+; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388624AbfHATZH (ORCPT + 99 others); Thu, 1 Aug 2019 15:25:07 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:34606 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388598AbfHATZG (ORCPT ); Thu, 1 Aug 2019 15:25:06 -0400 Received: by mail-pf1-f195.google.com with SMTP id b13so34627832pfo.1 for ; Thu, 01 Aug 2019 12:25:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=message-id:mime-version:content-transfer-encoding:in-reply-to :references:cc:from:to:subject:user-agent:date; bh=YaxBDmm4w6BxFdLcy1jn89PkJwYAWRGHPRdVfiDQRHM=; b=ngdU8xy+iHRs7rlnaToJzNd5WH7HncGMsuD5TRZ7tEyyzGqqZFG7GFYIufuwz+VmxT epuk93Kk1F0gG1Z2roZPQ4y3CoRWdi+sT/PZXv1BZXaBnl+covbf5XsLOLYHKlg7IB62 cWkYR/qEgz8laAMUe6DPHSe3cNMu/zCGkvtfE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:mime-version :content-transfer-encoding:in-reply-to:references:cc:from:to:subject :user-agent:date; bh=YaxBDmm4w6BxFdLcy1jn89PkJwYAWRGHPRdVfiDQRHM=; b=BK6XfWDM2a9t1xzBCtM2OoxrEpy5K8N1QYt0ZuMa3qb1cawvdb9gakyDzS0Yx+Ug5H 3noftJ2V+V89tygCl+TQhce7Ap9g97r5kuGpmynsbex9Z5HxPGD9mopg4u20egw9409u fwwb1n6wCy75z44r7f8wpW3NAAhDoDj3nzG9Aw26sR2Gq/dsjC6Q/kMG/Ifw39/yoD9p fPYpIBgalvLbp8oRhZKoMLICg0eypxFsxhOETraHr5b4TKM3HJAgJcUtgHNCI+ZRqENu NmiGqZQBCgo16CUrF0iy6q77mqGpthMigw8btd7MEOv9P0EdqHJjaTXCnowkHhAa7Rau 94iQ== X-Gm-Message-State: APjAAAWePDMbAK9nPkNAZSo4AH+r//G0ldDx2h9SnYQEcojYDmsIWY+d 4E1jwJ0MmCeraqcGe0QJE26GbA== X-Received: by 2002:a17:90a:cb87:: with SMTP id a7mr392002pju.130.1564687506224; Thu, 01 Aug 2019 12:25:06 -0700 (PDT) Received: from chromium.org ([2620:15c:202:1:fa53:7765:582b:82b9]) by smtp.gmail.com with ESMTPSA id t9sm6136860pji.18.2019.08.01.12.25.05 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 01 Aug 2019 12:25:05 -0700 (PDT) Message-ID: <5d433c91.1c69fb81.93f13.febc@mx.google.com> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: References: <20190731215514.212215-1-trong@android.com> <6987393.M0uybTKmdI@kreacher> <5d42281c.1c69fb81.bcda1.71f5@mx.google.com> <5d423637.1c69fb81.62114.ca6f@mx.google.com> <5d4305df.1c69fb81.c4013.1950@mx.google.com> Cc: "Rafael J. Wysocki" , Tri Vo , "Rafael J. Wysocki" , Greg Kroah-Hartman , Viresh Kumar , Hridya Valsaraju , Sandeep Patil , Kalesh Singh , Ravi Chandra Sadineni , LKML , Linux PM , "Cc: Android Kernel" From: Stephen Boyd To: "Rafael J. Wysocki" Subject: Re: [PATCH v6] PM / wakeup: show wakeup sources stats in sysfs User-Agent: alot/0.8.1 Date: Thu, 01 Aug 2019 12:25:04 -0700 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Rafael J. Wysocki (2019-08-01 10:21:44) > On Thu, Aug 1, 2019 at 5:31 PM Stephen Boyd wrote: > > > > BTW, paths in /sys/devices aren't supposed to matter too much. In this > > case, I'd expect to see userspace looking at the /sys/class/wakeup path > > to follow the symlink to figure out what device triggered a wakeup. It > > can look at the 'device' symlink inside the directory for the wakeup > > device to figure out which one it is. >=20 > But if you go from the device, it would be good to be able to figure > out which wakeup sources are associated with it and in the alarmtimer > example you don't even see that it is a wakeup source without > following the link. Userspace shouldn't go from the device path (/sys/devices/.../rtc0 in this example). That's incorrect. Instead, userspace should go from the /sys/class/wakeup/... path. It should iterate over all the devices in the class path and look at the device pointers instead. # ls /sys/class/wakeup/*/device -l lrwxrwxrwx. 1 root root 0 Aug 1 12:13 /sys/class/wakeup/alarmtimer/device = -> ../../rtc0 lrwxrwxrwx. 1 root root 0 Aug 1 12:13 /sys/class/wakeup/wakeup0/device -> = ../../../a6f8800.usb lrwxrwxrwx. 1 root root 0 Aug 1 12:13 /sys/class/wakeup/wakeup1/device -> = ../../../a8f8800.usb lrwxrwxrwx. 1 root root 0 Aug 1 12:13 /sys/class/wakeup/wakeup2/device -> = ../../../cros-ec-rtc.1.auto lrwxrwxrwx. 1 root root 0 Aug 1 12:13 /sys/class/wakeup/wakeup3/device -> = ../../sbs-16-000b lrwxrwxrwx. 1 root root 0 Aug 1 12:13 /sys/class/wakeup/wakeup4/device -> = ../../../a88000.spi:ec@0:keyboard-controller lrwxrwxrwx. 1 root root 0 Aug 1 12:13 /sys/class/wakeup/wakeup5/device -> = ../../../spi10.0 lrwxrwxrwx. 1 root root 0 Aug 1 12:13 /sys/class/wakeup/wakeup6/device -> = ../../../gpio-keys lrwxrwxrwx. 1 root root 0 Aug 1 12:13 /sys/class/wakeup/wakeup7/device -> = ../../../1-1.1 lrwxrwxrwx. 1 root root 0 Aug 1 12:13 /sys/class/wakeup/wakeup8/device -> = ../../../1-1.2.4.1 >=20 > So the "wakeupN" virtual dev names for all wakeup source objects are > less confusing IMO. >=20 > It would be good to avoid the glue dir creation in all cases somehow too. I recall some differences between a bus_type and a class. Are you suggesting to use a bus_type for the wakeup sources? I like the class approach taken here to use different device names because it avoids the name collisions, avoids making another attribute to express the name of the wakeup source, and doesn't make a more heavyweight driver abstraction on top of wakeup sources. In fact, that ls command above pretty much sums up the wakeup source name and the device that it's associated with. Whatever goes on inside /sys/devices/... with respect to where the devices go and how they're structured is not important, at least to me. Why is it important to you?