Re: [PATCH v2] Add preadv and pwritev system calls.

From: Russell King
Date: Fri Dec 12 2008 - 14:13:19 EST


On Fri, Dec 12, 2008 at 10:29:29AM -0800, Scott Lurndal wrote:
> On Fri, Dec 12, 2008 at 05:02:05PM +0100, Gerd Hoffmann wrote:
> > Matthew Wilcox wrote:
> > > On the other hand, NetBSD have approximately 0% market share.
> > > We shouldn't let them lock us into making a bad decision. Is there
> > > anyone other than NetBSD who has added these syscalls?
> >
> > Free- and OpenBSD have it too. For Solaris I've found a feature request
> > only. Dunno about MacOS/Darwin. Other un*xes which are important these
> > days?
> >
> > I'd *really* hate it to have the same system call with different
> > argument ordering on different systems though. Especially when swapping
> > two integer values, so gcc wouldn't error out on wrong usage.
>
> I would suggest that from the end-users perspective, the user-mode API
> should be similar to pread/pwrite, e.g:
>
> int preadv(fd, iovec, iovec_size, offset)

Yes, and that's easy for glibc to achieve.

What's hard is that the user <-> kernel API firstly has a limited number
of registers available to it for passing arguments without indirection
from user space into kernel space.

Secondly, the user <-> kernel argument register allocation can vary
depending on the ABI version which user space or kernel space is built
for. On ARM we have two ABIs, one where 64-bit arguments can be placed
in any two consecutive registers, and one where 64-bit arguments must
be placed in an even,odd register pair (not an odd,even pair.)

That leads to the above being:

fd r0 r0
iovec r1 r1
vecsz r2 r2
offset r3,r4 r4,r5

Notice the different register allocation for the 64-bit offset.

This problem of register-aligned argument placement is not limited
to just ARM, but several other Linux supported architectures.

--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of:
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/