Skip to content

Commit

Permalink
net: inline sock_prot_inuse_add()
Browse files Browse the repository at this point in the history
sock_prot_inuse_add() is very small, we can inline it.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Nov 16, 2021
1 parent abc3342 commit 2a12ae5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
14 changes: 11 additions & 3 deletions include/net/sock.h
Original file line number Diff line number Diff line change
Expand Up @@ -1429,13 +1429,21 @@ proto_memory_pressure(struct proto *prot)


#ifdef CONFIG_PROC_FS
#define PROTO_INUSE_NR 64 /* should be enough for the first time */
struct prot_inuse {
int val[PROTO_INUSE_NR];
};
/* Called with local bh disabled */
void sock_prot_inuse_add(struct net *net, struct proto *prot, int inc);
static inline void sock_prot_inuse_add(const struct net *net,
const struct proto *prot, int val)
{
__this_cpu_add(net->core.prot_inuse->val[prot->inuse_idx], val);
}
int sock_prot_inuse_get(struct net *net, struct proto *proto);
int sock_inuse_get(struct net *net);
#else
static inline void sock_prot_inuse_add(struct net *net, struct proto *prot,
int inc)
static inline void sock_prot_inuse_add(const struct net *net,
const struct proto *prot, int val)
{
}
#endif
Expand Down
11 changes: 0 additions & 11 deletions net/core/sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -3536,19 +3536,8 @@ void sk_get_meminfo(const struct sock *sk, u32 *mem)
}

#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);

void sock_prot_inuse_add(struct net *net, struct proto *prot, int val)
{
__this_cpu_add(net->core.prot_inuse->val[prot->inuse_idx], val);
}
EXPORT_SYMBOL_GPL(sock_prot_inuse_add);

int sock_prot_inuse_get(struct net *net, struct proto *prot)
{
int cpu, idx = prot->inuse_idx;
Expand Down

0 comments on commit 2a12ae5

Please sign in to comment.