This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v4 2/3] 32-bit ABIs: support stat syscall family


On Tuesday 30 August 2016, Yury Norov wrote:
> On Mon, Aug 29, 2016 at 10:34:38PM +0200, Arnd Bergmann wrote:
> > On Monday 29 August 2016, Yury Norov wrote:
> > > > 
> > > > We've gone back and forth on the arm64+ilp32 definition of the
> > > > existing stat64 , because that one cannot easily use the same
> > > > generic structure. I originally thought that using the 64-bit
> > > > layout of 'struct stat' was a good idea for arm64, but now
> > > > I don't see much of an advantage either way (the existing arm32
> > > > 'struct stat64' layout or the existing  arm64 'struct stat' layout).
> > > > 
> > > > Both of them are incompatible with the default layout for all
> > > > other new 32-bit architectures in user space, so pick one of the
> > > > two for the kernel interface, and convert it to the normal layout
> > > > in glibc using __xstat_conv():
> > > > 
> > > > - if you use the arm64 'struct stat' layout (as in the current
> > > >   kernel patches), you need a temporary buffer with the larger
> > > >   size and then copy over the time fields one by one
> > > > - if you instead use the arm32 'struct stat64' layout in the kernel,
> > > >   the size is the same, and the conversion is a one-line
> > > >   assignment of st_ino.
> > > > 
> > > >       Arnd
> > > 
> > > Ok. I'll do like this. I'd prefer 1st option, because 2nd implies
> > > allocating big buffer on kernel side.
> > 
> > On the kernel side, both require allocating a buffer, the second
> > one is just slightly bigger. The kernel uses its own internal
> > 'struct kstat', which gets copied into one of the other structures.
> > 
> > 	Arnd
> 
> Ah, and in kernel too...
> 
> Anyway, using the arm32 'struct stat64' cannot help because
> __xstat{,32,64}_conv() assumes copying of the kernel buffer to user
> buffer.
> 
> We can, of course, write custom __xstat_conv() to avoid that copying. 

Right, that would work. No idea if that would be preferred in glibc
or not: the existing __xstat_conv() obviously works already, while
the simpler replacement would mean extra code.

> But then we'd write custom syscalls for stat family for aarch64/ilp32.
> More simple and straightforward way then is to introduce custom layout
> for struct stat, and avoid all conversions and memory wasting at all.
> And this is what I suggested in the very first series of ilp32 support.
> But Joseph declined it as non-generic solution.

Ok. 

> So for me there are 3 options:
>  - __xstat_conv() - hacky, complex and ineffective. I work on it right
>    now, and I'm not happy.
>  - current version with conversion of time fields only - adds new
>    fresh portion of hacks, but little more effective.

+ new version with conversion of st_ino field only, a different new hack
  but simpler.

>  - initial version. Effective, simple, free of hacks but (because of)
>    non-generic.

I can't find that version now, can you post a copy of that original
patch or a link to an archived discussion?

The layout we want is exactly what we have for stat64
sysdeps/unix/sysv/linux/bits/stat.h (not
sysdeps/unix/sysv/linux/generic/bits/stat.h), right?

	Arnd


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]