summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2021-11-16 13:20:45 +0000
committerDavid S. Miller <davem@davemloft.net>2021-11-16 13:20:45 +0000
commit62803fec52f80e4dd375de2dd76510c405792928 (patch)
tree7f2d751f3ec898f8cfb48df852e8beafdb6000a6 /include
parentabc3342a09a74dcaaf11e6560c2ae859171f1167 (diff)
parentb3cb764aa1d753cf6a58858f9e2097ba71e8100b (diff)
downloadcachepc-linux-62803fec52f80e4dd375de2dd76510c405792928.tar.gz
cachepc-linux-62803fec52f80e4dd375de2dd76510c405792928.zip
Merge branch 'inuse-cleanups'
Eric Dumazet says: ==================== net: prot_inuse and sock_inuse cleanups Small series cleaning and optimizing sock_prot_inuse_add() and sock_inuse_add(). ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r--include/net/netns/core.h1
-rw-r--r--include/net/sock.h27
2 files changed, 23 insertions, 5 deletions
diff --git a/include/net/netns/core.h b/include/net/netns/core.h
index 36c2d998a43c..552bc25b1933 100644
--- a/include/net/netns/core.h
+++ b/include/net/netns/core.h
@@ -12,7 +12,6 @@ struct netns_core {
int sysctl_somaxconn;
#ifdef CONFIG_PROC_FS
- int __percpu *sock_inuse;
struct prot_inuse __percpu *prot_inuse;
#endif
};
diff --git a/include/net/sock.h b/include/net/sock.h
index 95cc03bd3fac..f09c0c4736c4 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -1429,13 +1429,32 @@ proto_memory_pressure(struct proto *prot)
#ifdef CONFIG_PROC_FS
-/* Called with local bh disabled */
-void sock_prot_inuse_add(struct net *net, struct proto *prot, int inc);
+#define PROTO_INUSE_NR 64 /* should be enough for the first time */
+struct prot_inuse {
+ int all;
+ int val[PROTO_INUSE_NR];
+};
+
+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);
+}
+
+static inline void sock_inuse_add(const struct net *net, int val)
+{
+ this_cpu_add(net->core.prot_inuse->all, 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)
+{
+}
+
+static inline void sock_inuse_add(const struct net *net, int val)
{
}
#endif