Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp300610ybi; Thu, 1 Aug 2019 19:23:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqzTPStCd4Un6um2YOSG1NV1eo2VeZ+Y99MHLBqoBhVCF7GqJ8oevBRX/u2UtxvkI3DP9Wd8 X-Received: by 2002:a17:90a:9a95:: with SMTP id e21mr1865372pjp.98.1564712634952; Thu, 01 Aug 2019 19:23:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564712634; cv=none; d=google.com; s=arc-20160816; b=zohhWUA+vduGc2r+jrajSJLOon/wQc8PHkHCCVJi4SbEzppbsQx7W3g34Lv8WZX1dI AzOmlr+Hf+QPmvDmMna+ilry4hb5ZOAUkoiOOyiu0uR6Ulkqn757+4DY70OJECo9sFKr 6cgaPsN93ZtcT6bWaSZaWkHjtktYd5sE0m/n9MaRPAFkVVuQe4z2rUukfwCe9KntJSN1 EhoeZnq5SsFzBp/II0y2w5Qq1FrCHfpIa2xMiApd8oc6IszSCbjNc2LNltR1DJIELs0P auFHdAwN8paXoCw7jRKXWUcmIrCIrqscYJwwBZDuljUsQuycidl9rCuH9PLr6h3YTkxg 6LWA== 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:to:cc:from:subject :references:in-reply-to:content-transfer-encoding:mime-version :message-id:dkim-signature; bh=ODIRyiL2jtm5+/15idQHr4S7cTy4XyQupt2hfbfu6pE=; b=cnzTAr6wlwjyB4DXO7Op7hl/YWuyLYHawG6ZqljS6cOXWde9pFuXvKYTRgTnbaj+Qv GbE+lFSbIPW81c2VcCpgm7/lBCxZaUbFiR3WOIBys/fFyt+mFWBB6eTc0gxQNB+tzzoz uxX0MDIWACCdOFiiUXANmp51MpCcjlw5k83S6ZjEGocIp+tOQJBwBPmhlxVOK5cIcAts gi14BtcWm46FHGBeznGxlccMRU6TqFwvGxrrDV9Vfg2OqLj6zYSanvbiNJynX5xsJXzp l0HEMkNW+MY4QE1LqKnv7LCA5tNI7Ubf+rBRpVH6Ku43v8CEB+s9m8W4+g++1uB7sARv JjOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=HrCl0x5Q; 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 b21si36011708plz.21.2019.08.01.19.23.39; Thu, 01 Aug 2019 19:23:54 -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=HrCl0x5Q; 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 S1731631AbfHAWL7 (ORCPT + 99 others); Thu, 1 Aug 2019 18:11:59 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:33627 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728170AbfHAWL7 (ORCPT ); Thu, 1 Aug 2019 18:11:59 -0400 Received: by mail-pf1-f196.google.com with SMTP id g2so34854528pfq.0 for ; Thu, 01 Aug 2019 15:11:58 -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:subject:from:cc:to:user-agent:date; bh=ODIRyiL2jtm5+/15idQHr4S7cTy4XyQupt2hfbfu6pE=; b=HrCl0x5QBEnYD9qwWOywZJP+pIVZLFd/RMfSyMarPnYV6bB5gkfq4UstgZv/I6KWre WrZqFHlGrgGS2NpJ3Zkh0adwD9LjZiHgqs7DmVbDJd2cBJ7k/9zsOKFRqwx6DsIpGGPa DRexuLZIGD8yWzRNR69KPmmdZWa7pRQnY8bWc= 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:subject:from:cc:to :user-agent:date; bh=ODIRyiL2jtm5+/15idQHr4S7cTy4XyQupt2hfbfu6pE=; b=JeXmywFWogrJhLFSnAE9FFVdn8sBOB1g8zJnR6gReT6fhj9cOg1azwJOcTcmKewt+9 fUI3jV0mzWhOMuWtN7cVhd1b2LlSzWyXc1YwdI2qZ8e3V0er1vOKTXLp+DgSBPugxVVU bEFDYP3ceHRz1EZOdCLIc2jPvg/irnxyqvnPTXXJN7r4urTdKk8mWLWj071mooH9Qeuk wZjlYNw4nDFI12ju2AVKHZUKVuabX9nbqCNjTqySq/CHtYk9zbK6RbgStw+VhgmdRvmu 4LpO25+RZsy1g1BWWYN7xuvzWOgIkIXkPqxug+GObV4uUdPPK2pKzCGSk5vZnJmxocdT SDcA== X-Gm-Message-State: APjAAAV5tqQLPpnwiNoXRdB91LdSZEcXKMHz6lVuuYIqauDOKni7fMFj +ONfaWAGDwNcYO9HTCyLN9BfWQ== X-Received: by 2002:a17:90a:19c2:: with SMTP id 2mr959761pjj.13.1564697518491; Thu, 01 Aug 2019 15:11:58 -0700 (PDT) Received: from chromium.org ([2620:15c:202:1:fa53:7765:582b:82b9]) by smtp.gmail.com with ESMTPSA id e5sm2796523pgt.91.2019.08.01.15.11.57 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 01 Aug 2019 15:11:58 -0700 (PDT) Message-ID: <5d4363ae.1c69fb81.b621e.65ed@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> <32598586.Mjd66ZhNnG@kreacher> <6987393.M0uybTKmdI@kreacher> <5d42281c.1c69fb81.bcda1.71f5@mx.google.com> <5d434a23.1c69fb81.c4201.c65b@mx.google.com> Subject: Re: [PATCH v6] PM / wakeup: show wakeup sources stats in sysfs From: 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" To: Tri Vo User-Agent: alot/0.8.1 Date: Thu, 01 Aug 2019 15:11:57 -0700 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. >=20 > 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. >=20 > 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. >=20 > 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. 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. 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.