Received: by 10.192.165.148 with SMTP id m20csp2810001imm; Sun, 29 Apr 2018 07:30:34 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpRg3eXqRWANhKmAu6aoISF6bZfgtduDyra29vP3fj5H6OR8IOFlJLBUAPPXmvXEadAvfd1 X-Received: by 10.98.50.198 with SMTP id y189mr3749863pfy.241.1525012234837; Sun, 29 Apr 2018 07:30:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525012234; cv=none; d=google.com; s=arc-20160816; b=nGLcM3DFi6KcZhbF/MwDrB1/6n8LVRPQ6NOoWaZJOSQbLTAigkIJliBTrgpu1eNaF5 2X7Uttv5cdThvdAkKFV8tTNnd+w1j/CjXNFf9NIv2paB5VXyatHhLxJjz0uUQKHwsBMS x7NNTtCdwXKTJImxSdfUmBQO4YXpDA01BtGeFGdygfnXVAP29kg2xGzcWuOPgEhi0GIb n6uxIUjkR/2Ov1kdYG+j9VTOM0Ggu9++fE93CkHwGJoiSwS7BpYbuh21olKS7sL0wqQX //0h0UUtcs/X9T62KKHsNNV3SL3C831DhqzQ0h60ldN2yYLaNYDeog4SIcOmxlVNRtdd BevA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=K56ULmRtuBdAWxi1/Qxk2kPM5KT+l6XXPTf1x2vvHV8=; b=B7w6+JBP2jXqj3Enbgg5Mu/1q/3Jvje99w8BRdcKzJCsQ3XNHe9RXEN5OU/E/iD1OQ K9TPULpblelllYyklxgkeMrzSFYoE0COncODCREJMemlY0bcVqruzpRertljzfrleryT OcdXdTWqQx8ZTGt62QflIFzMAkS9D8PMFzdt2s3jI6sfY3gpGl0ia0xAQo/4Y5sN+E6Y /ofrGXTFpuRWIKFfipzEZTawXu+57QCRfUkrRGhFFyJP0Uo9IMstMaudhZGVHv/jSGlC yPPZTHpoLTu/vrOhTcqXRT1puqSaCXJwJvQ27xGBIT/XbpAkd1c5W0aYoVsqSjsJ4qxf 2vYg== 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 b66-v6si5890579plb.107.2018.04.29.07.30.19; Sun, 29 Apr 2018 07:30:34 -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 S1753559AbeD2OaH (ORCPT + 99 others); Sun, 29 Apr 2018 10:30:07 -0400 Received: from atrey.karlin.mff.cuni.cz ([195.113.26.193]:52295 "EHLO atrey.karlin.mff.cuni.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752895AbeD2OaD (ORCPT ); Sun, 29 Apr 2018 10:30:03 -0400 Received: by atrey.karlin.mff.cuni.cz (Postfix, from userid 512) id 867A28044C; Sun, 29 Apr 2018 16:30:02 +0200 (CEST) Date: Sun, 29 Apr 2018 16:30:02 +0200 From: Pavel Machek To: Ganesh Mahendran Cc: rjw@rjwysocki.net, len.brown@intel.com, rafael@kernel.org, gregkh@linuxfoundation.org, geert@linux-m68k.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3] PM / wakeup: use seq_open() to show wakeup stats Message-ID: <20180429143002.GC13475@amd> References: <1524653971-10425-1-git-send-email-opensource.ganesh@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="8X7/QrJGcKSMr1RN" Content-Disposition: inline In-Reply-To: <1524653971-10425-1-git-send-email-opensource.ganesh@gmail.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --8X7/QrJGcKSMr1RN Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed 2018-04-25 18:59:31, 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. >=20 > This patch use seq_open() to show wakeup stats. This method > need only one page, so timeout will not be observed. Sounds like magic. > -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) > { =2E.. > - srcuidx =3D 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 =3D srcu_read_lock(&wakeup_srcu); > + list_for_each_entry_rcu(ws, &wakeup_sources, entry) { > + if (n-- <=3D 0) > + return ws; > + } > + > + return NULL; > +} =2E.. > +static void wakeup_sources_stats_seq_stop(struct seq_file *m, void *v) > +{ > + int *srcuidx =3D m->private; > + > + srcu_read_unlock(&wakeup_srcu, *srcuidx); > +} But you are holding srcu_lock over return to userspace, and somehow I don't think that's permitted? Pavel --=20 (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blo= g.html --8X7/QrJGcKSMr1RN Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAlrl1uoACgkQMOfwapXb+vLWfQCfec1XrdlLE0AwT0gWMJILdKJP fLgAoIqn6yp9O1011jbE2eSYNL1XyMHR =uMnk -----END PGP SIGNATURE----- --8X7/QrJGcKSMr1RN--