From: Steven Whitehouse <swhiteho@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] seq_file: Use larger buffer to reduce time traversing lists
Date: Fri, 01 Jun 2012 13:24:46 +0100 [thread overview]
Message-ID: <1338553486.2708.25.camel@menhir> (raw)
In-Reply-To: <1338552626.2760.1510.camel@edumazet-glaptop>
Hi,
On Fri, 2012-06-01 at 14:10 +0200, Eric Dumazet wrote:
> On Fri, 2012-06-01 at 11:39 +0100, Steven Whitehouse wrote:
> > I've just been taking a look at the seq_read() code, since we've noticed
> > that dumping files with large numbers of records can take some
> > considerable time. This is due to seq_read() using a buffer which, at
> > most is a single page in size, and that it has to find its place again
> > on every call to seq_read(). That makes it rather inefficient.
> >
> > As an example, I created a GFS2 filesystem with 100k inodes in it, and
> > then ran ls -l to get a decent number of cached inodes. This result in
> > there being approx 400k lines in the debugfs file containing GFS2's
> > glocks. I then timed how long it takes to read this file:
> >
> > [root at chywoon mnt]# time dd if=/sys/kernel/debug/gfs2/unity\:myfs/glocks
> > of=/dev/null bs=1M
> > 0+5769 records in
> > 0+5769 records out
> > 23273958 bytes (23 MB) copied, 63.3681 s, 367 kB/s
>
> What time do you get if you do
>
> time dd if=/sys/kernel/debug/gfs2/unity\:myfs/glocks of=/dev/null bs=4k
>
Yes, you are right that it will be slow, still. But I'm not sure what we
can do about that. We have to find our place again on each read call, in
any case I think.
> This patch seems the wrong way to me.
>
> seq_read(size = 1MB) should perform many copy_to_user() calls instead of a single one.
>
> Instead of doing kmalloc(m->size <<= 1, GFP_KERNEL) each time we overflow the buffer,
> we should flush its content to user space.
>
>
>
Yes, I thought of that... there is a potential problem though. Is it
valid to do a copy to user while between ->seq_start() and ->seq_stop()
in general? These might be holding locks which may potentially be
required during a page fault caused by the copy_to_user(). Thats not an
issue in the GFS2 case, but I don't know if it is generally ok to do
that. I assume that is why the results are buffered rather than being
directly written to userspace anyway.
As soon as we do a ->seq_stop, then we have to go through the whole list
(assuming a list based data source) again to find our place :(
Steve.
next prev parent reply other threads:[~2012-06-01 12:24 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-01 10:39 [Cluster-devel] seq_file: Use larger buffer to reduce time traversing lists Steven Whitehouse
[not found] ` <1338552626.2760.1510.camel@edumazet-glaptop>
2012-06-01 12:24 ` Steven Whitehouse [this message]
[not found] ` <1338554890.2760.1517.camel@edumazet-glaptop>
2012-06-01 13:14 ` Steven Whitehouse
[not found] ` <1338557229.2760.1520.camel@edumazet-glaptop>
2012-06-01 14:18 ` Steven Whitehouse
[not found] ` <1338562627.2760.1526.camel@edumazet-glaptop>
2012-06-01 15:28 ` Steven Whitehouse
[not found] ` <1338562897.2760.1528.camel@edumazet-glaptop>
[not found] ` <1338563900.2760.1529.camel@edumazet-glaptop>
2012-06-01 15:30 ` Steven Whitehouse
[not found] ` <1338552870.2760.1512.camel@edumazet-glaptop>
2012-06-01 12:26 ` Steven Whitehouse
2012-06-01 15:54 ` Joe Perches
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1338553486.2708.25.camel@menhir \
--to=swhiteho@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).