Received: by 10.223.185.116 with SMTP id b49csp8424591wrg; Fri, 2 Mar 2018 01:17:19 -0800 (PST) X-Google-Smtp-Source: AG47ELslHGXd74Di36Lzj2H2WfvVVdh94zk7i24JGjK+6qtxjQiim3SuNW/pWuReqnXIxCU4j+Cs X-Received: by 2002:a17:902:7b95:: with SMTP id w21-v6mr4648400pll.35.1519982239537; Fri, 02 Mar 2018 01:17:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519982239; cv=none; d=google.com; s=arc-20160816; b=GRtUkB4HY6vtPeq11AH9LcGNN0WV+RnrKYVWRXjC4bBIw5aNzTJG9vG//ghKc0BYFy TBvD3v+aqxTnr9wt5RxdXogAm/YD49uwcnqnsxyj2zBpIIgHSA+6wUyFhta4OpSWv6ql e+DDLwWsAAhPRMRRgO7fCq6lANwyb1Al5JJ85xRXVZYINdZ2BmDw1eUiBKYgvMEVJS3v uJnfuCh8sGxn3Xg9QKtITuaz/dy8JuWn3mQ18jsaDjo5gg643LxaovAmE+G+D7NDCynq m7rYOkg6a5Yhk1jQV2xYyhHevq47POHgjQE/KFiAz1ASxxRCICW5EbM5eCwIHxXCoL+M TSHA== 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 :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=Cq77KwqiuQq41gPTATyz48LLIIouWXaSgG5J87TmqVk=; b=Fhpo+uKpdBja3HoDHauXXkh3t0ZIf1MA/ZvkoC1SQv/WFhZESrjqMiHT2F1LkiZlNy 4GCagj6v87heWfoxpUwGjOjHuJ6WxmuT7mRFKrmlL0sOCzAJKB+jTMOfCUokPawdfhR8 rA5ZWPHfBdtvY2d2t/Nl6gaG/UmsqMEFDd/1zVtcw+hzIQa3xCJb3766X69nC0CYbEk5 AU7mWMG0yFgBlC6GXgRgUHXM5SH5l7MIdPjP1X852YZvk1iS5w/PbCEWo4XU83fDJofl Wh1av96PrGYVYVjbS3ZKH5fFypa7jiguRojRoDPqkDWTfKsTeRm6k7GTunc2s7CInQUg TNsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=lxhugijL; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y64si2699837pgy.363.2018.03.02.01.17.04; Fri, 02 Mar 2018 01:17:19 -0800 (PST) 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=fail header.i=@gmail.com header.s=20161025 header.b=lxhugijL; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1425356AbeCBJPw (ORCPT + 99 others); Fri, 2 Mar 2018 04:15:52 -0500 Received: from mail-oi0-f66.google.com ([209.85.218.66]:44592 "EHLO mail-oi0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1424852AbeCBJPq (ORCPT ); Fri, 2 Mar 2018 04:15:46 -0500 Received: by mail-oi0-f66.google.com with SMTP id b8so6577440oib.11; Fri, 02 Mar 2018 01:15:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=Cq77KwqiuQq41gPTATyz48LLIIouWXaSgG5J87TmqVk=; b=lxhugijLbEl0XxlUpednxdVYT7jQrr8z50IiN6YaihlWZWfQesfDwYMzj7fMnEQVEI nnteEk7/3QQS67xPcdy0jJmi+2EwmM5qccMr4AvYmPm5YINS4HA9tcJAFrC6q9fUjwpY p7W9IcCkG8H46WIR6/KJxkhj+zRL0msdFJwR8VaB9F5NO2bGMKwcUVg9/Bdx4EB9plPi 2HM11qwBN9iQAMkOkE61hLuaNE3u0l6MOKAEuX5xnpZGYdVFGahRxZMUITf5HKTG+5E0 7MpI2ONgvNGMC7rHYOn1HmBl4fN08EHe19tyP1w56zEl/GGrXQ43xD/RitfkaXJe3UXC 3ffw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=Cq77KwqiuQq41gPTATyz48LLIIouWXaSgG5J87TmqVk=; b=JpMEe8Uy1J0daO7q1DNVQpWjtdKnbCklFLsoc+zKwkif6aObQrteJTJ3a0gQS1l2DD 2jyKtjiMDRbcUEXKk62stnfKqWUkla2G+1r26++B8FAVeg/MZrMW8yYDJqmZ+YHGxrsn Ji4gQkw65jlWMCCfdi3vabI3UWPNhfIYDLyIHdlYoeMX4eCxyDu1oz0jj7hMj7GmnwM1 KvXV4SuUXu4dHdCh0EnmvBFVMPxjUCHJHN/5N6x//pzrSrRB7+oYmogYOVI2s8mwCqIC qR7wf+f4sYs3skBAJXwJxTw/HjiMSkKn6Qg/ymd1SPSaKDj+OFYSQzQ8JGfPSzdkj4Tl gX+Q== X-Gm-Message-State: AElRT7G0uyALZAm+j3mqwXu2il1+WHxyJwlEMYS9dPNOxws8dgm0D5hJ oQzNnqJedyDwmzr1BaqKJ8mF8l9JfGcphn28CWA= X-Received: by 10.202.71.211 with SMTP id u202mr3271127oia.227.1519982146009; Fri, 02 Mar 2018 01:15:46 -0800 (PST) MIME-Version: 1.0 Received: by 10.157.44.146 with HTTP; Fri, 2 Mar 2018 01:15:45 -0800 (PST) In-Reply-To: References: <1519966860-32519-1-git-send-email-opensource.ganesh@gmail.com> From: "Rafael J. Wysocki" Date: Fri, 2 Mar 2018 10:15:45 +0100 X-Google-Sender-Auth: 7QFZwPL0rqkuN8n5ltuqjROuIRo Message-ID: Subject: Re: [PATCH] PM / wakeup: use seq_open() to show wakeup stats To: Ganesh Mahendran Cc: "Rafael J. Wysocki" , Pavel Machek , Len Brown , Greg Kroah-Hartman , Linux PM , Linux Kernel Mailing List 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, Mar 2, 2018 at 9:58 AM, Rafael J. Wysocki wrote: > On Fri, Mar 2, 2018 at 6:01 AM, Ganesh Mahendran > wrote: >> single_open() interface requires that the whole output must >> fit into a single buffer. This will lead to timeout when >> system memory is not in a good situation. > > Did you actually see this problem with this particular file or is it > theoretical? > >> This patch use seq_open() to show wakeup stats. This method >> need only one page, so timeout will not be observed. >> >> Signed-off-by: Ganesh Mahendran >> --- >> drivers/base/power/wakeup.c | 71 +++++++++++++++++++++++++++++++++++---------- >> 1 file changed, 56 insertions(+), 15 deletions(-) >> >> diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c >> index ea01621..c64609a 100644 >> --- a/drivers/base/power/wakeup.c >> +++ b/drivers/base/power/wakeup.c >> @@ -1029,32 +1029,73 @@ static int print_wakeup_source_stats(struct seq_file *m, >> return 0; >> } >> >> +static void *wakeup_sources_stats_seq_start(struct seq_file *m, >> + loff_t *pos) >> +{ >> + struct wakeup_source *ws; >> + loff_t n = *pos; >> + >> + if (n == 0) { >> + seq_puts(m, "name\t\tactive_count\tevent_count\twakeup_count\t" >> + "expire_count\tactive_since\ttotal_time\tmax_time\t" >> + "last_change\tprevent_suspend_time\n"); >> + } >> + >> + rcu_read_lock(); > > The code running after this cannot sleep. Use > srcu_read_lock(&wakeup_srcu) instead. But generally, as Pavel points it out, even under srcu_read_lock() things cannot be delayed indefinitely (at least for actions other than freeing up more memory), so the entire approach appears to be flawed.