From: Denis Cheng <crquan@gmail.com>
To: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, cr_quan@163.com
Subject: [PATCH 3/3] netlink: use a statically allocated nl_table instead
Date: Sun, 2 Sep 2007 03:45:59 +0800 [thread overview]
Message-ID: <11886759772663-git-send-email-crquan@gmail.com> (raw)
In-Reply-To: <11886759682348-git-send-email-crquan@gmail.com>
if the table is always fixed size with MAX_LINKS entries, why not use a statically
allocated table straightforwardly?
Signed-off-by: Denis Cheng <crquan@gmail.com>
---
net/netlink/af_netlink.c | 11 ++---------
1 files changed, 2 insertions(+), 9 deletions(-)
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index ac3b100..c527f87 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -115,7 +115,7 @@ struct netlink_table {
int registered;
};
-static struct netlink_table *nl_table;
+static struct netlink_table nl_table[MAX_LINKS];
static DECLARE_WAIT_QUEUE_HEAD(nl_table_wait);
@@ -1894,10 +1894,6 @@ static int __init netlink_proto_init(void)
BUILD_BUG_ON(sizeof(struct netlink_skb_parms) > sizeof(dummy_skb->cb));
- nl_table = kcalloc(MAX_LINKS, sizeof(*nl_table), GFP_KERNEL);
- if (!nl_table)
- goto panic;
-
if (num_physpages >= (128 * 1024))
limit = num_physpages >> (21 - PAGE_SHIFT);
else
@@ -1915,8 +1911,7 @@ static int __init netlink_proto_init(void)
while (i-- > 0)
nl_pid_hash_free(nl_table[i].hash.table,
1 * sizeof(*hash->table));
- kfree(nl_table);
- goto panic;
+ goto out;
}
memset(hash->table, 0, 1 * sizeof(*hash->table));
hash->max_shift = order;
@@ -1933,8 +1928,6 @@ static int __init netlink_proto_init(void)
rtnetlink_init();
out:
return err;
-panic:
- panic("netlink_init: Cannot allocate nl_table\n");
}
core_initcall(netlink_proto_init);
--
1.5.3.rc7
next prev parent reply other threads:[~2007-09-01 19:45 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-01 19:45 [PATCH 1/3] netlink: use the macro min(x,y) provided by <linux/kernel.h> instead Denis Cheng
2007-09-01 19:45 ` [PATCH 2/3] netlink: the temp variable name max is ambiguous Denis Cheng
2007-09-01 19:45 ` Denis Cheng [this message]
2007-09-16 23:38 ` [PATCH 3/3] netlink: use a statically allocated nl_table instead David Miller
2007-09-16 23:36 ` [PATCH 2/3] netlink: the temp variable name max is ambiguous David Miller
2007-09-20 16:56 ` rae l
[not found] ` <46DA07B8.4050204@davidnewall.com>
2007-09-02 0:56 ` [PATCH 1/3] netlink: use the macro min(x,y) provided by <linux/kernel.h> instead rae l
2007-09-16 23:35 ` 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=11886759772663-git-send-email-crquan@gmail.com \
--to=crquan@gmail.com \
--cc=cr_quan@163.com \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--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 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).