Received: by 10.213.65.68 with SMTP id h4csp204209imn; Fri, 30 Mar 2018 04:02:23 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+dd1mLHiyrEKgMmCFOgyWew3gqkW3x6R1WRn2LonbX7V7EcJ8z+H/2P9r0H/Rw06JmaWOG X-Received: by 10.101.72.136 with SMTP id n8mr8209051pgs.201.1522407743111; Fri, 30 Mar 2018 04:02:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522407743; cv=none; d=google.com; s=arc-20160816; b=R856Td88EMGFM0oeuDcEPtkxp4+pKiCAGt9U/DE9OSi3l6XpaiqRr9b3RNGOtPjC6h LCaKiP/2qVy20AMLXdYjN0sYaO697Gvy+OtJufe6AVpi1a4suZtNW2aoK88waUMvX1xO QvEwIEVfeDsIhZGjKpPX6C7wkUlHyOkl8J6R75MJajPxLGsA6lUrPxiNHxFfG22Lmzuw iWmHDxe+7ZCZGBMY8kALtV+6jowT3szxVDGKLveomuLDt+ONXjA8gm9sWeeGMjdvGJja FFk3D09H3/siYlOK8MwVaUR1JC6nsscRN3YQIsGPgnJJenH3IOMOwpMvsnWCt6KRranl Y03Q== 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=AmiR6Qy69CjjEl/LBxnYLJg40k1yVE7wk9EyK6oCDyA=; b=vCYyBjhI+EGmctvmT3gtTQLi4uc5zrbMp1wZHpdZym8RLnHqUrL1aZcF6rRzpBFvcK ZwDUwJ+oYuPZ/ZxL90Uoe9O3T1fO6avuBTt9bKWZ0G/+ZfnBT2riaHzZa2o5FNFV/hx0 0efT1BSbj+QINA+QMeMHzP8e3iG6L8+AM9Mb+G8WFV/GTpE/DyAcb9k4CcYpvSM/R/Cm 8mTVMn9jYZQe/8AvnsxsUOEI+6uWtz6rvmMk30kU+PkFCSLSvbagRGj31YzyCXDW1GNS ELLOcytS6BPSB+dhIh7DkYCFYqCdHTMkiOPIVRFAbP0Y4JUInYr5tRpDy0S5sbnWMMLR MukQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=BsZwp+zF; 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 x10si5495099pgt.109.2018.03.30.04.02.08; Fri, 30 Mar 2018 04:02: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=fail header.i=@gmail.com header.s=20161025 header.b=BsZwp+zF; 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 S1751403AbeC3LA1 (ORCPT + 99 others); Fri, 30 Mar 2018 07:00:27 -0400 Received: from mail-qt0-f193.google.com ([209.85.216.193]:39072 "EHLO mail-qt0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750794AbeC3LAX (ORCPT ); Fri, 30 Mar 2018 07:00:23 -0400 Received: by mail-qt0-f193.google.com with SMTP id v11so9082180qtj.6; Fri, 30 Mar 2018 04:00:22 -0700 (PDT) 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=AmiR6Qy69CjjEl/LBxnYLJg40k1yVE7wk9EyK6oCDyA=; b=BsZwp+zFM7q0LPxFBGjPjVJWvxNteIpnj8f3D2+K7jTDbJbkZNFeX5DK1kQH1d6f5O EuYhx9orjAXB+8FcWpbPcHLzwA46XRMaF5PeYzwZHjgw/C12hKZsV/9tt2amBRqiqHS/ 73UkkZt5nsqR4uYdWDVPODuvTjwtoe1+PR3g1SPvgRG3A9aijRu9+c07RPV4XlTYBgdj AmO32o5RDyqrcNaXkpx0WDZ8cpdYc6xvtcKcqr1fQWTsNRxRNBKE1YhqSIBzBYT2yex7 DhZonaThHSeyDEbKW+yj9ojG5eGjcEi+evapo7pqDzKAeq5fj6mBfpp8xTRzZzbeaaF5 /rnw== 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=AmiR6Qy69CjjEl/LBxnYLJg40k1yVE7wk9EyK6oCDyA=; b=p9H+2MmLSVeb/Fyb/GDk9oLq+q+YAo//GU34AiHsbJC3reXOw5AL8xquX6o9GvGY00 6fyWvuiDffzbycT3aqfP9i+dDig7JA4ooqOwll1GyoL5uIXgQ0kveKFipIxpYOLDafP2 t0UBIp/tFxGtYvTTxKzKugRg+8jm9uY/T+Bj764OIZD023YOtxn1N/fIcDPNZ0yr7t7L U1dZ44GD9x2+9MDm8B9D6pyReLPhf3h4XiQLu3kI1mR6d3HeJRtXPa6GeoYidekKfSD+ NK/f3uWFdS6BVaxbWNCO7ekwxsgdG4orzoyoECdyauwltGOUKnZUxviPBsy9e4/rIXP8 eIyA== X-Gm-Message-State: ALQs6tBLc5jEwnCzgtm+HVH6bd5PH0TPcRp+Ed3CxkaiLzA8Ze81A6cK TVmxu7/LfD7WQOODGXtWytphbWfuDw+OcBVqsiI= X-Received: by 10.200.28.61 with SMTP id a58mr6044874qtk.280.1522407622318; Fri, 30 Mar 2018 04:00:22 -0700 (PDT) MIME-Version: 1.0 Received: by 10.200.54.147 with HTTP; Fri, 30 Mar 2018 04:00:21 -0700 (PDT) In-Reply-To: <2654052.UvzeiuBsVA@aspire.rjw.lan> References: <1520239666-2964-1-git-send-email-opensource.ganesh@gmail.com> <2654052.UvzeiuBsVA@aspire.rjw.lan> From: Geert Uytterhoeven Date: Fri, 30 Mar 2018 13:00:21 +0200 X-Google-Sender-Auth: naRNO-1I-TMK2sud33ONW2RoBnI Message-ID: Subject: Re: [PATCH v2] PM / wakeup: use seq_open() to show wakeup stats To: "Rafael J. Wysocki" Cc: Ganesh Mahendran , Pavel Machek , Len Brown , "Rafael J. Wysocki" , Greg KH , Linux PM list , 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 30, 2018 at 12:25 PM, Rafael J. Wysocki wrote: > 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. The continue is also not needed, if the test condition is inverted. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds