Re: [LTP] mmapstress03 weirdness? (fwd)

2009-09-22 Thread Benjamin Herrenschmidt
On Mon, 2009-09-21 at 15:40 +0200, Geert Uytterhoeven wrote:

 
 With 32-bit userland, this boils down to:
 
 | mmap addr 0x7fff size 0x7fff
 | mmap returned 0x7fff
 
 i.e. mmap() succeeds, but (1) the test expects it to fail, so the test returns
 TFAIL, but (2) ltp-pan still reports that the tests passed?

What is the output of /proc/pid/maps after that mmap ?

With a 64-bit kernel, 32-bit userspace has access to the entire 4G
address space, so mapping 2G-64k at the 2G-64k point can work, provided
you aren't overlapping an existing mapping such as the stack.

 In addition, sometimes mmapstress03 fails due to SEGV. I created a small test
 program that just does the above mmap(), and depending on the distro and what
 else I print later it crashes with a SEGV, too. Probably this happens because
 the mmap() did succeed, and corrupted some existing mappings, cfr. the notes
 for MAP_FIXED:

That's possible.

MAP_FIXED
   Don’t  interpret  addr  as  a hint: place the mapping at exactly
   that address.  addr must be a multiple of the page size.  If the
   memory  region  specified  by addr and len overlaps pages of any
   existing mapping(s), then the overlapped part  of  the  existing
   mapping(s)  will  be discarded.  If the specified address cannot
   be used, mmap() will fail.  Because requiring  a  fixed  address
   for  a  mapping is less portable, the use of this option is dis‐
   couraged.

Yeah, I suppose the test might be wiping out its own stack for example

IE. I think that test is just bogus :-)

 JFYI, with 64-bit userland, this boils down to:
 
 | mmap addr 0x7fff size 0x7fff
 | mmap returned 0x
 
 i.e. mmap() fails as expected, and the test succeeds.

Right because on 64-bit userspace, you only are allowed something like
16T of address space.

 Does all of this sound OK?
 Thanks for your comments!

Yes, I think so far, it's just bogus tests :-)

Cheers,
Ben.

 With kind regards,
 
 Geert Uytterhoeven
 Software Architect
 Techsoft Centre
 
 Technology and Software Centre Europe
 The Corporate Village · Da Vincilaan 7-D1 · B-1935 Zaventem · Belgium
 
 Phone:+32 (0)2 700 8453
 Fax:  +32 (0)2 700 8622
 E-mail:   geert.uytterhoe...@sonycom.com
 Internet: http://www.sony-europe.com/
 
 A division of Sony Europe (Belgium) N.V.
 VAT BE 0413.825.160 · RPR Brussels
 Fortis · BIC GEBABEBB · IBAN BE41293037680010
 ___
 Linuxppc-dev mailing list
 linuxppc-...@lists.ozlabs.org
 https://lists.ozlabs.org/listinfo/linuxppc-dev


--
Come build with us! The BlackBerryreg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9#45;12, 2009. Register now#33;
http://p.sf.net/sfu/devconf
___
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list


Re: [LTP] [PATCH RFC] ltp: define and use common clone helpers

2009-09-22 Thread Serge E. Hallyn
Quoting Mike Frysinger (vap...@gentoo.org):
 On Monday 21 September 2009 19:06:44 Serge E. Hallyn wrote:
  Define ltp_clone() and ltp_clone_malloc() in libltp, and convert existing
  clone usages to them.  (clone04 can't use it bc it wants to pass NULL,
  which ltp_clone() will for many arches convert to NULL+stacksize-1).
 
 so have the code handle NULL specially:
 (stack ? stack + stack_size - 1 : NULL)

grumble yeah that occurred to me but I was rebelling against the clone04.c
code...  But I guess I should.

  +ltp_clone(unsigned long clone_flags, void *stack, int stack_size,
  +   int (*fn)(void *arg), void *arg)
  +{
  +   int ret;
  +
  +#if defined(__hppa__)
  +   ret = clone(fn, stack, clone_flags, arg);
  +#elif defined(__ia64__)
  +   ret = clone2(fn, stack, stack_size, clone_flags, arg, NULL, NULL, NULL);
  +#else
  +   ret = clone(fn, stack + stack_size - 1, clone_flags, arg);
  +#endif
  +
  +   if (ret == -1)
  +   perror(clone);
 
 we cant be sure why the higher layers are calling clone.  maybe the args 
 given 
 expect the clone() call to fail.  so we dont want any perror() invocation 
 here.

Makes sense.

  +/***
  + * ltp_clone_malloc: also does the memory allocation for clone.
  + * Experience thus far suggests that one page is often insufficient,
  + * while 4*getpagesize() seems adequate.
  + ***/
 
 a malloc() function implies you should be giving it a size.  i think there 
 should be another helper here.
 ltp_clone_malloc() - takes a size
 ltp_clone_quick() - calls ltp_clone_malloc() with getpagesize() * 4
 
 or a better name than quick ...
 
  +int
  +ltp_clone_malloc(unsigned long clone_flags, int (*fn)(void *arg), void
   *arg)
 
 i think argument order should be consistent.  i.e. have all ltp_clone_* calls 
 start with (flags, func, arg) and then the malloc/etc... calls can add on 
 (..., size) and (..., size, buffer).

makes sense.

  +   void *stack = malloc (stack_size);
 
 no spacing around function calls
 
  +   if (!stack) {
  +   perror(malloc);
  +   return -1;
  +   }
 
 since people are linking in -lltp to get these clone helpers, we can assume 
 the tst_* funcs exist.  so this should invoke one of them with TBROK|TERRNO.

True.

  +   ret = ltp_clone(clone_flags, stack, stack_size, fn, arg);
  +
  +   if (ret == -1) {
  +   perror(clone);
  +   free(stack);
  +   }
 
 same issue as the other func -- dont call perror()
 
 i think we should make sure to save/restore errno across the free() 
 invocation 
 so that the caller gets the result from clone() ...

Good point.

 otherwise this looks great.  thanks for doing the footwork here.
 -mike

Will hopefully whip up a new patch later this week and resend.

thanks,
-serge

--
Come build with us! The BlackBerryreg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9#45;12, 2009. Register now#33;
http://p.sf.net/sfu/devconf
___
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list