Received: by 10.192.165.148 with SMTP id m20csp545284imm; Wed, 25 Apr 2018 04:02:40 -0700 (PDT) X-Google-Smtp-Source: AIpwx49h/GoYQOZJJ/kdf4p/jLxoI2vaBGAhhQHgOXLbSHIUCwstF9S5qYGVguc5vR4u51MFjYP8 X-Received: by 2002:a17:902:43:: with SMTP id 61-v6mr29221581pla.112.1524654160113; Wed, 25 Apr 2018 04:02:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524654160; cv=none; d=google.com; s=arc-20160816; b=JiiBd5fzd6qwUg7GpMrp4euTNDQJMdSguS6XTf6fqQ46PUSjck3el3KDphG9Hmhwhe wZ2y/LgPlUbH8IQ7kQoE2cBd1edzsHy+flhiHNCILPs6h5buUHQeMPNf/UkavENt/tOP 07dbcnNx7cqOOAWOA05Jq8E54Dl4yig+rUtWeGbELg6n9fdOOo9dvbwWAIET0gC/pPfI e2cU3gPsIKOPmmUGj64OzG8shhZvwQxQxb9KvfftfJaDnHv65ThhEGso9dGwucCkJMIZ bxL5N/v4t0frwahdWYV7OHPYMOdCHYuwB0fg5jp0ngJj/CxuCReOjEJBgwou05lRFb0S S/Wg== 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=qmH/Et6KsE30MSoV2TvTkXGf24X1WDPyFXFbSUAEGH0=; b=Kjp5ISGKGrAVt/0eJnRK8FAXhuyUBiiyNJF6uWmNvVmSUQGpO0npx1rMqn7AtpnWNC JmZdG81UTi3mYLLXegkxo+7HjgKX3mbBxutahQmYKzlrV5GnJUducc28n8AOakx7PU7C Vz9Q0iO+2bPnfWMOMksCzX+KrydiHYE+/NlRDwL4qPRmgBvyty+qtZMliqUDUlrC5Ji6 /2wO5TvDtx4PzNLzUt/06UEQWs05VKVbmZJVVA7593H8gHUQRiNdpL0Kv8MHWNAQE934 viFAJnJQ3saG7uLnqJhOcXzelzSgPncbofi+Mjw6uT+DXzaVG981v3emh1zFmfs7b2zS HVBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Y96z5nft; 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 g3-v6si14845714plp.471.2018.04.25.04.02.25; Wed, 25 Apr 2018 04:02:40 -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=Y96z5nft; 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 S1754351AbeDYLBW (ORCPT + 99 others); Wed, 25 Apr 2018 07:01:22 -0400 Received: from mail-it0-f67.google.com ([209.85.214.67]:36805 "EHLO mail-it0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754334AbeDYLBS (ORCPT ); Wed, 25 Apr 2018 07:01:18 -0400 Received: by mail-it0-f67.google.com with SMTP id e20-v6so18833833itc.1; Wed, 25 Apr 2018 04:01:18 -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=qmH/Et6KsE30MSoV2TvTkXGf24X1WDPyFXFbSUAEGH0=; b=Y96z5nftyxb0r2HqxgU5Kzfkwkmscy5+/dtabShCotr7sBf7cqc7Ie+kpTlAGQtYeA jF5Bnhvn134vkXjqQJ5EEv0clBxxbSG8lHIhEYlAR1x7OxHFwCBhtPTLH82Pouyv8rsh ld4kkLhD1TQ3JsOhQYFvv12EvMUVzewtIKN6KZC8spY7WIiRO4Rdsy0LQY6WzT8ifUeO v92q9c3pGSmwymMOUcaawcYi4z+RlsV2r3/FZ0sImnko9mMTvisgi9ookCGuXKg2Nbnq i+UvtbbNkAyWUIbwsCWcpitCRRecDGUBuV4QBV4bZXniQfp3pZaIy+wqAE4RlX/Adc8S toQg== 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=qmH/Et6KsE30MSoV2TvTkXGf24X1WDPyFXFbSUAEGH0=; b=Hm/5VF2pECPlB0pRadVQ8fFlRns8tKGI4cbTduAgkr0HENy0Yx2pYtREa/myuQXjT1 Y63KGglT4pzJUZChtoq6o2sPQkmI5a127ualhbGaghcrRJobj8a/VHfzphXMZxKjVLk3 zMOY4PmuGpFx9NiEK4ouzm3SXhDn7IbE94Bs/t2BUVbV7WV9tGIdNfYkdsS8Wwci7ufz cSJIw2wesu1kFnhZq9VdayPMq/M5mKcwGHSFq5DyBgOTbOSfVqrmsT0HvBYnd1J3TCTl hqPfdRC9j/qTP29mk0rlBhOWqF9OHEyogP4oIfW506jNXGGVIB1XrCyq2jCuYYTO2Zb/ UDGw== X-Gm-Message-State: ALQs6tB5r93XLR73vsfSIfdaz+MmV+KT5aV34UTleYGtPOwrNdda7OiM Ak5G8zSl/0lz6iN8D0dJXL8cnWeyRc8kP2bZW39gqA== X-Received: by 2002:a24:e3c7:: with SMTP id d190-v6mr1347527ith.22.1524654077646; Wed, 25 Apr 2018 04:01:17 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.140.23 with HTTP; Wed, 25 Apr 2018 04:01:16 -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: Wed, 25 Apr 2018 19:01:16 +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-04-02 14:46 GMT+08:00 Geert Uytterhoeven : > Hi Ganesh, > > On Mon, Apr 2, 2018 at 3:33 AM, Ganesh Mahendran > wrote: >> 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. > >>>>> --- 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) >>>>> { > >>>>> + 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? > > I didn't mean to get rid of that logic, but to reorganize the code to make it > simpler: > > list_for_each_entry_rcu(ws, &wakeup_sources, entry) { > if (n-- <= 0) > return ws; > } I send a v3 patch. Thanks for your review. > > 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