From mboxrd@z Thu Jan 1 00:00:00 1970 From: Cong Wang Subject: Re: [PATCH v5 2/2] sock: Move the socket inuse to namespace. Date: Thu, 7 Dec 2017 13:28:43 -0800 Message-ID: References: <1512665148-2413-1-git-send-email-xiangxia.m.yue@gmail.com> <1512665148-2413-2-git-send-email-xiangxia.m.yue@gmail.com> <1512667208.25033.13.camel@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Cc: Tonghao Zhang , David Miller , Eric Dumazet , Willem de Bruijn , Linux Kernel Network Developers To: Eric Dumazet Return-path: Received: from mail-pg0-f67.google.com ([74.125.83.67]:43769 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751288AbdLGV3E (ORCPT ); Thu, 7 Dec 2017 16:29:04 -0500 Received: by mail-pg0-f67.google.com with SMTP id b18so5354009pgv.10 for ; Thu, 07 Dec 2017 13:29:04 -0800 (PST) In-Reply-To: <1512667208.25033.13.camel@gmail.com> Sender: netdev-owner@vger.kernel.org List-ID: On Thu, Dec 7, 2017 at 9:20 AM, Eric Dumazet wrote: > On Thu, 2017-12-07 at 08:45 -0800, Tonghao Zhang wrote: >> In some case, we want to know how many sockets are in use in >> different _net_ namespaces. It's a key resource metric. >> > > ... > >> +static void sock_inuse_add(struct net *net, int val) >> +{ >> + if (net->core.prot_inuse) >> + this_cpu_add(*net->core.sock_inuse, val); >> +} > > This is very confusing. > > Why testing net->core.prot_inuse for NULL is needed at all ? > > Why not testing net->core.sock_inuse instead ? I bet that is copy-n-paste error given that sock_inuse_exit_net() has a similar typo.