Received: by 10.213.65.16 with SMTP id m16csp175199imf; Sun, 11 Mar 2018 22:34:24 -0700 (PDT) X-Google-Smtp-Source: AG47ELtyOcIYCN4Yh0mOqQN9BDGQonmlhpXfczE7wGloOcS+B81A3+99xSQ4/ISfsV77bU/gYPbW X-Received: by 2002:a17:902:2e43:: with SMTP id q61-v6mr3090543plb.404.1520832864776; Sun, 11 Mar 2018 22:34:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520832864; cv=none; d=google.com; s=arc-20160816; b=rGNtuU32QzuEP6HSA4PmuprneNVxMD3akkoJ5NUZYGgMYPdGKKcXpHpTZSeVA27xa8 4y/9dhwaW+Q6q6YQr2NH/ugEDeMVzbu2ibNAMsNEq6PTzDmxMciQrfjV+riI5gnhc66/ pgGNiPrpGe+/lvNSTAZ/4zjArPzvbmlV3wI2nHzyX5PehBBK68bJy13Hfm+pP2S7IgX4 xBsNBMUU4O2KLPlTa3qvsLebQLBPnxdl/Tp5juMVGIsZi3+5mZSr/hvwwlIxVcjbUkS1 DaeH8VnDRmwfKkFxW297UlWcspZN55FzxrJm11qsu2ZhRPHXhmE+/3829XmMu39wrtcj tBoQ== 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=athTWfq0BGtTLdyMVzUWpYs1AF9f/8/2j8JGc4Oq0HE=; b=PW+6EMDa2ToCCXp9Vbs6IkQV1HkejWwCb2sb6eKuHgG+uNa+L9jrsf4TsemuPuBClr C5EimFt3QHK+3hdfEuVTdss4BZ6bo6SewjCdUG1TM3X5C9M+Yzj1EjdtRwO2AqjmYv4M jTK/4bzPSw4rQ9ZWghdTxLZzJfU1xikm79NqMUIrL/+HwdB2F8Th5RDy4YXuaUaMdPvx O/hLusUC2wV9Si9I1xn3kx94R12T3ivk+rJAglL/VmFFVmfzAGp+2Uyn4CRhqfAImRUL U8ryjV9KA8Iw3Ux+akeC2/4ncu9LZ3jZBO5CFvvah8pOSxDERlEFrG1b9nENUC6UW3Pk 8kpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=AAZ4ckzF; 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 b126si5294678pfg.7.2018.03.11.22.34.10; Sun, 11 Mar 2018 22:34:24 -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=AAZ4ckzF; 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 S1751574AbeCLFdJ (ORCPT + 99 others); Mon, 12 Mar 2018 01:33:09 -0400 Received: from mail-it0-f66.google.com ([209.85.214.66]:54777 "EHLO mail-it0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751234AbeCLFdG (ORCPT ); Mon, 12 Mar 2018 01:33:06 -0400 Received: by mail-it0-f66.google.com with SMTP id c11so9538118ith.4; Sun, 11 Mar 2018 22:33:06 -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=athTWfq0BGtTLdyMVzUWpYs1AF9f/8/2j8JGc4Oq0HE=; b=AAZ4ckzFDJYfcC0tYvK7jwl/mYpZqqpKu2IGG7cmIs+0XUqYBhuocPimDBtJAwtIPc ZLIq/OpH3RoB2wGAIkBWIhnIFbhCmkisEfNsBrUOXVTvGnfbJVnXWzxRPreCTZSSb3UA Yb+Ks2EAhm63YLUFdOLTrPlBMiiKBfLjwYVHIE201rjOX3hp5HnTFr3l30RyWZkYGwWz rKpMq1lUeLqUF3zYP4JqsBKk5YckY/VsZPzI6KdAAM1a+OYGH6venaXZhbMgyZS9dm4T e6q36bKGhFRsghlTSwpf9mFj1NKHuQJ59gjSqBIRNLCkmOcSY56gD/7KbxnOncqFjGf9 kRfA== 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=athTWfq0BGtTLdyMVzUWpYs1AF9f/8/2j8JGc4Oq0HE=; b=rYoO/xXyZKJ/mH9GRalVdzIuCjkTTayKmfXPj+tCJgvsB5w+1hojK6CLSR5U32Ugek QlWoDn+aGNXTE5PFYbvhIYYwl9s5bNuzNeooqL/JZ4Y3JyRHv/xEJCUozkKHdzxrKsSF 7M9ROp6nzlhiUpx/6PG7NydSDkwFuxlA8tWrL3+Qlyioqile4V17Ca1CcoapiwsB/fii 4FW1D+vXVm85U3XeO8+sJBIfOoNrScmZaFN+QvUIa61mPzOpIUMZ9wbjJCWGnnh7gFoK b42gkaNoMYo4sg8HQ5EuNXj2uvpEEH1RM2NqQ9PR56km2XojwKVo6OwCt1YzzrRLBev8 +nVQ== X-Gm-Message-State: AElRT7HiiiPaqrQrQs3WFsbf1pkUKelZcDYv/v8hbx3CqmkbCbRL2dL3 a8G2IHn3T3ao3epMx9wCNgAKSyyMUtPQauUbOSw= X-Received: by 10.36.189.129 with SMTP id x123mr7639197ite.13.1520832786087; Sun, 11 Mar 2018 22:33:06 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.59.71 with HTTP; Sun, 11 Mar 2018 22:33:04 -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: Mon, 12 Mar 2018 13:33:04 +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 Hello, Rafael: 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. > > Signed-off-by: Ganesh Mahendran > ---- > v2: use srcu_read_lock instead of rcu_read_lock How about the V2 patch? If you have other concern, please let me know. Thanks. > --- > 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 >