Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 90449
b: refs/heads/master
c: 1338d46
h: refs/heads/master
i:
  90447: 34b671e
v: v3
  • Loading branch information
Pavel Emelyanov authored and David S. Miller committed Mar 28, 2008
1 parent c651879 commit 6563e5e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 13ff3d6fa4e6d8b6ee7c64245a0078e6a0e6f977
refs/heads/master: 1338d466d9c3f8a65cc6d83c629cd906f2a989f8
13 changes: 5 additions & 8 deletions trunk/include/net/sock.h
Original file line number Diff line number Diff line change
Expand Up @@ -639,18 +639,15 @@ static inline void sk_refcnt_debug_release(const struct sock *sk)
# define DEFINE_PROTO_INUSE(NAME) DEFINE_PCOUNTER(NAME)
# define REF_PROTO_INUSE(NAME) PCOUNTER_MEMBER_INITIALIZER(NAME, .inuse)
/* Called with local bh disabled */
static inline void sock_prot_inuse_add(struct proto *prot, int inc)
{
pcounter_add(&prot->inuse, inc);
}
extern void sock_prot_inuse_add(struct proto *prot, int inc);

static inline int sock_prot_inuse_init(struct proto *proto)
{
return pcounter_alloc(&proto->inuse);
}
static inline int sock_prot_inuse_get(struct proto *proto)
{
return pcounter_getval(&proto->inuse);
}

extern int sock_prot_inuse_get(struct proto *proto);

static inline void sock_prot_inuse_free(struct proto *proto)
{
pcounter_free(&proto->inuse);
Expand Down
22 changes: 22 additions & 0 deletions trunk/net/core/sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -1942,8 +1942,30 @@ static LIST_HEAD(proto_list);

#ifdef CONFIG_PROC_FS
#define PROTO_INUSE_NR 64 /* should be enough for the first time */
struct prot_inuse {
int val[PROTO_INUSE_NR];
};

static DECLARE_BITMAP(proto_inuse_idx, PROTO_INUSE_NR);
static DEFINE_PER_CPU(struct prot_inuse, prot_inuse);

void sock_prot_inuse_add(struct proto *prot, int val)
{
__get_cpu_var(prot_inuse).val[prot->inuse_idx] += val;
}
EXPORT_SYMBOL_GPL(sock_prot_inuse_add);

int sock_prot_inuse_get(struct proto *prot)
{
int cpu, idx = prot->inuse_idx;
int res = 0;

for_each_possible_cpu(cpu)
res += per_cpu(prot_inuse, cpu).val[idx];

return res >= 0 ? res : 0;
}
EXPORT_SYMBOL_GPL(sock_prot_inuse_get);

static void assign_proto_idx(struct proto *prot)
{
Expand Down

0 comments on commit 6563e5e

Please sign in to comment.