Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6575212ybi; Wed, 31 Jul 2019 17:18:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqxogGHTtdXn46XF/WnnqFk7cRP0xW3/IRsMT+JEn87D/ps/HNoXEfZdtGcINvo2u9qRHvWV X-Received: by 2002:a17:90a:ac0e:: with SMTP id o14mr5548551pjq.142.1564618708428; Wed, 31 Jul 2019 17:18:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564618708; cv=none; d=google.com; s=arc-20160816; b=ZEtvv6zuYmR8pn4iVffDTVdeamZTCR/kyMT6mcwo0mj252370N1HZZH733gXsgUgky q89HD09Gr6gk9fP7Kldj07kQZONgvBYm6EFHvu/BSgdJc8IpoPN/kcbXwJEuixkq6KlI iz49CtUkC34KbXm0QuMGcLsi/E73ra1qhbb/v8GbxHYMDPW1xrt8BSYlxUg6MzxiMno7 FGx0JDm+ww51eEdUn+82RJ99DoQOLhpPQzpWhVPEhVvbpxTPR6IOwAOVaesWKNjlBGdb a1tMNc/xac9wTpH4heVO1puBUok9Ajf/LcQhRW5YKwxNXEaeDaPuOWKfaFKwRvq5dZNO kQWw== 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=Tl5pYeZ72qtvUfn4lyn1cjKCDdQYMVgYKeR/aYm1DhE=; b=lS5lo0CkOMFUY4onaiouhYGtj30WUp5DqrjYQVe5gvFfS4GZI4fBUCk+zEUAYYJifS P8D2ZIuYvkbwYCrJSXd8/a8kV7CYfs2zfYLK7YJrZXYqj5YCcbXZacnmYC6QpQMenW1Z G4qQeAUwser4JVrxMb2CK4VTOc9uPgwt7j/mTWeUxa12I/+chZmdE0wFNiEgc8C79DIW nWxOJFr3YU9Mah3l/DcElTmtGS5zg2hkxoJ2C3dHtgjdNBkzMHKM+JTazA3iVKREd2S/ xkBpHtGepD3SNpY0Uj1WeVKg3W/1iwAle3wrRcTylDXmyh/vV9gTefwRJkGEhaBnmAkl fcXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@android.com header.s=20161025 header.b=v47GlmL8; 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 e80si32228445pfh.121.2019.07.31.17.18.12; Wed, 31 Jul 2019 17:18:28 -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=v47GlmL8; 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 S1730688AbfGaX1g (ORCPT + 99 others); Wed, 31 Jul 2019 19:27:36 -0400 Received: from mail-oi1-f196.google.com ([209.85.167.196]:34044 "EHLO mail-oi1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728774AbfGaX1f (ORCPT ); Wed, 31 Jul 2019 19:27:35 -0400 Received: by mail-oi1-f196.google.com with SMTP id l12so52144381oil.1 for ; Wed, 31 Jul 2019 16:27:35 -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=Tl5pYeZ72qtvUfn4lyn1cjKCDdQYMVgYKeR/aYm1DhE=; b=v47GlmL8kD1utdUfl8QhSsYQ4Ycd1eqmlLIHQozoHfiH8imsFoYdxlYhZfXBlHKFOj uc6mUixJlfqK2Ks7KZrES+UXs3+sQ+cRBxjYePOuqQaWoYycbs3/Uee7taScQRy8QISM 3owBKhe1Przm4WbIC7G+XSYIy/zAqp8IlFfNkg17DwlXCEoPRmT/hvTqqsFF2nA57OYy XH++6DrmmoxUbh+d6ESIDCalkrsni5GDPUaMhoLe+JHbWReauiXTwZUKmosfI3M//lT5 o9UOiMzDqvjjctii9bqV4cS9Ej+khBG6LKgnKtr6NkUqgvP3cFHkcQW/BHJTthIuY1px kgyg== 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=Tl5pYeZ72qtvUfn4lyn1cjKCDdQYMVgYKeR/aYm1DhE=; b=EVG048jwrSCfxdjBlL0b9NjelnuxZBgrcUna6ZuomtTKCrG4JnG1IRoPrAJLAeH3uS VDFuqVDBlWsSrqinM6Q46Rkqyd3dfTWrEwpKzmdE13xRgrmvqjDXt8Nobqqy+zNczBcY Eug9+40KFq5JBcGQrJYBfY2LIRwQu2visaCOicFHFfxIMISDRJkO/a9y0sXoIg15F9k+ ZtaOBTuYOLosqmoDhMBRZIneiFY44PbaIeRoMq7QqinpIUr0Y7tFXC7Y25+lB9IINSW0 0soh08/xIdFDsmIovU3/iSCZEBPLC6FPeEnW1iq5lnF5WiTBOdhP8OgaHlpBLcy3plvG 0JvQ== X-Gm-Message-State: APjAAAUS8YOrsX1mHnHFDq8HeWHFUhzzsaznYoPfOJRhmt2C7nm2JhaK Pw2hi+dywUmI81h3Dllq9PptUYEDrUwCoeoXMhU= X-Received: by 2002:aca:3509:: with SMTP id c9mr64322694oia.179.1564615654731; Wed, 31 Jul 2019 16:27:34 -0700 (PDT) MIME-Version: 1.0 References: <20190731215514.212215-1-trong@android.com> <32598586.Mjd66ZhNnG@kreacher> <6987393.M0uybTKmdI@kreacher> In-Reply-To: From: Tri Vo Date: Wed, 31 Jul 2019 16:27:23 -0700 Message-ID: Subject: Re: [PATCH v6] PM / wakeup: show wakeup sources stats in sysfs To: "Rafael J. Wysocki" Cc: "Rafael J. Wysocki" , Stephen Boyd , 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 Wed, Jul 31, 2019 at 4:10 PM Rafael J. Wysocki wrote: > > On Thu, Aug 1, 2019 at 12:59 AM Tri Vo wrote: > > > > On Wed, Jul 31, 2019 at 3:42 PM Rafael J. Wysocki wrote: > > > > > > On Thursday, August 1, 2019 12:31:16 AM CEST Tri Vo wrote: > > > > On Wed, Jul 31, 2019 at 3:17 PM Rafael J. Wysocki wrote: > > > > > > > > > > On Wednesday, July 31, 2019 11:59:32 PM CEST Stephen Boyd wrote: > > > > > > Quoting Tri Vo (2019-07-31 14:55:14) > > > > > > > +/** > > > > > > > + * wakeup_source_sysfs_add - Add wakeup_source attributes to sysfs. > > > > > > > + * @parent: Device given wakeup source is associated with (or NULL if virtual). > > > > > > > + * @ws: Wakeup source to be added in sysfs. > > > > > > > + */ > > > > > > > +int wakeup_source_sysfs_add(struct device *parent, struct wakeup_source *ws) > > > > > > > +{ > > > > > > > + struct device *dev; > > > > > > > + int id; > > > > > > > + > > > > > > > + id = ida_alloc(&wakeup_ida, GFP_KERNEL); > > > > > > > > > > So can anyone remind me why the IDA thing is needed here at all? > > > > > > > > IDA is used to generate the directory name ("ws%d", ID) that is unique > > > > among wakeup_sources. That is what ends up in > > > > /sys/class/wakeup/ws/* path. > > > > > > That's not my point (see below). > > > > > > > > > > + if (id < 0) > > > > > > > + return id; > > > > > > > + ws->id = id; > > > > > > > + > > > > > > > + dev = device_create_with_groups(wakeup_class, parent, MKDEV(0, 0), ws, > > > > > > > + wakeup_source_groups, "ws%d", > > > > > > > > > > > > I thought the name was going to still be 'wakeupN'? > > > > > > > > > > So can't we prefix the wakeup source name with something like "wakeup:" or similar here? > > > > > > > > "ws%d" here is the name in the sysfs path rather than the name of the > > > > wakeup source. Wakeup source name is not altered in this patch. > > > > > > > > > > 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? Yes, in Android we do rely on the name to aggregate statistics across a fleet of devices. That wouldn't be possible with just the id, as those are generated at dynamically runtime. > > That's kind of fair enough, but having two different identification > schemes for wakeup sources will end up confusing. It's not without precedent though. rtc, input, and other devices have a similar scheme.