144144static DEFINE_MUTEX (proto_list_mutex );
145145static LIST_HEAD (proto_list );
146146
147- static void sock_inuse_add (struct net * net , int val );
148-
149147/**
150148 * sk_ns_capable - General socket capability test
151149 * @sk: Socket to use a capability on or through
@@ -3536,19 +3534,8 @@ void sk_get_meminfo(const struct sock *sk, u32 *mem)
35363534}
35373535
35383536#ifdef CONFIG_PROC_FS
3539- #define PROTO_INUSE_NR 64 /* should be enough for the first time */
3540- struct prot_inuse {
3541- int val [PROTO_INUSE_NR ];
3542- };
3543-
35443537static DECLARE_BITMAP (proto_inuse_idx , PROTO_INUSE_NR ) ;
35453538
3546- void sock_prot_inuse_add (struct net * net , struct proto * prot , int val )
3547- {
3548- __this_cpu_add (net -> core .prot_inuse -> val [prot -> inuse_idx ], val );
3549- }
3550- EXPORT_SYMBOL_GPL (sock_prot_inuse_add );
3551-
35523539int sock_prot_inuse_get (struct net * net , struct proto * prot )
35533540{
35543541 int cpu , idx = prot -> inuse_idx ;
@@ -3561,17 +3548,12 @@ int sock_prot_inuse_get(struct net *net, struct proto *prot)
35613548}
35623549EXPORT_SYMBOL_GPL (sock_prot_inuse_get );
35633550
3564- static void sock_inuse_add (struct net * net , int val )
3565- {
3566- this_cpu_add (* net -> core .sock_inuse , val );
3567- }
3568-
35693551int sock_inuse_get (struct net * net )
35703552{
35713553 int cpu , res = 0 ;
35723554
35733555 for_each_possible_cpu (cpu )
3574- res += * per_cpu_ptr (net -> core .sock_inuse , cpu );
3556+ res += per_cpu_ptr (net -> core .prot_inuse , cpu )-> all ;
35753557
35763558 return res ;
35773559}
@@ -3583,22 +3565,12 @@ static int __net_init sock_inuse_init_net(struct net *net)
35833565 net -> core .prot_inuse = alloc_percpu (struct prot_inuse );
35843566 if (net -> core .prot_inuse == NULL )
35853567 return - ENOMEM ;
3586-
3587- net -> core .sock_inuse = alloc_percpu (int );
3588- if (net -> core .sock_inuse == NULL )
3589- goto out ;
3590-
35913568 return 0 ;
3592-
3593- out :
3594- free_percpu (net -> core .prot_inuse );
3595- return - ENOMEM ;
35963569}
35973570
35983571static void __net_exit sock_inuse_exit_net (struct net * net )
35993572{
36003573 free_percpu (net -> core .prot_inuse );
3601- free_percpu (net -> core .sock_inuse );
36023574}
36033575
36043576static struct pernet_operations net_inuse_ops = {
@@ -3644,9 +3616,6 @@ static inline void release_proto_idx(struct proto *prot)
36443616{
36453617}
36463618
3647- static void sock_inuse_add (struct net * net , int val )
3648- {
3649- }
36503619#endif
36513620
36523621static void tw_prot_cleanup (struct timewait_sock_ops * twsk_prot )
0 commit comments