Received: by 10.213.65.68 with SMTP id h4csp1894503imn; Sun, 1 Apr 2018 18:35:18 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/zvQIr0Ccs5+11P/oCiJVas7K8dMMBL/GwqTzUUnOhmIsCh0M/j91KV22b3u7Gq0IULR9F X-Received: by 2002:a17:902:8c83:: with SMTP id t3-v6mr8002000plo.391.1522632918280; Sun, 01 Apr 2018 18:35:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522632918; cv=none; d=google.com; s=arc-20160816; b=g1iWkB4DzVn7vx0itJF3YJdjyVHPVPXeaxbO67r+vzg0bohkQ5VSWBGkbuLZ+76nep pGplhTLdJ5Ojm1yeSTE64PhJqdYP3OYuzNP0Shif5SgDH03J7d0H3prD3W42HI4NoVtW Qql2jzPCcJTzfCl/CSbyfcJrFcSD4EdIk+1pXsWXr/i8GxCHUk34YhrfN194t5xiKYj1 hK8IZ48/74ls/bWofGor/OIx1AiPm169aY15Lde/Zev6a78UWax9BoMKERtXl7Pb7esU Llvbcuf/hALc7XXZ6fYcMSZDjWLHSxXL7Qwtc2jHfL9E/tYDr16vUM1OOmKDaFdxTXHZ sp2Q== 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=kJaKmEqDQKPsoM7E/Om/e2bzJ+CsVRZjz70758pCtow=; b=t99uqUvQ4iWmkGl8HsLHU/ZVJXfJNXTpUgLflClfjzitQtLYFiw9lM/aW/PNgWZXCy Il2X3nQa8Z3vs44tbQHi6TLarZ1JelDTMv0Ak1NTvruyARgxh5Q/ZXZExG/ZoNsSxRGO 3frrOBeRtlIheXeCenGNQIeo9/qNMLGlX9JT/O7VlaUjrgoyX2LCdXmiLVPreEoJqHDK uWfrWjeHGgGB8hz5VBmSPJZxwQGgd26I23Fb0ENU/iHvQ6pNdWKR/qLaNVma1r7KP8e/ wetSScxZJW8Bpb99vT9lytHj5qo243snZYY4XvHPlAlhTvAs3BXVkuBGKC91K6R3ZoGK FMaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=f0ax9Co2; 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 o1-v6si5549977plk.330.2018.04.01.18.34.48; Sun, 01 Apr 2018 18:35:18 -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=f0ax9Co2; 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 S1754095AbeDBBdc (ORCPT + 99 others); Sun, 1 Apr 2018 21:33:32 -0400 Received: from mail-io0-f196.google.com ([209.85.223.196]:43861 "EHLO mail-io0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754033AbeDBBdb (ORCPT ); Sun, 1 Apr 2018 21:33:31 -0400 Received: by mail-io0-f196.google.com with SMTP id q84so16363542iod.10; Sun, 01 Apr 2018 18:33:31 -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=kJaKmEqDQKPsoM7E/Om/e2bzJ+CsVRZjz70758pCtow=; b=f0ax9Co2eO03samnXrUCA4VMG3D5x/uzdnP4de1HbVOLUGnE7MjZqL5mSt7zdrm7Ig Koej31v5VQ4oLJ4yrd3u/H2Zghu9f8LY67VvJ2YgbRzuamyP+5DVbRh5eNXqKE12ySwg R4T9rDvimzmgDKdzX8LQS78Vq0rBStzMCfiRd5s+b7V8q6z0VxmdYDOsRLKh3F2JQDoO 7xfnbeW3tao0D2gMWVRxkZNpT7yneHeZycMBFD2u5ipQGu5gYcng45YT+CH9TBNpoals 4mvYxUEXxh9MfFP/1UkdXlvn8HU+Y6ldbM8ZgtXx2Dpz+kySNGyDrYbhwBkbNq2mg4Qd +oKw== 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=kJaKmEqDQKPsoM7E/Om/e2bzJ+CsVRZjz70758pCtow=; b=myUV0yzC9Uw9Zupp5PutmAQoJ67jNZy9ioW8KRtcMud/ZEHMgqXbdZbDw2mxZdcaMJ 2VIm0+Let8ZJf/VRRpJXm47m56X4ff8c7FQgGySNdPtdjJIG6K+TNcDKvwfaPBsUyzUB n9AHUMNZ6pqkSLi1MDddNe3t0aVa48OWlrMwiwuUPW3jQ1RGUk1Q7PBq7BQ8RD/wz9s4 R0l9T+cJlWsGx8KXFYQPqf2rNcWvfNzVu8IxuQtBkMi2lmh31SE7qeAxLm3J+NzKlDWH D2sh5w6h+OG+ywIv2NfubYxJk3uLAp0JBObHgMMBEek0qkGYHryp0GNu4xChJo9tPxCV 3pOg== X-Gm-Message-State: AElRT7E8ctgo47c/HxK5hLCd8Z7w/4t0KHgPTA0S+lZpcXB72i1u1mKo XXKpu5iLOkOBnF9UFmX8JGdUnsTP15BjgAPcuk+Stw== X-Received: by 10.107.57.133 with SMTP id g127mr6367814ioa.52.1522632810763; Sun, 01 Apr 2018 18:33:30 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.168.153 with HTTP; Sun, 1 Apr 2018 18:33:30 -0700 (PDT) In-Reply-To: References: <1520239666-2964-1-git-send-email-opensource.ganesh@gmail.com> <2654052.UvzeiuBsVA@aspire.rjw.lan> From: Ganesh Mahendran Date: Mon, 2 Apr 2018 09:33:30 +0800 Message-ID: Subject: Re: [PATCH v2] PM / wakeup: use seq_open() to show wakeup stats To: Geert Uytterhoeven Cc: "Rafael J. Wysocki" , 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 2018-03-30 19:00 GMT+08:00 Geert Uytterhoeven : > 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. Hi, Geert We need to locate to the last read item. What is your suggestion here? Thanks. > > 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