Garrett Cooper <[email protected]> wrote on 09/14/2010 12:43:47 PM:
> 1. It doesn't make sense why you're doing this, unless you're
> purposely trying to impose a limit to get the consumer to fail on the
> next round. What happens if you make this 0 instead?

You're right; this should be 0.  I foolishly just copied the structure from
the functions above.

> 2. Also, have you tried inverting the logic to test out whether or not
> this case functions as expected (i.e. #ifndef __linux__ ... #else
> return (size_t) -1; #endif)?
> 3. This also exposes type bugs in the tests; example:

I didn't test the LTP on a non-Linux platform.  I'm new to this, sorry.

> diff -r 90778db5a87c lib/system_specific_hugepages_info.c
> --- a/lib/system_specific_hugepages_info.c Mon Sep 13 11:19:49 2010 -0400
> +++ b/lib/system_specific_hugepages_info.c Mon Sep 13 14:51:14 2010 -0400
> @@ -26,8 +26,10 @@
> */
>
> #include <fcntl.h>
> +#include <linux/shm.h>
> #include <sys/types.h>
> #include <test.h>
> +#include "usctest.h"
>
> #define BUFSIZE 512
>
> @@ -76,3 +78,29 @@
> #endif
> }
>
> +/* Calculate how much memory to allocate based on the available huge
memory
> and
> + how many parallel processes are going to allocate it.
> +*/
> +size_t calculate_huge_pages_shm_to_be_allocated( double fraction )
> +{
> +#ifdef __linux__
> + size_t bytes_to_allocate;
> +
> + bytes_to_allocate = (size_t)(fraction * (double)get_no_of_hugepages() *
> (double)hugepages_size() * 1024.0);
> +
> + /* Now divide that up amongst the processes */
> + if( STD_COPIES > 1 )
> + bytes_to_allocate /= (size_t)STD_COPIES;
> + /* and limit to SHMMAX */
> + if( bytes_to_allocate > SHMMAX )
> + bytes_to_allocate = (size_t)SHMMAX;
> +
> + #ifdef DEBUG
> + printf( "calculate_huge_pages_shm_to_be_allocated(%lf) returns %lu\n",
> divider, (unsigned long)bytes_to_allocate );
> + #endif
> +
> + return bytes_to_allocate;
> +#else
> + return 0;
> +#endif
> +}

--
Scott Romanowski
------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to