diff options
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/sock.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/net/core/sock.c b/net/core/sock.c index 7d2c8add5f5a..174c64bc7a43 100644 --- a/net/core/sock.c +++ b/net/core/sock.c | |||
@@ -1942,8 +1942,30 @@ static LIST_HEAD(proto_list); | |||
1942 | 1942 | ||
1943 | #ifdef CONFIG_PROC_FS | 1943 | #ifdef CONFIG_PROC_FS |
1944 | #define PROTO_INUSE_NR 64 /* should be enough for the first time */ | 1944 | #define PROTO_INUSE_NR 64 /* should be enough for the first time */ |
1945 | struct prot_inuse { | ||
1946 | int val[PROTO_INUSE_NR]; | ||
1947 | }; | ||
1945 | 1948 | ||
1946 | static DECLARE_BITMAP(proto_inuse_idx, PROTO_INUSE_NR); | 1949 | static DECLARE_BITMAP(proto_inuse_idx, PROTO_INUSE_NR); |
1950 | static DEFINE_PER_CPU(struct prot_inuse, prot_inuse); | ||
1951 | |||
1952 | void sock_prot_inuse_add(struct proto *prot, int val) | ||
1953 | { | ||
1954 | __get_cpu_var(prot_inuse).val[prot->inuse_idx] += val; | ||
1955 | } | ||
1956 | EXPORT_SYMBOL_GPL(sock_prot_inuse_add); | ||
1957 | |||
1958 | int sock_prot_inuse_get(struct proto *prot) | ||
1959 | { | ||
1960 | int cpu, idx = prot->inuse_idx; | ||
1961 | int res = 0; | ||
1962 | |||
1963 | for_each_possible_cpu(cpu) | ||
1964 | res += per_cpu(prot_inuse, cpu).val[idx]; | ||
1965 | |||
1966 | return res >= 0 ? res : 0; | ||
1967 | } | ||
1968 | EXPORT_SYMBOL_GPL(sock_prot_inuse_get); | ||
1947 | 1969 | ||
1948 | static void assign_proto_idx(struct proto *prot) | 1970 | static void assign_proto_idx(struct proto *prot) |
1949 | { | 1971 | { |