svn commit: r274017 - head/sys/kern

Brooks Davis brooks at freebsd.org
Tue Nov 4 15:11:03 UTC 2014


On Tue, Nov 04, 2014 at 06:41:44AM +0100, Mateusz Guzik wrote:
> re-sent with trimmed cc
> 
> On Mon, Nov 03, 2014 at 07:35:56PM +0000, Poul-Henning Kamp wrote:
> > --------
> > In message <20141104045159.E1605 at besplex.bde.org>, Bruce Evans writes:
> > 
> > >This optimization is probably minor, but reminds me of other syscalls
> > >that would benefit using a single largish allocation up front:
> > >- all vfs calls that start with namei().  They allocate PATH_MAX (1K)
> > >   bytes and more.  An 8K stack has plently to spare after allocating
> > >   1K.  However, if malloc() is used then the PATH_MAX limit shouldn't
> > >   exist.   Only a limit to prevent denial of service is needed.
> > 
> > We should actually roll a new rev of all syscalls which take a path
> > and have them pass strlen(path)+1 into the kernel.
> > 
> > That would allow both precise allocation and faster copyin, followed
> > by a check that the last byte is (still) a NUL.
> > 
> 
> I think we can speed up things on amd64 no problem without affecting
> userspace.
> 
> amd64's copyinstr (and most likely all others) copy byte by byte. What
> we can do is copy word size and fall back to byte by byte on page fault.
> Ten on each iteration check if 0 was encountered.

As long as you handle unaligned starting addresses, you can safely copy
aligned-word by aligned-word without the risk of spurious pagefaults
(libc makes this assumption all over the place).  You may trip other
potential memory protection mechanims which aren't limited to page
alignment, but for exisiting hardware you don't need to worry about it.

That said, I prefer phk's suggestion in many ways.  It places the burden on
userspace where it belongs and allows precise allocation in the kernel.

-- Brooks
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/svn-src-head/attachments/20141104/79c1b06b/attachment.sig>


More information about the svn-src-head mailing list