Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp5024339ybi; Tue, 30 Jul 2019 12:21:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqwiWU3B1TbQ04njVdqYHEMQpAMbNwv72Zi17NrPVPgtsrQseag3XnKVVjFdJ9nk/nw7e7Lf X-Received: by 2002:a62:82c1:: with SMTP id w184mr44191354pfd.8.1564514485641; Tue, 30 Jul 2019 12:21:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564514485; cv=none; d=google.com; s=arc-20160816; b=Ojt5kuYA4qJO45Dx8nOOPYMLFXLE8JPuJZhE1y0noGSjhxl1cawISUlZ3PX5siaQaq E6aXFycFmpi+KgkaQWcSCymocwcFVxqcd6YO2OfyeigDpDzzRpqA/YppA96GHDMjqD2V y2PFtcCRWDSVobudQBPSpnd1hIEbYI0KRk6EVX5KRJ8M38Mbt7TKB82D+awr5f4EKiDP Ds3V6j1dZ6SvHewCLDb5Vh2wkZWr4E0Q2i5Lp/BFX6o6m6QZq9SZFyrVod+gRjy8luhe g9F8Edf5AazYdfoU8sM7qPen3MHRFDfG32WnuqagjJ3wzLQZHoUtTN4jZb9HvPF88n5X lL7A== 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=lG7iy+1TUm+VzW+0drIYHjU3Qdez5tE551tVEBNTmeo=; b=tlRVfX4C1c+gx8AyHtOG1Ti/LSS3Ds5+mqe9FTH6iewsTio88FQT923FeG/0Exr5Vv 9ImvdGR6jAWXjH/jkXEjo1fU0+np19DLRlIihtoPF0vWayhzimlw4dRbBS4Wmsl0KH3i 03CVH3Vxdz1O0xg2Th9CoiucCtvke6b2yQ7Ik1yjtguwucb3tPrXTmsW8TIzY/vQHZi6 v/WyceJt1oa7bxNoFMoj+4hdczLdy36WRS3eJheGtm+7PyCLbUlVO1mHXUwrKzKeVkQC sKrlALU+XHm2OUT+nnsApkHeKnbJok68++UPcvk0Cl34gQoY+Bq1snyjbHMqwy2qT7U1 NpYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@android.com header.s=20161025 header.b=OQQuPmBc; 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 x9si32109814pfi.211.2019.07.30.12.21.09; Tue, 30 Jul 2019 12:21:25 -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=OQQuPmBc; 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 S2387918AbfG3TU2 (ORCPT + 99 others); Tue, 30 Jul 2019 15:20:28 -0400 Received: from mail-ot1-f68.google.com ([209.85.210.68]:36207 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727994AbfG3TU2 (ORCPT ); Tue, 30 Jul 2019 15:20:28 -0400 Received: by mail-ot1-f68.google.com with SMTP id r6so67509728oti.3 for ; Tue, 30 Jul 2019 12:20:27 -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=lG7iy+1TUm+VzW+0drIYHjU3Qdez5tE551tVEBNTmeo=; b=OQQuPmBcpMZJBJouO1aP91Dqm5eUdHs6vf8Es3y6gatwl7fi640xxXvrSF2orp8jgg mWDqfiijza5vmEP8V1sCwsXqhTJzcFycCdGjbwFB9FL0dvUQSdLXwaQckaD405bDvXeu pq66QciEHh3BNsSIWLZnw9pxvC3lJC0/HNKsb9d/WAnGlAEeWBXnj2mers2MQDqKwhwO SRQhEDYTpGoyXNvmpt0O3qyx+FYCpoY7x6PuXKtOKeTBuxDMR2xS1J6iZV0bBHEH8hoG y6azRXHRg0lTQovJi+biD14b6lJG9drbO/cWsLgXzEpmHKCzTdFnqoAPe6XWOYE6oO8P +emw== 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=lG7iy+1TUm+VzW+0drIYHjU3Qdez5tE551tVEBNTmeo=; b=qpFosxzCpNl++FEpG7gX0LNoRlqjmW646l0gkgOWV6TGiAoen5/aYak/h9kTeVGqs7 yXbc7jp+tBbl9KW1Mkd9G4/cb4cfdOk8l4RHu0f4jekDmnTkh7kQO+Iewhb1nvHjOXTS 5odVw19l7CMgUhFqT7VBQW1XNsCWoK2dREpkMiPixB+I4kzZWsTiKaGBS2y4f4tTRcBg h1AMhk1I6aWVfZ5okvVnmlhD+9HiFhSIaXHGKthqJo8YBdgAu/JSbktB9fJX5nORA/zn A/afmA21jeX2iOpxnQk9F3uGhfhOfRBjkSQBGLD+i60eV+P6LXgeYxJ/4yrsLOCMDUig OnBw== X-Gm-Message-State: APjAAAVmFpeNMh5EdqYvU6UKQsoYiw1vJvLQI3eKQk6cb3PbaSDSNTLL aCRZ3P7Ypdva2iG/uso5XQhul9LEcOIII+pWdDM= X-Received: by 2002:a9d:5f02:: with SMTP id f2mr1883265oti.148.1564514427329; Tue, 30 Jul 2019 12:20:27 -0700 (PDT) MIME-Version: 1.0 References: <20190730024309.233728-1-trong@android.com> <20190730064657.GA1213@kroah.com> In-Reply-To: <20190730064657.GA1213@kroah.com> From: Tri Vo Date: Tue, 30 Jul 2019 12:20:16 -0700 Message-ID: Subject: Re: [PATCH v5] PM / wakeup: show wakeup sources stats in sysfs To: Greg KH Cc: "Rafael J. Wysocki" , Viresh Kumar , "Rafael J. Wysocki" , Hridya Valsaraju , Sandeep Patil , Kalesh Singh , Ravi Chandra Sadineni , Stephen Boyd , LKML , 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 Mon, Jul 29, 2019 at 11:47 PM Greg KH wrote: > > On Mon, Jul 29, 2019 at 07:43:09PM -0700, Tri Vo wrote: > > Userspace can use wakeup_sources debugfs node to plot history of suspend > > blocking wakeup sources over device's boot cycle. This information can > > then be used (1) for power-specific bug reporting and (2) towards > > attributing battery consumption to specific processes over a period of > > time. > > > > However, debugfs doesn't have stable ABI. For this reason, create a > > 'struct device' to expose wakeup sources statistics in sysfs under > > /sys/class/wakeup/wakeup/*. > > I agree with Rafael here, no need for the extra "wakeup" in the device > name as you are in the "wakeup" namespace already. > > If you have an IDA-allocated name, there's no need for the extra > 'wakeup' at all. > > > +int wakeup_source_sysfs_add(struct device *parent, struct wakeup_source *ws) > > +{ > > + struct device *dev; > > + int id; > > + > > + id = ida_simple_get(&wakeup_ida, 0, 0, GFP_KERNEL); > > + if (id < 0) > > + return id; > > No lock needed for this ida? Are you sure? > > > + ws->id = id; > > + > > + dev = device_create_with_groups(wakeup_class, parent, MKDEV(0, 0), ws, > > + wakeup_source_groups, "wakeup%d", > > + ws->id); > > + if (IS_ERR(dev)) { > > + ida_simple_remove(&wakeup_ida, ws->id); > > + return PTR_ERR(dev); > > + } > > + > > + ws->dev = dev; > > + return 0; > > +} > > +EXPORT_SYMBOL_GPL(wakeup_source_sysfs_add); > > + > > +/** > > + * wakeup_source_sysfs_remove - Remove wakeup_source attributes from sysfs. > > + * @ws: Wakeup source to be removed from sysfs. > > + */ > > +void wakeup_source_sysfs_remove(struct wakeup_source *ws) > > +{ > > + device_unregister(ws->dev); > > + ida_simple_remove(&wakeup_ida, ws->id); > > Again, no lock, is that ok? I think ida's can work without a lock, but > not always, sorry, I don't remember the rules anymore given the recent > changes in that code. Documentation says, "The IDA handles its own locking. It is safe to call any of the IDA functions without synchronisation in your code." https://www.kernel.org/doc/html/latest/core-api/idr.html#ida-usage