From: Stephen Hemminger <shemminger@vyatta.com>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Subject: [PATCH 2/3] netlink: use vzalloc()
Date: Wed, 21 Dec 2011 13:48:33 -0800 [thread overview]
Message-ID: <20111221134833.76af35e6@nehalam.linuxnetplumber.net> (raw)
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)
next reply other threads:[~2011-12-21 21:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-21 21:48 Stephen Hemminger [this message]
2011-12-21 22:12 ` [PATCH 2/3] netlink: use vzalloc() Eric Dumazet
2011-12-21 23:00 ` David Miller
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=20111221134833.76af35e6@nehalam.linuxnetplumber.net \
--to=shemminger@vyatta.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.