Re: [PATCH] netfilter: replace horrible hack with ksize()

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Patrick McHardy
Date: Thursday, March 6, 2008 - 7:51 am

Pekka J Enberg wrote:

The ksize() description in mm/slab.c matches exactly what netfilter
wants to do:

  * kmalloc may internally round up allocations and return more memory
  * than requested. ksize() can be used to determine the actual amount 
of
  * memory allocated. The caller may use this additional memory, even though
  * a smaller amount of memory was initially specified with the kmalloc 
call.


I don't think there is anything broken with that code.

The initial allocation size is calculated as max(size, min slab size)
and is stored as ext->alloc_size. When adding the first extension,
it allocates ext->alloc_size of memory and stores both the real amount
of space used (ext->len) and the actual size (ext->real_len).
When adding further extensions, it calculates the new total amount of
space needed (newlen). If that is larger than the real amount of
memory allocated (real_len), it reallocates.

What am I missing here?

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] netfilter: replace horrible hack with ksize(), Pekka J Enberg, (Wed Mar 5, 2:20 pm)
Re: [PATCH] netfilter: replace horrible hack with ksize(), Christoph Lameter, (Wed Mar 5, 2:56 pm)
Re: [PATCH] netfilter: replace horrible hack with ksize(), Patrick McHardy, (Thu Mar 6, 7:03 am)
Re: [PATCH] netfilter: replace horrible hack with ksize(), Pekka J Enberg, (Thu Mar 6, 7:14 am)
Re: [PATCH] netfilter: replace horrible hack with ksize(), Pekka J Enberg, (Thu Mar 6, 7:20 am)
Re: [PATCH] netfilter: replace horrible hack with ksize(), Patrick McHardy, (Thu Mar 6, 7:35 am)
Re: [PATCH] netfilter: replace horrible hack with ksize(), Pekka J Enberg, (Thu Mar 6, 7:41 am)
Re: [PATCH] netfilter: replace horrible hack with ksize(), Patrick McHardy, (Thu Mar 6, 7:51 am)
Re: [PATCH] netfilter: replace horrible hack with ksize(), Christoph Lameter, (Thu Mar 6, 9:41 am)
Re: [PATCH] netfilter: replace horrible hack with ksize(), Patrick McHardy, (Mon Mar 10, 10:57 am)