From: Pavel Emelyanov <xemul@openvz.org>
To: Eric Dumazet <dada1@cosmosbay.com>
Cc: Linux Netdev List <netdev@vger.kernel.org>
Subject: [PATCH net-2.6.26 1/5][SOCK]: Enumerate struct proto-s to facilitate percpu inuse accounting.
Date: Fri, 28 Mar 2008 11:59:14 +0300 [thread overview]
Message-ID: <47ECB362.5050104@openvz.org> (raw)
This add the inuse_idx to struct proto and generates one in proto_register.
The ++ in generator is protected with write-locked proto_list_lock.
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
---
include/net/sock.h | 1 +
net/core/sock.c | 10 ++++++++++
2 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/include/net/sock.h b/include/net/sock.h
index 1c9d059..abc6341 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -562,6 +562,7 @@ struct proto {
/* Keeping track of sockets in use */
#ifdef CONFIG_PROC_FS
+ unsigned int inuse_idx;
struct pcounter inuse;
#endif
diff --git a/net/core/sock.c b/net/core/sock.c
index 3ee9506..a7faf30 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -1940,6 +1940,15 @@ EXPORT_SYMBOL(sk_common_release);
static DEFINE_RWLOCK(proto_list_lock);
static LIST_HEAD(proto_list);
+static void assign_proto_idx(struct proto *prot)
+{
+#ifdef CONFIG_PROC_FS
+ static unsigned int idx = 0;
+
+ prot->inuse_idx = idx++;
+#endif
+}
+
int proto_register(struct proto *prot, int alloc_slab)
{
char *request_sock_slab_name = NULL;
@@ -2000,6 +2009,7 @@ int proto_register(struct proto *prot, int alloc_slab)
write_lock(&proto_list_lock);
list_add(&prot->node, &proto_list);
+ assign_proto_idx(prot);
write_unlock(&proto_list_lock);
return 0;
--
1.5.3.4
next reply other threads:[~2008-03-28 8:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-28 8:59 Pavel Emelyanov [this message]
2008-03-28 9:43 ` [PATCH net-2.6.26 1/5][SOCK]: Enumerate struct proto-s to facilitate percpu inuse accounting Eric Dumazet
2008-03-28 10:17 ` Pavel Emelyanov
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=47ECB362.5050104@openvz.org \
--to=xemul@openvz.org \
--cc=dada1@cosmosbay.com \
--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.