netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/3] netlink: use vzalloc()
@ 2011-12-21 21:48 Stephen Hemminger
  2011-12-21 22:12 ` Eric Dumazet
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Hemminger @ 2011-12-21 21:48 UTC (permalink / raw)
  To: David Miller; +Cc: netdev

The netlink pid hash can be allocated using vzalloc() rather than direct
access to get_free_pages. It is also safe for nl_pid_hash_zalloc to use
GFP_KERNEL since it is only called from netlink_proto_init and
nl_pid_hash_rehash. The former is already allocating table with GFP_KERNEL,
and the latter is called from netlink_insert() which already could 
sleep in netlink_table_grab()

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>

--- a/net/netlink/af_netlink.c	2011-12-20 10:20:33.356914405 -0800
+++ b/net/netlink/af_netlink.c	2011-12-20 10:25:19.364247598 -0800
@@ -251,11 +251,9 @@ found:
 static struct hlist_head *nl_pid_hash_zalloc(size_t size)
 {
 	if (size <= PAGE_SIZE)
-		return kzalloc(size, GFP_ATOMIC);
+		return kzalloc(size, GFP_KERNEL);
 	else
-		return (struct hlist_head *)
-			__get_free_pages(GFP_ATOMIC | __GFP_ZERO,
-					 get_order(size));
+		return vzalloc(size);
 }
 
 static void nl_pid_hash_free(struct hlist_head *table, size_t size)
@@ -263,7 +261,7 @@ static void nl_pid_hash_free(struct hlis
 	if (size <= PAGE_SIZE)
 		kfree(table);
 	else
-		free_pages((unsigned long)table, get_order(size));
+		vfree(table);
 }
 
 static int nl_pid_hash_rehash(struct nl_pid_hash *hash, int grow)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/3] netlink: use vzalloc()
  2011-12-21 21:48 [PATCH 2/3] netlink: use vzalloc() Stephen Hemminger
@ 2011-12-21 22:12 ` Eric Dumazet
  2011-12-21 23:00   ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Dumazet @ 2011-12-21 22:12 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: David Miller, netdev

Le mercredi 21 décembre 2011 à 13:48 -0800, Stephen Hemminger a écrit :
> The netlink pid hash can be allocated using vzalloc() rather than direct
> access to get_free_pages. It is also safe for nl_pid_hash_zalloc to use
> GFP_KERNEL since it is only called from netlink_proto_init and
> nl_pid_hash_rehash. The former is already allocating table with GFP_KERNEL,
> and the latter is called from netlink_insert() which already could 
> sleep in netlink_table_grab()
> 


But netlink_table_grab() returns with write_lock_irq(&nl_table_lock);

So we are not allowed to sleep in a
netlink_table_grab()/netlink_table_ungrab() section .

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/3] netlink: use vzalloc()
  2011-12-21 22:12 ` Eric Dumazet
@ 2011-12-21 23:00   ` David Miller
  0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2011-12-21 23:00 UTC (permalink / raw)
  To: eric.dumazet; +Cc: shemminger, netdev

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Wed, 21 Dec 2011 23:12:31 +0100

> Le mercredi 21 décembre 2011 à 13:48 -0800, Stephen Hemminger a écrit :
>> The netlink pid hash can be allocated using vzalloc() rather than direct
>> access to get_free_pages. It is also safe for nl_pid_hash_zalloc to use
>> GFP_KERNEL since it is only called from netlink_proto_init and
>> nl_pid_hash_rehash. The former is already allocating table with GFP_KERNEL,
>> and the latter is called from netlink_insert() which already could 
>> sleep in netlink_table_grab()
>> 
> 
> 
> But netlink_table_grab() returns with write_lock_irq(&nl_table_lock);
> 
> So we are not allowed to sleep in a
> netlink_table_grab()/netlink_table_ungrab() section .

Right.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-12-21 23:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-21 21:48 [PATCH 2/3] netlink: use vzalloc() Stephen Hemminger
2011-12-21 22:12 ` Eric Dumazet
2011-12-21 23:00   ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).