Re: [patch] readv/writev rework

From: Andrew Morton (akpm@digeo.com)
Date: Thu Sep 12 2002 - 13:47:21 EST


Hirokazu Takahashi wrote:
>
> Hello,
>
> Your readv/writev patch interested me and I checked it.
> I found we also have a chance to improve normal writev.
>
> a_ops->prepare_write() and a_ops->commit_write will have a
> penalty when I/O size isn't PAGE_SIZE.
> With following patch generic_file_write_nolock() will try to
> make each I/O size become PAGE_SIZE.
>

Certainly makes a lot of sense. If an application has a large
number of small objects which are to be appended to a file, and
they are not contiguous in user memory then this patch makes
writev() a very attractive way of doing that. Tons faster.

However I'd be a little concerned over the increased work which a boring
old write() has to do. Perhaps we could add a special code path
for it:

        struct iovstate {
                unsigned rest;
                unsigned copy;
                unsigned off;
                struct iovec *work_iov;
                char *work_buf;
                unsigned work_iov_bytes;
        } iovstate;

        if (nr_segs != 1) {
                initialise iovstate;
        }

        ...

        if (nr_segs == 1)
                page_fault = filemap_copy_from_user(page, offset, buf, bytes);
        else
                page_fault = iov_copy_from_user(&arg1, &arg2, &bytes, &iovstate);
        status = a_ops->commit_write(file, page, offset, offset+bytes);

then we can do all that fancy stuff in iov_copy_from_user(). That
function should be inlined so we don't really pass all those arguments
around. That's just a cleanliness thing, and branching around the complex
code in the simple case. We should be able to get the impact on the
common case down to a single taken branch per page.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sun Sep 15 2002 - 22:00:30 EST