* Re: (RFC): SKB Initialization
@ 2002-08-21 16:59 Mala Anand
2002-08-21 17:10 ` Benjamin LaHaise
0 siblings, 1 reply; 5+ messages in thread
From: Mala Anand @ 2002-08-21 16:59 UTC (permalink / raw)
To: alan, davem, linux-kernel, lse-tech; +Cc: Bill Hartner
Here is a 2.5.25 patch that improves the skb header initialization
on SMP systems [for netperf]. The patch removes the constructor
for the skbuff_head_cache and moves the initialization of the skb
header from __free_skb to alloc_skb.
Since skbs freed on one CPU may end up being allocated on another cpu,
and often are, the initialization on the free side may not be the
right choice for SMP particularily if the free slab is then allocated
on another CPU.
I measured the cycles spent in initializing skb in the stock kernel
versus with the patch. I collected the cycles at the end of running
tcp_stream netperf test using 4KB message size, 64KB socket buffer
size, 2 adapter test on a 2-way system.
Two 996MHz Pentium III systems with 2 gigabit ethernet cards in each
one of them are used. The cycles are collected at the server
end.
The patch reduces the numer of cylces by 25%
Baseline on Linux 2.5.25 kernel:
-------------------------------
CPU 0 CPU 1
------ ------
Avg cycles in alloc_skb: 64.05 203.39
Avg cycles in __kfree_skb: 127.54 228.95
------ -------
Total Avg Cycles 191.59 432.34
------ -------
# of times alloc_skb called: 235,478 2,060,422
# of times __kfree_skb called: 2,063,276 232,359
Linux 2.5.25+Skbinit Patch:
--------------------------
CPU 0 CPU 1
----- -----
Avg cycles in alloc skb: 237.21 230.91
# of times alloc_skb called: 1,226,594 1,213,327
I also will collect the cycles of this init code in Specweb99 workload
and will post it later.
diff -Naur linux2.5.25/net/core/skbuff.c linux-525skb/net/core/skbuff.c
--- linux2.5.25/net/core/skbuff.c Tue Aug 20 08:50:58 2002
+++ linux-525skb/net/core/skbuff.c Wed Aug 21 08:51:52 2002
@@ -195,18 +195,37 @@
goto nodata;
/* XXX: does not include slab overhead */
+ skb->next = skb->prev = NULL;
+ skb->list = NULL;
+ skb->sk = NULL;
+ skb->stamp.tv_sec = 0; /* No idea about time */
+ skb->dev = NULL;
+ skb->dst = NULL;
+ memset(skb->cb, 0, sizeof(skb->cb));
+ skb->len = 0;
+ skb->data_len = 0;
+ skb->csum = 0;
+ skb->cloned = 0;
+ skb->pkt_type = PACKET_HOST; /* Default type */
+ skb->ip_summed = 0;
+ skb->priority = 0;
+ skb->security = 0; /* By default packets are insecure */
skb->truesize = size + sizeof(struct sk_buff);
-
/* Load the data pointers. */
skb->head = skb->data = skb->tail = data;
skb->end = data + size;
-
- /* Set up other state */
- skb->len = 0;
- skb->cloned = 0;
- skb->data_len = 0;
-
atomic_set(&skb->users, 1);
+ skb->destructor = NULL;
+#ifdef CONFIG_NETFILTER
+ skb->nfmark = skb->nfcache = 0;
+ skb->nfct = NULL;
+#ifdef CONFIG_NETFILTER_DEBUG
+ skb->nf_debug = 0;
+#endif
+#endif
+#ifdef CONFIG_NET_SCHED
+ skb->tc_index = 0;
+#endif
atomic_set(&(skb_shinfo(skb)->dataref), 1);
skb_shinfo(skb)->nr_frags = 0;
skb_shinfo(skb)->frag_list = NULL;
@@ -326,7 +345,7 @@
#ifdef CONFIG_NETFILTER
nf_conntrack_put(skb->nfct);
#endif
- skb_headerinit(skb, NULL, 0); /* clean state */
+ /* skb_headerinit(skb, NULL, 0); clean state */
kfree_skbmem(skb);
}
@@ -1191,7 +1210,7 @@
sizeof(struct sk_buff),
0,
SLAB_HWCACHE_ALIGN,
- skb_headerinit, NULL);
+ NULL, NULL);
if (!skbuff_head_cache)
panic("cannot create skbuff cache");
Regards,
Mala
Mala Anand
IBM Linux Technology Center - Kernel Performance
E-mail:manand@us.ibm.com
http://www-124.ibm.comdeveloperworks/opensource/linuxperf
http://www-124.ibm.com/developerworks/projects/linuxperf
Phone:838-8088; Tie-line:678-8088
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: (RFC): SKB Initialization
2002-08-21 16:59 Mala Anand
@ 2002-08-21 17:10 ` Benjamin LaHaise
0 siblings, 0 replies; 5+ messages in thread
From: Benjamin LaHaise @ 2002-08-21 17:10 UTC (permalink / raw)
To: Mala Anand; +Cc: alan, davem, linux-kernel, lse-tech, Bill Hartner
On Wed, Aug 21, 2002 at 11:59:44AM -0500, Mala Anand wrote:
> The patch reduces the numer of cylces by 25%
The data you are reporting is flawed: where are the average cycle
times spent in __kfree_skb with the patch? Without that information,
there is no basis for conclusion as the total time spent in these
two routines is unknown. At worst, I'd have to assume this lack of
scientific method is an attempt to hide some aspect of the resulting
behaviour, but I hope that isn't the case.
-ben
> Baseline on Linux 2.5.25 kernel:
> -------------------------------
>
> CPU 0 CPU 1
> ------ ------
> Avg cycles in alloc_skb: 64.05 203.39
> Avg cycles in __kfree_skb: 127.54 228.95
> ------ -------
> Total Avg Cycles 191.59 432.34
> ------ -------
>
> # of times alloc_skb called: 235,478 2,060,422
> # of times __kfree_skb called: 2,063,276 232,359
>
>
> Linux 2.5.25+Skbinit Patch:
> --------------------------
> CPU 0 CPU 1
> ----- -----
> Avg cycles in alloc skb: 237.21 230.91
>
> # of times alloc_skb called: 1,226,594 1,213,327
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: (RFC): SKB Initialization
@ 2002-08-21 18:07 Mala Anand
2002-08-21 18:16 ` Benjamin LaHaise
0 siblings, 1 reply; 5+ messages in thread
From: Mala Anand @ 2002-08-21 18:07 UTC (permalink / raw)
To: Benjamin LaHaise; +Cc: alan, Bill Hartner, davem, linux-kernel, lse-tech
>On Wed, Aug 21, 2002 at 11:59:44AM -0500, Mala Anand wrote:
>> The patch reduces the numer of cylces by 25%
>The data you are reporting is flawed: where are the average cycle
>times spent in __kfree_skb with the patch?
I measured the cycles for only the initialization code in alloc_skb
and __kfree_skb. Since the init code is removed from __kfree_skb,
no cycles are spent there.
Regards,
Mala
Mala Anand
IBM Linux Technology Center - Kernel Performance
E-mail:manand@us.ibm.com
http://www-124.ibm.comdeveloperworks/opensource/linuxperf
http://www-124.ibm.com/developerworks/projects/linuxperf
Phone:838-8088; Tie-line:678-8088
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: (RFC): SKB Initialization
2002-08-21 18:07 (RFC): SKB Initialization Mala Anand
@ 2002-08-21 18:16 ` Benjamin LaHaise
0 siblings, 0 replies; 5+ messages in thread
From: Benjamin LaHaise @ 2002-08-21 18:16 UTC (permalink / raw)
To: Mala Anand; +Cc: alan, Bill Hartner, davem, linux-kernel, lse-tech
On Wed, Aug 21, 2002 at 01:07:09PM -0500, Mala Anand wrote:
>
> >On Wed, Aug 21, 2002 at 11:59:44AM -0500, Mala Anand wrote:
> >> The patch reduces the numer of cylces by 25%
>
> >The data you are reporting is flawed: where are the average cycle
> >times spent in __kfree_skb with the patch?
>
> I measured the cycles for only the initialization code in alloc_skb
> and __kfree_skb. Since the init code is removed from __kfree_skb,
> no cycles are spent there.
Then the testing technique is flawed. You should include all of the
operations included in an alloc_skb/kfree_skb pair in order to see
the overall effect of the change, otherwise your change could have a
net negative effect which would not be noticed.
-ben
--
"You will be reincarnated as a toad; and you will be much happier."
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: (RFC): SKB Initialization
@ 2002-08-21 18:42 Nivedita Singhvi
0 siblings, 0 replies; 5+ messages in thread
From: Nivedita Singhvi @ 2002-08-21 18:42 UTC (permalink / raw)
To: manand
> The patch reduces the numer of cylces by 25%
Er, I'm not getting that from just the numbers you show.
The total ave number of cycles in alloc_skb before is approx 268.
Total number of cycles in alloc_skb after is approx 468.
So in order to reduce the total ave number of cycles, you
need __kfree_skb to reduce by more than approx 200. (Since
thats where you moved the code to).
So unless we see the total cycles in __kfree_skb, how
do we know? Or what am I missing?
thanks,
Nivedita
You said:
CPU 0 CPU 1
------ ------
Avg cycles in alloc_skb: 64.05 203.39
Avg cycles in __kfree_skb: 127.54 228.95
------ -------
Total Avg Cycles 191.59 432.34
------ -------
# of times alloc_skb called: 235,478 2,060,422
# of times __kfree_skb called: 2,063,276 232,359
Linux 2.5.25+Skbinit Patch:
--------------------------
CPU 0 CPU 1
----- -----
Avg cycles in alloc skb: 237.21 230.91
# of times alloc_skb called: 1,226,594 1,213,327
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2002-08-21 18:40 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-08-21 18:07 (RFC): SKB Initialization Mala Anand
2002-08-21 18:16 ` Benjamin LaHaise
-- strict thread matches above, loose matches on Subject: below --
2002-08-21 18:42 Nivedita Singhvi
2002-08-21 16:59 Mala Anand
2002-08-21 17:10 ` Benjamin LaHaise
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox