Received: by 10.213.65.68 with SMTP id h4csp176140imn; Fri, 30 Mar 2018 03:26:52 -0700 (PDT) X-Google-Smtp-Source: AIpwx49vJPx5Tvucn3hgHIlVG8uzwjPVUbgB7PRPV6gv9AwM9T1Z7crmiwnA6VjmZ32SF7eZbppq X-Received: by 10.99.126.87 with SMTP id o23mr8110984pgn.350.1522405612123; Fri, 30 Mar 2018 03:26:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522405612; cv=none; d=google.com; s=arc-20160816; b=GvfH2cnFDxV+dMa9NWgFluYoJV9S1xY2bDAT3lIMCR8n161UgfGvCVY9fpnLKqQPV8 j1oIfI9OpPU1rq/XHfE+MAC/jikiequEdBem0uSp9r3blD0Q7s2P3yc0W9RZRqJakiuk m6wdYpK/SWN1kCjcE4xdPLR8aq8GHZJzljgrqrQ5ocr3J3z0xMJMNtRj/khqClrvfRTl /C9EEANV8eokslodXEukjEm7uOHh5ca6wJstb5zrJb9JKIt5c0KTYsqe71xbG7xFyeM7 7gkbgB+MaojpdlWQnTwhb7xBCRgKzfGKSHLIUMoVEUXdKfOsjh+RGLkf/mW00zEv5jc4 z4WA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=JdXFXPnaT3CcQTXe3czAjgn2Gk8FUxzNGO5FkZtnLEY=; b=RG9zdZzImC+5VWYKb0hG/KFKxFWPb8AbiqFM32HSqMKDVIxazixF6ivQNEqNgXTYgm PPhYpGtlsdAFuqOOcLxL2KGtFQCwtEX8wBGWGgoPjVn7dsdQLXNKmW5tDQb5cluKvNtj //mZ2M2GYjAQJjDxfSu7kqerYMwKXaNkC7cd/4QOUjy4lsoNQbgdtg6VC4E2DNmLfc+X LzsfzfBI4skr+p2wg4hF1OLihCNhqkl9M4QEqKf53qeS3/M4gzqaoAyn8Q3z5uXEsdmG AWUPb2t3Jn5Z9NjQf/q7/CmR1SrOHDik1xU6+SrzmTg88PDBmCWy4c5w3Rj0hIDQ+DqB ab+w== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u188si6154868pfb.220.2018.03.30.03.26.37; Fri, 30 Mar 2018 03:26:52 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751237AbeC3KZa (ORCPT + 99 others); Fri, 30 Mar 2018 06:25:30 -0400 Received: from cloudserver094114.home.pl ([79.96.170.134]:62255 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750765AbeC3KZ3 (ORCPT ); Fri, 30 Mar 2018 06:25:29 -0400 Received: from 79.184.254.228.ipv4.supernova.orange.pl (79.184.254.228) (HELO aspire.rjw.lan) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83) id 548d614006b39872; Fri, 30 Mar 2018 12:25:28 +0200 From: "Rafael J. Wysocki" To: Ganesh Mahendran Cc: pavel@ucw.cz, len.brown@intel.com, rafael@kernel.org, gregkh@linuxfoundation.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] PM / wakeup: use seq_open() to show wakeup stats Date: Fri, 30 Mar 2018 12:25:46 +0200 Message-ID: <2654052.UvzeiuBsVA@aspire.rjw.lan> In-Reply-To: <1520239666-2964-1-git-send-email-opensource.ganesh@gmail.com> References: <1520239666-2964-1-git-send-email-opensource.ganesh@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Monday, March 5, 2018 9:47:46 AM CEST 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. > > 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 > ---- > 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; > +} Please clean up the above at least. If I'm not mistaken, you don't need the label and the goto here.