From: "Mala Anand" <manand@us.ibm.com>
To: alan@lxorguk.ukuu.org.uk, davem@redhat.com,
linux-kernel@vger.kernel.org, lse-tech@lists.sourceforge.net
Cc: "Bill Hartner" <bhartner@us.ibm.com>
Subject: Re: (RFC): SKB Initialization
Date: Wed, 21 Aug 2002 11:59:44 -0500 [thread overview]
Message-ID: <OF9AEE9308.79FD144F-ON87256C1C.004716B7@boulder.ibm.com> (raw)
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
next reply other threads:[~2002-08-21 16:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-08-21 16:59 Mala Anand [this message]
2002-08-21 17:10 ` Benjamin LaHaise
2002-08-21 18:07 Mala Anand
2002-08-21 18:16 ` Benjamin LaHaise
2002-08-21 18:42 Nivedita Singhvi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=OF9AEE9308.79FD144F-ON87256C1C.004716B7@boulder.ibm.com \
--to=manand@us.ibm.com \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=bhartner@us.ibm.com \
--cc=davem@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lse-tech@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®