Subject: Re: bug#18892: few test failure with 'grep-2.20.72-d512'

From: Bruce Dubbs <[email-masked]>
Date: Sun, 02 Nov 2014 12:59:34 -0600

Jim Meyering wrote:
> Your total free memory is obviously larger than 2GiB, but remember
> that what's listed there is the total, while the offending usage
> required a *contiguous* 2GiB region.

My understanding of the kernel is that it allocates in 4K blocks and 
maps them to user space to appear to be contiguous.

If I write a program that does:
   size_t size = 0xA0000000;  // 2,684,354,560
   char*  mem  = (char*) malloc( size );
   size_t i;

   for ( i = 0; i < size; i++, mem++ ) *mem='A';

There are no problems, but it does take about 9 seconds on my system.
The start address is 7ffa5405d010.
The end   address is 7ffaf405d010.

What am I missing?

   -- Bruce

> On Sat, Nov 1, 2014 at 7:56 PM, Bruce Dubbs <[email-masked]> wrote:
>> Jim Meyering wrote:
>>>
>>> On Wed, Oct 29, 2014 at 2:56 PM, Bruce Dubbs <[email-masked]>
>>> wrote:
>>> ...
>>>>>>
>>>>>>      http://meyering.net/grep/grep-2.20.72-d512.tar.xz
>>>
>>> ...
>>>>
>>>> Linux From Scratch 7.6
>>>>
>>>> configure and make were clean.
>>>>
>>>> $ env RUN_EXPENSIVE_TESTS=yes make -k check
>>>>
>>>> big-match: skipped test: not enough main memory to run the test
>>>> sjis-mb: skipped test: SJIS locale not found
>>>>
>>>> I do have 8G of memory.
>>>
>>>
>>> That test fails when grep fails to allocate enough space to hold a 2GiB
>>> line.
>>> No big deal, and not hard to imaging happening with a few applications
>>> in 8GiB of RAM.
>>
>>
>> Curious though.  It should have been OK.  I did not have any gui running at
>> the time.  Even if RAM was full, swap should have handled it.
>>
>> $ free
>>              total       used       free     shared    buffers     cached
>> Mem:      8105972    2380012    5725960        880     610460     326820
>> -/+ buffers/cache:   1442732    6663240
>> Swap:    10485756       3216   10482540
>>
>>    -- Bruce
>>
>>
>