[PATCH] IP fragment SLAB

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello

We know streaming services and NFS use UDP protocol.
This means IP defragmentation is processed heavily,
as their packets are very large.

We should allocate "incomplete detagram queue" using 
kmem_cache_alloc() instead of kmalloc().

This is the patch against linux 2.5.15.

Thank you,
Hirokazu Takahashi.


--- linux/include/net/ip.h.ORG	Tue May 14 03:32:55 2002
+++ linux/include/net/ip.h	Tue May 14 06:32:41 2002
@@ -84,6 +84,7 @@
  *	Functions provided by ip.c
  */
 
+extern void		ipfrag_init(void);
 extern int		ip_build_and_send_pkt(struct sk_buff *skb, struct sock *sk,
 					      u32 saddr, u32 daddr,
 					      struct ip_options *opt);
--- linux/net/ipv4/ip_fragment.c.ORG	Tue May 14 03:33:12 2002
+++ linux/net/ipv4/ip_fragment.c	Thu May 16 02:24:43 2002
@@ -89,7 +89,7 @@
 
 /* Hash table. */
 
-#define IPQ_HASHSZ	64
+#define IPQ_HASHSZ	128
 
 /* Per-bucket lock is easy to add now. */
 static struct ipq *ipq_hash[IPQ_HASHSZ];
@@ -128,6 +128,7 @@
 
 
 atomic_t ip_frag_mem = ATOMIC_INIT(0);	/* Memory used for fragments */
+static kmem_cache_t	*iqp_cachep;
 
 /* Memory Tracking Functions. */
 static __inline__ void frag_kfree_skb(struct sk_buff *skb)
@@ -139,12 +140,12 @@
 static __inline__ void frag_free_queue(struct ipq *qp)
 {
 	atomic_sub(sizeof(struct ipq), &ip_frag_mem);
-	kfree(qp);
+	kmem_cache_free(iqp_cachep, qp);
 }
 
 static __inline__ struct ipq *frag_alloc_queue(void)
 {
-	struct ipq *qp = kmalloc(sizeof(struct ipq), GFP_ATOMIC);
+	struct ipq *qp = kmem_cache_alloc(iqp_cachep, GFP_ATOMIC);
 
 	if(!qp)
 		return NULL;
@@ -628,4 +629,10 @@
 	IP_INC_STATS_BH(IpReasmFails);
 	kfree_skb(skb);
 	return NULL;
+}
+
+void __init ipfrag_init()
+{
+	iqp_cachep = kmem_cache_create("ipfragq",
+			sizeof(struct ipq), 0, SLAB_HWCACHE_ALIGN, 0, 0);
 }
--- linux/net/ipv4/ip_output.c.ORG	Tue May 14 03:33:19 2002
+++ linux/net/ipv4/ip_output.c	Tue May 14 03:33:40 2002
@@ -1012,6 +1012,7 @@
 
 	ip_rt_init();
 	inet_initpeers();
+	ipfrag_init();
 
 #ifdef CONFIG_IP_MULTICAST
 	proc_net_create("igmp", 0, ip_mc_procinfo);
-
: send the line "unsubscribe linux-net" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux