Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp299130ybi; Thu, 1 Aug 2019 19:22:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqwah04MOOS643dIFj/39bXpUD+Sh8RDQxJOKeSP9TB/mZlM0hgkQouI29TCJcfzyO+aObOj X-Received: by 2002:a62:834d:: with SMTP id h74mr59705283pfe.254.1564712524756; Thu, 01 Aug 2019 19:22:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564712524; cv=none; d=google.com; s=arc-20160816; b=P3DsY+a06LGB34ThcI8+MGBGNjS7RTViPqEWD2j7nFs77s5krXv/WweQsTxF/KGTdV cX7MPMyL37GcZcGnlxO4hQnL/rlkMYYakXeCObkeSG/smHgBteoraMnevjSY3DcDvCjJ 3wNI0AmhZjjgyyqU+BNd5u6bv9BxR6aLnr8sykqCcQoPx8ETsJXDgWogKIiNoXpJC26o VgwdKpdsbrijs9SUT6dJC+fO2LNVfMqn13h2zh/YbWaCuFa385Y/mDLTFAJx5y3HA5SV Q0ADLpLfj3jVtGc7R9zsH3Xnxvf5TjVXzmJ6Bj8P3OrLkhEvCeaPXa2pcs7i5fyTjy3B arjQ== 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=frWZM6vtCtibjV524zgoV1SgXB5n8GDLBSplraM3LKI=; b=s+qe/QqGctCN9+apPyKvg5sYSClCB+Hgt5QM0FZWcfX+4OjbNp36UZ9/YZIzmOb2cK avf4AQEjBwtQwpehbtyzyOlwyYrJiYSW88xIJXivjp9HWwmQH6bv/cZj70TAbJVBG7ru YUsp5+tkqApwaBtZZjBU0khaCkPyQ22H81aTk1pakh9VwRUErHXDVdw/YQW9vViAojqY zFo6Z8tr/FuMqztHjaPXy3j748v+G/BJvIciy9WKqJGETeUN77fH6ma7YbBvwYwr2Mtg g9v3qrjFUOfWc2PikBrTl3x4krl+XykJDE5algwYPpZF1mp+iaj3NektGXHeE4EV2V0k t7pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@android.com header.s=20161025 header.b=RGkTVsKn; 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 m68si39461898pfm.150.2019.08.01.19.21.49; Thu, 01 Aug 2019 19:22:04 -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=RGkTVsKn; 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 S1732394AbfHAVpF (ORCPT + 99 others); Thu, 1 Aug 2019 17:45:05 -0400 Received: from mail-ot1-f65.google.com ([209.85.210.65]:34811 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730924AbfHAVpF (ORCPT ); Thu, 1 Aug 2019 17:45:05 -0400 Received: by mail-ot1-f65.google.com with SMTP id n5so76021338otk.1 for ; Thu, 01 Aug 2019 14:45:04 -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=frWZM6vtCtibjV524zgoV1SgXB5n8GDLBSplraM3LKI=; b=RGkTVsKn0HppoD90ZbwIiUcLoDfWsTd76bBY0/P9mDIX9xK6EnSGnO/dJTWcG4o9as acP2cijwAMkWMJbQX/UxMPkSCpuhjBWGDDcLGtNYLvoUhkko06gaUK+2XfIEIJPIVXz6 tLHMpS37vngF3TbQGvssxf9av0EOuv/hod51Onx6XHIP8Vl5DwxEvHkizemmMBKsNxps ir08JCNcavYVw2TML9XbI3J9Qi8qlia+P9j+76hDuALdvsrV/gpbhK8VfacGXEWEtYbF tCOPyexZWurTEQ/HJZlzgmTLpENpElSeC4KyyQAi92Yj9a76QHrddBBqyK4yqiyR9BN0 6UiA== 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=frWZM6vtCtibjV524zgoV1SgXB5n8GDLBSplraM3LKI=; b=dEfB9KEpzRZ/3E2ha9AS9KeimpMDcdQwI7ichBZpITkB+EGz5VY3jUf6fRdVBK4clE F280kkCLN+ensaYzV7rykfEav4jgZj8/kgDLCDM0j4BLhYe0JPGZfBQdPVstvoGd9r3T hXkIGnBBJ+Hlf90BoxQfJa2LRk8WG8Pef9zDek8StHUBb+W1tp/5gnm9gbDtL6eEPg1C Bh2yQNvyzXzngHVFS1hfUiXjfZ/nLf8JJdhm/e+8bc26bE8xMwNN41g/Cxk1CTZyMjum /lM1W7+C/TxjosXNSWeuCws8ub5LXtlr3a5RtfOIP7rEkFa08dUGQaQ/XF0nqZNQlhY5 I7NQ== X-Gm-Message-State: APjAAAXXBkceiHuKpUBaEASVeZi2OQhmD0/gOzw1XuJ7+zFiuLsNpLQY eGc3waildW6XUVLRdILqY1WQHTJogKUJwfKD844= X-Received: by 2002:a9d:5f02:: with SMTP id f2mr12471058oti.148.1564695904071; Thu, 01 Aug 2019 14:45:04 -0700 (PDT) MIME-Version: 1.0 References: <20190731215514.212215-1-trong@android.com> <32598586.Mjd66ZhNnG@kreacher> <6987393.M0uybTKmdI@kreacher> <5d42281c.1c69fb81.bcda1.71f5@mx.google.com> <5d434a23.1c69fb81.c4201.c65b@mx.google.com> In-Reply-To: <5d434a23.1c69fb81.c4201.c65b@mx.google.com> From: Tri Vo Date: Thu, 1 Aug 2019 14:44:52 -0700 Message-ID: Subject: Re: [PATCH v6] PM / wakeup: show wakeup sources stats in sysfs To: Stephen Boyd Cc: "Rafael J. Wysocki" , "Rafael J. Wysocki" , Greg Kroah-Hartman , Viresh Kumar , Hridya Valsaraju , Sandeep Patil , Kalesh Singh , Ravi Chandra Sadineni , LKML , Linux PM , "Cc: Android Kernel" 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 Thu, Aug 1, 2019 at 1:23 PM Stephen Boyd wrote: > > Quoting Tri Vo (2019-08-01 12:50:25) > > On Wed, Jul 31, 2019 at 4:45 PM Stephen Boyd wrote: > > > > > > Quoting Rafael J. Wysocki (2019-07-31 16:10:38) > > > > On Thu, Aug 1, 2019 at 12:59 AM Tri Vo wrote: > > > > > > > > > > > > > > > > > So why wouldn't something like this suffice: > > > > > > > > > > > > dev = device_create_with_groups(wakeup_class, parent, MKDEV(0, 0), ws, > > > > > > wakeup_source_groups, "wakeup:%s", ws->name); > > > > > > > > > > > > ? > > > > > > > > > > ws->name is inherited from the device name. IIUC device names are not > > > > > guaranteed to be unique. So if different devices with the same name > > > > > register wakeup sources, there is an error. > > > > > > > > OK > > > > > > > > So I guess the names are retained for backwards compatibility with > > > > existing user space that may be using them? > > > > > > > > That's kind of fair enough, but having two different identification > > > > schemes for wakeup sources will end up confusing. > > > > > > I understand your concern about the IDA now. Thanks for clarifying. > > > > > > How about we name the devices 'wakeupN' with the IDA when they're > > > registered with a non-NULL device pointer and then name them whatever > > > the name argument is when the device pointer is NULL. If we have this, > > > we should be able to drop the name attribute in sysfs and figure out the > > > name either by looking at the device name in /sys/class/wakeup/ if it > > > isn't 'wakeupN', or follow the symlink to the device in /sys/devices/ > > > and look at the parent device name there. > > > > This makes it difficult for userspace to query the name a wakeup > > source, as it now has to first figure out if a wakeup source is > > associated with a device or not. The criteria for that is also > > awkward, userspase has to check if directory path contains "wakeupN", > > then it's a virtual wakeup source. > > I think you mean if it doesn't match wakeupN then it's a virtual wakeup > source? Yes > > > > > IMO it's cleaner to consistently have /sys/class/wakeup/wakeupN/name > > for every wakeup source. > > I don't find it awkward or difficult. Just know what the name of the > /sys/class/wakeup/ path is and then extract the name from there if it > doesn't match wakeupN, otherwise read the 'device' symlink and run it > through basename. The concern was that having both "id" and "name" around might be confusing. I don't think that making the presence of "name" conditional helps here. And we have to maintain additional logic in both kernel and userspace to support this. Also, say, userspace grabs a wakelock named "wakeup0". In the current patch, this results in a name collision and an error. Even assuming that userspace doesn't have ill intent, it still needs to be aware of "wakeupN" naming pattern to avoid this error condition. All wakeup sources in the /sys/class/wakeup/ are in the same namespace regardless of where they originate from, i.e. we have to either (1) inspect the name of a wakeup source and make sure it's unique before using it as a directory name OR (2) generate the directory name on behalf of whomever is registering a wakeup source, which I think is a much simpler solution.