Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp303167ybi; Thu, 1 Aug 2019 19:26:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqySKHETBGIRlQ4VVi3g/LvP6pI4XZoLfInIBATPh9FzKhRuIygMBnnjEv2yL8qOmFhNDBDH X-Received: by 2002:a63:ff0c:: with SMTP id k12mr79463614pgi.186.1564712808731; Thu, 01 Aug 2019 19:26:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564712808; cv=none; d=google.com; s=arc-20160816; b=yTO1Y1tupmAxqEFyrORpfVNcV6IbMVIIZW7D4TLv9D5aL9tWjsmwY4u1mRX4S8JF3x 0637s4kmojwjqEl5LIFpXN/uxbDUg+Cl2GXf6lq0mkmIrwyDUGBvwN4qimY0lBH/LWW6 D7crJYj3AEZvIMAseX4CRTdf7oxA6xoTlkkPcdJe88SqRc2nCExMI9f799fZyuB6RXdZ EpYMmlkhDBgNdupEGNokB946+briDAX/c2Uy58r8XyBwSl9W9uumvucrM5eZ8SfSF8Mc 2rX5orhPNC3+x6rSWyf++o464M2NohLuNBLrrhSK411SCiXcuYBqJ92tnBBNpcfiEs3k 6FyA== 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=6/A0oFUJlLeWDW4iRfhcabTxuKQ2E0T/S9GKqy4yr6w=; b=FOJ2C4jVL4LVFeevXCgwcDthDtNPSwg34bmy7+tMfvDHeHklWkGVwvZAcNA6Rq1R0N 6seXKs42Vw4kH6qjW2CFy2afLSmCLTCcfoQLcFSqqQgOACPcHzJpUk4hvrha2/vTHfUw QuvJJ/X1SGHSRgy8y9BFWCr7C0856T2GMM1emciZzGT4f/3RAunl16VTlKAuT7dQCJSj Nv9AzoaOUj9iTyvMv+ySileSW8mPZs7K/xDmsfRA39aZFVChLN2+MiglewsKrCnQTavi PWGfyVDkaxz193F5BU8d4huTvI4WphF2y6nxTfHr02paaJ8aW/zY8ykTpmUqIQXGUhgH Wm9g== 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 d31si2157977pgb.227.2019.08.01.19.26.33; Thu, 01 Aug 2019 19:26: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 S1732990AbfHAWqq (ORCPT + 99 others); Thu, 1 Aug 2019 18:46:46 -0400 Received: from mail-ot1-f67.google.com ([209.85.210.67]:42294 "EHLO mail-ot1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732187AbfHAWqp (ORCPT ); Thu, 1 Aug 2019 18:46:45 -0400 Received: by mail-ot1-f67.google.com with SMTP id l15so76089427otn.9; Thu, 01 Aug 2019 15:46:45 -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=6/A0oFUJlLeWDW4iRfhcabTxuKQ2E0T/S9GKqy4yr6w=; b=BRFT8UXsCmKc+OO2lHbV7mRLsfKRHlLFZnfbx3esM7Tvh0DSSG/njPGNhXFfdLtinR H3CujCvYD6Fz3mUajjZiESx/yrdDpVbK2GI38lybPxxDQM4vYVAU4r2PsWUTRUkviw8l e/09PQF21TUdQhvCLemgvD0S1RLprfovxqdWzRpUHfywYIl+rW3lZAzjY+PdFO2YOBPd 1TDEFK6hH4ApoOd9805eegNx7+op9SNenBQ33FywpxwB01QMsvXFuDWR/ycGxVIAmsr1 NdKkofCQ5DCnQYi1kYb6lEIyHQbJHjJnVLaOU98yxi9JKSAmgH7difzC9kxvUSFifhNV qLHA== X-Gm-Message-State: APjAAAU5p098XhP2NOzaHG71tauh/i8/93cn5+sD5l4vJSSy9kS3VI4P q3Sxquz8yhmZmTjZmczkYibAIWHkgrhmqDbASJfAIg== X-Received: by 2002:a05:6830:1516:: with SMTP id k22mr92227045otp.189.1564699604701; Thu, 01 Aug 2019 15:46:44 -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> <5d4363ae.1c69fb81.b621e.65ed@mx.google.com> In-Reply-To: <5d4363ae.1c69fb81.b621e.65ed@mx.google.com> From: "Rafael J. Wysocki" Date: Fri, 2 Aug 2019 00:46:33 +0200 Message-ID: Subject: Re: [PATCH v6] PM / wakeup: show wakeup sources stats in sysfs To: Stephen Boyd Cc: Tri Vo , "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 Fri, Aug 2, 2019 at 12:11 AM Stephen Boyd wrote: > > Quoting Tri Vo (2019-08-01 14:44:52) > > On Thu, Aug 1, 2019 at 1:23 PM Stephen Boyd wrote: > > > > > > > > > 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. > > Ok. If the device name is going to be something generic like 'wakeupN', > then we need to make sure that the wakeup source name is unique. > Otherwise, I'm not able to see how userspace will differentiate between > two of the same named wakelocks. Before this patch the wakeup source > name looks to have been used for debugging, but now it's being used > programmatically to let userspace act upon it somehow. I'm not actually sure if this patch changes the situation with respect to wakeup source names. User space still can use them for whatever it used to use the list in debugfs and that's it. That's what I mean by retaining the names for "backwards compatibility only". > Maybe it's for debug still, but I could see how userspace may want to hunt down the > wakelock that's created in userspace and penalize or kill the task > that's waking up the device. It can't do that right now. > I see that wakelock_lookup_add() already checks the list of wakelock > wakeup sources, but I don't see how I can't create an "alarmtimer" > wakelock again, but this time for userspace, by writing into > /sys/power/wake_lock. > > What happens with namespaces here BTW? Can a wakelock be made in one > namespace and that is the same name as another wakelock in a different > namespace? Right now it doesn't look possible because of the global name > matching, but it probably makes sense to support this? Maybe we just > shouldn't make anything in sysfs for wake sources that can be any random > name created from the wakelock path right now. I don't see how it can be > traced back to the process that created it in any reasonable way. It can't. The assumption was that there would be a "manager" process in user space controlling access to this interface and it would do its own tracking. That predated namespaces though. :-)