Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp5689083ybi; Wed, 31 Jul 2019 01:43:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqzkZc08gT1PMf901zGcuzk7eo5nC++gEISyTSZBYLlZMmCFbLbb40V67Z7YxH7NtfkTYR2o X-Received: by 2002:a17:902:4501:: with SMTP id m1mr119797143pld.111.1564562628152; Wed, 31 Jul 2019 01:43:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564562628; cv=none; d=google.com; s=arc-20160816; b=fCI+f87ZyPDZHVpF/wR61hAvTysR6KiTJqYGfiImvaIa87g9a1yWJQYpNpVVzqcr60 6ucxRffPOYSp8drChCb9dFXJnhUzOdSRGget9EQ17J4cwbDIj9/xNijbwkz8/thJfBCj ldA14DO0RyiiD4xScGH2QiCfhCZKQg5rxOj2D4KGOUsk//8SVvm7hK2w3RgCgX1KOBOc Um1JcVA/lkFN1Rk7nFcQTqczCNJPZF6E6JsWJT0JJgtG9jtUgm5wtxsGm6QiDP7pMngD L0lQJhmKPpk6RK3/oYX2vxG5TXLDRy3bciUEM32Q0ukLCXnxM1onotAjBS4veuehBSs+ 99xA== 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=AB8Hs1jyVm8RnPRFNhSx7PcKVllFtK5cSajR3rR52nI=; b=Z/yyKOt42Ti4ack9VUL+L0oAWXayx6Db566lCf7djUupDnRmBwkcy4n+OsVTys17z8 Aew5XRt6xD5xDiay7aKwZ9gassWCJcZdLdWFx8tvuxzqEbjhPLBp4vjKQacsrUQZ1S15 Pivh0vI07RCvhUuAvV6C76+cNFqdcpZ6YQGb0dhkkqqLru8BNtZjuAH/cZQx6jSlhv0s 70q4xWugmvLhfQXoiYh8TzX/wEHbxQ4aoKMh7YFI4vycW8ngu6VqyPuZ389lmKwegwcj BsBufHgJTsDBg8KpajB2sVRyff920m0IML1T7+jxCEr8rgvH2bOuBz1ONfQp4pEI7RlI RqcA== 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 i17si998179pju.96.2019.07.31.01.43.33; Wed, 31 Jul 2019 01:43:48 -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 S1726968AbfGaIeZ (ORCPT + 99 others); Wed, 31 Jul 2019 04:34:25 -0400 Received: from mail-ot1-f66.google.com ([209.85.210.66]:43863 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726428AbfGaIeY (ORCPT ); Wed, 31 Jul 2019 04:34:24 -0400 Received: by mail-ot1-f66.google.com with SMTP id j11so12025731otp.10; Wed, 31 Jul 2019 01:34:24 -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=AB8Hs1jyVm8RnPRFNhSx7PcKVllFtK5cSajR3rR52nI=; b=KOwnd+Uv3zA5G86muDK28NkoIOBlEFh97YaNPc+yEUgFl4M7ngpDMhpjxGWUbhBsO5 6atiOe0wvF1tDRds8iQsgOV/CpAZqCwktA1hSrNJBn1DDJHlBQWUqw3iOJRV3C/92fM+ 17KVdn22e0aRp7pzicMEMCsY1olo2S9YrBCykTURtGQBu57sb6lVmOqIDno0Y5aDFJyy BRXIP17dYgbW2YX4zFA/yol8j/of6OFdviLmkRoWF/TyoVCf4SeJXxZEKrs8W9yqGFks 7752rvpnzWpWU4Xvltv/cEgs4eEYlb41xpRQaUOLVrPvDllNS8fXla+500CkjHBBXQsj cvUw== X-Gm-Message-State: APjAAAWAnazlI58zcoyaWmRLy0fb2w3mKmWGHz2t3MmR691wKkHX4aIp tbf0cGjCBFTDovqrwNn6qpSE0lvwzdJJhSTCWIw= X-Received: by 2002:a9d:7a51:: with SMTP id z17mr3227635otm.266.1564562063546; Wed, 31 Jul 2019 01:34:23 -0700 (PDT) MIME-Version: 1.0 References: <20190730024309.233728-1-trong@android.com> <5d4090ea.1c69fb81.d5cab.4dcd@mx.google.com> <2085893.cJkfNvi94x@kreacher> <5d40c41f.1c69fb81.ac63f.947f@mx.google.com> <5d40d5b3.1c69fb81.6047f.1cc3@mx.google.com> In-Reply-To: <5d40d5b3.1c69fb81.6047f.1cc3@mx.google.com> From: "Rafael J. Wysocki" Date: Wed, 31 Jul 2019 10:34:11 +0200 Message-ID: Subject: Re: [PATCH v5] PM / wakeup: show wakeup sources stats in sysfs To: Stephen Boyd Cc: "Rafael J. Wysocki" , "Rafael J. Wysocki" , Tri Vo , Greg Kroah-Hartman , Viresh Kumar , Hridya Valsaraju , Sandeep Patil , Kalesh Singh , Ravi Chandra Sadineni , Linux Kernel Mailing List , Linux PM , "Cc: Android Kernel" , kbuild test robot 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, Jul 31, 2019 at 1:41 AM Stephen Boyd wrote: > > Quoting Rafael J. Wysocki (2019-07-30 16:05:55) > > On Wed, Jul 31, 2019 at 12:26 AM Stephen Boyd wrote: > > > > > > Quoting Rafael J. Wysocki (2019-07-30 15:17:55) > > > > On Tuesday, July 30, 2019 8:48:09 PM CEST Stephen Boyd wrote: > > > > > > > > > > Using the same prefix for the class and the device name is quite common. > > > > > For example, see the input, regulator, tty, tpm, remoteproc, hwmon, > > > > > extcon classes. I'd prefer it was left as /sys/class/wakeup/wakeupN. The > > > > > class name could be changed to wakeup_source perhaps (i.e. > > > > > /sys/class/wakeup_source/wakeupN)? > > > > > > > > Alternatively /sys/class/wakeup/wsN > > > > > > > > > > Or /sys/class/wakeup/eventN? It's your bikeshed to paint. > > > > So actually the underlying problem here is that device_wakeup_enable() > > tries to register a wakeup source and then attach it to the device to > > avoid calling possibly sleeping functions under a spinlock. > > Agreed, that is one problem. > > > > > However, it should be possible to call wakeup_source_create(name) > > first, then attach the wakeup source to the device (after checking for > > presence), and then invoke wakeup_source_add() (after dropping the > > lock). If the wakeup source virtual device registration is done in > > wakeup_source_add(), that should avoid the problem altogether without > > having to introduce extra complexity. > > While reordering the code to do what you describe will fix this specific > duplicate name problem, it won't fix the general problem with reusing > device names from one bus on a different bus/class. Fair enough. > We can run into the same problem when two buses name their devices the > same name and then we attempt to attach a wakeup source to those two > devices. Or we can have a problem where a virtual wakeup is made with > the same name, and again we'll try to make a duplicate named device. > Using something like 'event' or 'wakeup' or 'ws' as the prefix avoids this > problem and keeps things clean. Or suffix, like ". But if prefixes are used by an existing convention, I would prefer "ws-" as it is concise enough and should not be confusing. > We should probably avoid letting the same virtual wakeup source be made > with the same name anyway, because userspace will be confused about what > virtual wakeup it is otherwise. I concede that using the name of the > wakeup source catches this problem without adding extra code. > > Either way, I'd like to see what you outline implemented so that we > don't need to do more work than is necessary when userspace writes to > the file. Since we agree here, let's make this change first. I can cut a patch for that in a reasonable time frame I think if no one else beats me to that. > I just don't want to see us need to change the name of the > wakeup device later on and then add a 'name' attribute to the class so > that we can avoid name collisions due to various buses controlling the > string we use to create the name of the wakeup device. OK