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:35 am

Pekka J Enberg wrote:


It decides to reallocate when the remaining space isn't enough
to hold the new data. NF_CT_EXT_MIN_SIZE is used to make sure it
doesn't allocate anything smaller than the minimum slab size and
hopefully avoid reallocations in the future. Unless I'm
misunderstanding what ksize() does, the easiest way to get
rid of this would be to replace NF_CT_EXT_MIN_SIZE by ksize(0).

Even better would be to not only avoid waste on the first allocation,
but also on reallocations. This would look something like this:

__nf_ct_ext_add():
{
         struct nf_ct_ext *new;
-       int i, newlen, newoff;
+	int i, newlen, newoff, reallen;
...
         if (newlen >= ct->ext->real_len) {
+		reallen = ksize(newlen);
-               new = kmalloc(newlen, gfp);
+		new = kmalloc(reallen, gfp);
                 if (!new)
                         return NULL;
...
-               new->real_len = newlen;
+		new->real_len = reallen;
                 ct->ext = new;
         }

--
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)