Received: by 10.213.65.68 with SMTP id h4csp1252928imn; Thu, 29 Mar 2018 00:51:23 -0700 (PDT) X-Google-Smtp-Source: AIpwx49eYjbFwOpjLK2G39aAEH0SQTCMstWzPCvLRRdZbyhgMiqOPeZM1gi0woQUo8qDyabB4HPj X-Received: by 10.98.157.6 with SMTP id i6mr5577760pfd.52.1522309883193; Thu, 29 Mar 2018 00:51:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522309883; cv=none; d=google.com; s=arc-20160816; b=UqWIyfWOsG8PqQduz+JoqRyViRoQGRzHJHC8ZxzfqKwIHAow79PyJMxh09EDYzfy9H HbYGJJLwfjzOYqQ1dduzQIVNIISYbbbuvhiBAzZV2kqPZmr0x49vmOt4t+oA4dSAraPt iGyQdWdCBqCSt6fUxvsyd0B5hVw3Saj+1dF5iKw0egtrfR1Sq+Y9VE8emmcW0yg736St y0mSay9P9IUzf1CXn1/D5SpAznuy8w+vBobKVBeqGDDFj/3QM8RPEKppSqHAu+KyUaD3 J0dDSrsLT3vnA8eiBelrk8YgDd0kP6bL+80xBZzUd8/lTjvTXQS810s0ZVfiDna8feEe flIQ== 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=kvOtzOYt/tilGXTpXb58c46ymOiqWn/Z81SdBptJL3Q=; b=I4TsZIYYYVLrMuSHMLLDmerMK1Bw8DSl2AdFQH0p/sk2tGba705gE3f+72XC2M/ehP rC4zhI16ORRYO7jL3/QBaQdpq7boxR0yEuwkDLsBA6We1oKgjc1CI2b1dkzTjHCw21M3 6XGBovTXYsoX/w4yfpzKd7xAYkEIxEjRR9R+lrE1ZT1doyxMONghNtOC/U/OORSr5QSS Y6X9wrCtZhEB0y+1JUoFWUZP59hxRwg8Js4RZLrgJJCb5VpoE42r5Mv1d6iTykhZhZAu 0yYwrI6OS8Z3Lo5OoUaPxY6J4gW1bQmGu6LZ+Svd7pmZxeK7WtiG2CcWsMFRZSuIjLk2 b02Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=O1x9mTIm; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s9si3651503pgr.708.2018.03.29.00.51.09; Thu, 29 Mar 2018 00:51:23 -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=@gmail.com header.s=20161025 header.b=O1x9mTIm; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751973AbeC2Htq (ORCPT + 99 others); Thu, 29 Mar 2018 03:49:46 -0400 Received: from mail-io0-f195.google.com ([209.85.223.195]:41039 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751230AbeC2Hto (ORCPT ); Thu, 29 Mar 2018 03:49:44 -0400 Received: by mail-io0-f195.google.com with SMTP id m83so6602843ioi.8; Thu, 29 Mar 2018 00:49:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=kvOtzOYt/tilGXTpXb58c46ymOiqWn/Z81SdBptJL3Q=; b=O1x9mTImCU8RjlDNp9EEWRpyWkvj28MOElPfnDNl0CJXxai1XO7LewFVwmRzCySpsz XkP1LuVUweFYoUcuyUekpzfOswlxwV0ieEda/WB1kosHvJ5nscV3ZJmcrnRuK7t4GrcB Lg3UodV2f14STgGUJ63CAZtARRuwBDx5GvHZcjzS5eSgsrAn3XQPVD5vL7tqwm3MvyoI Fwja9AdZzQQYNctjiL1bnmMrZTKkxI77FTtDP3+Oz5VsYX6rNkbVbdOadJmBYffLUTu8 i+9Vxien9g/t3IZfSCOK1t0mVef108+vARGPvn3lGV2hTrHt4H3ESSYfUKDrD5xgKNVp oYDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=kvOtzOYt/tilGXTpXb58c46ymOiqWn/Z81SdBptJL3Q=; b=IKN9LeDC4J1VlTwCvj9sta//ZgpwdT0PSnex6NFV6WEGu+iLWCCHuzmsUOTZ1ujJUV 0cbF3h3t8t4Ge/ajT7CN8BbdM9SRJkvunO+gMV/U+pmE3HegBS1gmQV2h7CJouriBdSd moQvLeEJserOQbfo0zmeU6x4XpUBtWq+VPiC9BIbYP5YESBZL2+bhaNH/338rZOJb+tf ZXZvIL0sApU7ut6mWxdAROC/W3a2zBEDCoR6N7LzncBAYX8DTfyEdbtGA4jMeWHvT40a SkMoPPwIJqLam7C50LAEkTbzUGSBdXDfO44A0/0UqZNvzMIavzfAGIg01relE/mCl4Ua O9/w== X-Gm-Message-State: ALQs6tANcsvJURZx8uzW4ODSNLHnncSpKFVuH8z510OIQOjajuPiLx8o m8JJnNr4DevWyv3Qdj3xq5k0lfBnZIvyJE3NDy0= X-Received: by 10.107.173.41 with SMTP id w41mr393105ioe.126.1522309783699; Thu, 29 Mar 2018 00:49:43 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.168.153 with HTTP; Thu, 29 Mar 2018 00:49:43 -0700 (PDT) In-Reply-To: <1520239666-2964-1-git-send-email-opensource.ganesh@gmail.com> References: <1520239666-2964-1-git-send-email-opensource.ganesh@gmail.com> From: Ganesh Mahendran Date: Thu, 29 Mar 2018 15:49:43 +0800 Message-ID: Subject: Re: [PATCH v2] PM / wakeup: use seq_open() to show wakeup stats To: "Rafael J. Wysocki" , Pavel Machek , Len Brown , "Rafael J. Wysocki" , Greg KH Cc: Linux PM , linux-kernel , Ganesh Mahendran 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 ping. 2018-03-05 16:47 GMT+08:00 Ganesh Mahendran : > 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. > > This patch use seq_open() to show wakeup stats. This method > need only one page, so timeout will not be observed. We have resolved the watchdog timeout issue by this patch. Please help to review. Thanks. > > Signed-off-by: Ganesh Mahendran > ---- > v2: use srcu_read_lock instead of rcu_read_lock > --- > drivers/base/power/wakeup.c | 77 +++++++++++++++++++++++++++++++++++---------- > 1 file changed, 61 insertions(+), 16 deletions(-) > > diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c > index ea01621..3bcab7d 100644 > --- a/drivers/base/power/wakeup.c > +++ b/drivers/base/power/wakeup.c > @@ -1029,32 +1029,77 @@ static int print_wakeup_source_stats(struct seq_file *m, > return 0; > } > > -/** > - * wakeup_sources_stats_show - Print wakeup sources statistics information. > - * @m: seq_file to print the statistics into. > - */ > -static int wakeup_sources_stats_show(struct seq_file *m, void *unused) > +static void *wakeup_sources_stats_seq_start(struct seq_file *m, > + loff_t *pos) > { > struct wakeup_source *ws; > - int srcuidx; > + loff_t n = *pos; > + int *srcuidx = m->private; > > - 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"); > + 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"); > + } > > - srcuidx = srcu_read_lock(&wakeup_srcu); > - list_for_each_entry_rcu(ws, &wakeup_sources, entry) > - print_wakeup_source_stats(m, ws); > - srcu_read_unlock(&wakeup_srcu, srcuidx); > + *srcuidx = srcu_read_lock(&wakeup_srcu); > + list_for_each_entry_rcu(ws, &wakeup_sources, entry) { > + if (n-- > 0) > + continue; > + goto out; > + } > + ws = NULL; > +out: > + return ws; > +} > + > +static void *wakeup_sources_stats_seq_next(struct seq_file *m, > + void *v, loff_t *pos) > +{ > + struct wakeup_source *ws = v; > + struct wakeup_source *next_ws = NULL; > + > + ++(*pos); > > - print_wakeup_source_stats(m, &deleted_ws); > + list_for_each_entry_continue_rcu(ws, &wakeup_sources, entry) { > + next_ws = ws; > + break; > + } > + > + return next_ws; > +} > + > +static void wakeup_sources_stats_seq_stop(struct seq_file *m, void *v) > +{ > + int *srcuidx = m->private; > + > + srcu_read_unlock(&wakeup_srcu, *srcuidx); > +} > + > +/** > + * wakeup_sources_stats_seq_show - Print wakeup sources statistics information. > + * @m: seq_file to print the statistics into. > + * @v: wakeup_source of each iteration > + */ > +static int wakeup_sources_stats_seq_show(struct seq_file *m, void *v) > +{ > + struct wakeup_source *ws = v; > + > + print_wakeup_source_stats(m, ws); > > return 0; > } > > +static const struct seq_operations wakeup_sources_stats_seq_ops = { > + .start = wakeup_sources_stats_seq_start, > + .next = wakeup_sources_stats_seq_next, > + .stop = wakeup_sources_stats_seq_stop, > + .show = wakeup_sources_stats_seq_show, > +}; > + > static int wakeup_sources_stats_open(struct inode *inode, struct file *file) > { > - return single_open(file, wakeup_sources_stats_show, NULL); > + return seq_open_private(file, &wakeup_sources_stats_seq_ops, sizeof(int)); > } > > static const struct file_operations wakeup_sources_stats_fops = { > @@ -1062,7 +1107,7 @@ static int wakeup_sources_stats_open(struct inode *inode, struct file *file) > .open = wakeup_sources_stats_open, > .read = seq_read, > .llseek = seq_lseek, > - .release = single_release, > + .release = seq_release_private, > }; > > static int __init wakeup_sources_debugfs_init(void) > -- > 1.9.1 >