Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6572514ybi; Wed, 31 Jul 2019 17:15:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqwPx+Z7eNMpac9ar9D+gkio3tFraR5VsDLZDNr4OfwgJFXT9bfQb3qIAOJi5RpGJOiuHPHZ X-Received: by 2002:a62:5344:: with SMTP id h65mr50712171pfb.32.1564618511420; Wed, 31 Jul 2019 17:15:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564618511; cv=none; d=google.com; s=arc-20160816; b=nthTmq18aabnjqAoK7DMCWNLMlRNKttSJOhP880JyZwlOszzRwK4guZPib4somYs9Y 5DcOoH6Y51Pn1auNmXfSKnWM7HpyEzJEphTRxrSa2qc6BbniCAcBIxLHiWEHTu5N8jiu J/fv5v4oO/73uV9dmMhpgxNSc684xBRIw+7J8oxapUsCUFs3g56nSbAA5fhb6eVCIr7A cq/TKvMuakCManzc+k954FgiQqeEIchu7dlzzmuZZXv4N11j0AK4vQ9YdGFPhRSn+Mrl mN/dVnanaYVDnAbOw7j5bRFMh0clVpyT+s66je5ElhwNOMoRA9HsL1neJFCXY7Y4e33N afPA== 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=8l1uqGOVO/FuCTz/Db7pciz7jZIb+8ZYxFrfQmQPjZo=; b=HSZr9GipdGRCx9fOm9QG6ZvXdamI79zLXbvHsQs+F1z9Di07Vn4zaZ5jFrBk6/HJAt 78ZyaLkWcQRQU11H672CGrElRge6e/EepWZ9bwv2DXMBiwU1Dwvf/ztYiT2sXz+j0RjT n8jfinK4lTuP8ummrF3KmLbQauRc1KJ+xOFbI66Q7tKU6dGxTSJvkFUNl59G3GPjbhe4 bCkSNcwJ5jcezngfMRJTZb6JKB7PRAvkS3wFh9Xp9+ZVIlvmp/55r6fFYF6fL0SOIpA4 SepVW1klC3d4LQ38GOhf8KF6yVqoynm6G8zQtBrLbIq/ZIyXUx5A6OSgGQSk1puK33RT NwBw== 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 b28si35648237pfp.92.2019.07.31.17.14.55; Wed, 31 Jul 2019 17:15:11 -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 S1730677AbfGaXKw (ORCPT + 99 others); Wed, 31 Jul 2019 19:10:52 -0400 Received: from mail-ot1-f66.google.com ([209.85.210.66]:40849 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725793AbfGaXKu (ORCPT ); Wed, 31 Jul 2019 19:10:50 -0400 Received: by mail-ot1-f66.google.com with SMTP id l15so14775627oth.7; Wed, 31 Jul 2019 16:10:49 -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=8l1uqGOVO/FuCTz/Db7pciz7jZIb+8ZYxFrfQmQPjZo=; b=dJzj/nPJEkpn+z1sYfGw1w+DsSe86+WBHXwVMdFJ2fiU5X1qhyT4SnZGtCiM5qyuvZ whnBZQFg7YTLKIW++b+u1ybm2M3YXlebx1//wP720Dn0VOQY2+yc9uIGuCcqvjqOiJDo rwtbo3F7+0NcGSdcMqKSkms+wsB13JShoLKj68teYKvEv1LVTMfaauqtJC0Ih/kPpUSH sI8e4p/dt65bUdxBYL9UCeQdj1aP7NBCd3DgQcS2qDephmcbCwH0gl07h9ID54L2I9Yh EE+WW7hvp+vNkf0pG2wFlfWx9fxCccMtvkIVFE6RuRj+8hcVLxdWT79HHkHoF4mZUVGA 1lJQ== X-Gm-Message-State: APjAAAVniAFce/UiAgg+zzg8OMJj6YspETv4RR/lFHbKrXq9OESh7AlL 4aKzS2Fai8287Uf2/g/A5zqZju+k3lbR2QiM7K8= X-Received: by 2002:a9d:6b96:: with SMTP id b22mr24345908otq.262.1564614649426; Wed, 31 Jul 2019 16:10:49 -0700 (PDT) MIME-Version: 1.0 References: <20190731215514.212215-1-trong@android.com> <32598586.Mjd66ZhNnG@kreacher> <6987393.M0uybTKmdI@kreacher> In-Reply-To: From: "Rafael J. Wysocki" Date: Thu, 1 Aug 2019 01:10:38 +0200 Message-ID: Subject: Re: [PATCH v6] PM / wakeup: show wakeup sources stats in sysfs To: Tri Vo Cc: "Rafael J. Wysocki" , Stephen Boyd , Greg Kroah-Hartman , Viresh Kumar , "Rafael J. Wysocki" , 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 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? That's kind of fair enough, but having two different identification schemes for wakeup sources will end up confusing.