Skip to contentSkip to conversation

make sk_alloc use kmalloc for non performance critical families

PATCH In review Arnaldo Carvalho de Melo 1 participant 1 message Jan 21, 2005

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/12 make sk_alloc use kmalloc for non performance critical families

Hi David,

Please see the log in the patch.

Regards,

- Arnaldo

===================================================================

[email protected], 2005-01-20 20:25:41-02:00, [email protected]
[SOCK] make sk_alloc use kmalloc for non performance critical families

With this we can have aggregate protocol specific struct proto_sock allocated for non performance critical protocols.

We still check for slab == NULL && zero_it == 1 to allocate from the generic "sock" slab cache, but this will be removed when all the network families stop using sk_protinfo, when the generic "sock" slab cache will be removed.

 sock.c |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)
net/core/sock.c +14 -3
diff -Nru a/net/core/sock.c b/net/core/sock.c
@@ -621,9 +621,17 @@
 {
 	struct sock *sk = NULL;
 
-	if (!slab)
+	/*
+	 * Transitional, this test will be removed when sk_cachep is killed
+	 */
+	if (slab == NULL && zero_it == 1)
 		slab = sk_cachep;
-	sk = kmem_cache_alloc(slab, priority);
+
+	if (slab != NULL)
+		sk = kmem_cache_alloc(slab, priority);
+	else
+		sk = kmalloc(zero_it, priority);
+
 	if (sk) {
 		if (zero_it) {
 			memset(sk, 0,
@@ -662,7 +670,10 @@
 		       __FUNCTION__, atomic_read(&sk->sk_omem_alloc));
 
 	security_sk_free(sk);
-	kmem_cache_free(sk->sk_slab, sk);
+	if (sk->sk_slab != NULL)
+		kmem_cache_free(sk->sk_slab, sk);
+	else
+		kfree(sk);
 	module_put(owner);
 }