BUG and fix: area->map's size is incorrect
Hi
the bug doesn't impact stability but wastes memory, when more memory you have more memory you waste. please look this, it's a ONE line patch!
this is an email I sent here two weeks ago, since I've got no reply (and neigher from linux-mm) i resend it to again, I've also attached aditional info at the end
Quoted 20 lines · ulisses
In a 2.4 kernel, mm/page_alloc.c:free_area_init_core(), in the following assignement...
bitmap_size = size >> i;...makes
bitmap_sizebe the double of the needed size, this calculum assumes that with a 512 byte map size the kernel is mapping 8*512= 4096 chunks of memory, that is: one bit of the map is used for each chunk of memory, and that's not true.Really one bit of
area->mapis used to map two chunks of memory, so in the example above anarea->mapof just 256 bytes is really needed, the other 256 bytes are_neveraccessed_.So the righ thing would be to do is:
bitmap_size = size >> (i+1);
Quoted 8 lines
also I tested it and it works ok, so I believe I'm right...
Please CC: your replies to (I'm not subscribed to this list)
Ulisses Alonso Camaró <[email protected]>
PD: my nick on #kernelnewbies is despistao
an easy to understand indicator to see that I am right is to see (for instance) how a page index of area->map is calculated, in __free_pages_ok() we can see the following:
page_idx = page - base;
index = page_idx >> (1 + order);
Imagine the order is 0, that is a continious block of PAGE_SIZE size, we still shift page_idx one bit, that is two blocks of "order" size are maped in each bit of area->map
you can also see that MARK_USED macro also makes this shift
Please CC: your replies to (I'm not subscribed to this list)
Ulisses Alonso Camaró <[email protected]>
PD: my nick on #kernelnewbies is despistao
Debian GNU/Linux: a dream come true
-----------------------------------------------------------------------------
"Computers are useless. They can only give answers." Pablo Picasso
---> Visita http://www.valux.org/ para saber acerca de la <---
---> Asociación Valenciana de Usuarios de Linux <---
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/