Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp193413ybc; Mon, 11 Nov 2019 23:20:15 -0800 (PST) X-Google-Smtp-Source: APXvYqy1WJuSRyM5//g7dVqld7540k2rf7vvf73TcpAbAB0ZfgVtX78ZmNUQM6U2sBPYhRwvJdJc X-Received: by 2002:a50:f05c:: with SMTP id u28mr30650312edl.265.1573543215603; Mon, 11 Nov 2019 23:20:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573543215; cv=none; d=google.com; s=arc-20160816; b=ubCN2OB/xOl4hleHt0wYh1qebJjCerT7Diad4c4cjl10V+QYDEYa5DhSsL9Ph9WBvp IiTsO9mn9HkUrfDHCESLriBGcMmtpfpd2XfQl+laI+07p/1H7a49ra7XsbNFO0x7GNd+ CdzQMSiSer5CIzGgt9wiChDQEGkqD3v6i9QWrzpUsXaP0KIOly2OOpKNbFHolRht5kXf ta0cBMy13xk6Z1O0MymMpAL/HHMuoGeSFCg/yr0udrHs97GUJZhVSvXKtvvMhUcjzhZp IhWZPJPo8RX3Nl+9we4RsurdUr7DkGYjVmobWzYu2YkHApGsU3HgCoCUzhSShd75xb3z F/xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:message-id :subject:cc:to:from:date; bh=K00mc6SsjT86xRIQM8LdlhU7TKEP/bSsc9lMs2/lXMg=; b=EI3CoVt6iRr7grlrrFzrktEcUOUuUxOXt5ROqGbeskr9jp0Csv+h1IIFCNHsLR+W74 cNHY5uBxTMY8mjjpk2zcZMQkwZlN8MosK5nkQef9nvtmjRxYLDyysPV1MuimSLfJVau6 ov5KPJAmH2yj+F+eposraYIlfOM2zV+SfpvqN8rWBQ9dyffNCU7pXkoygS4PxfMKVSRr 6SmrgR4owpcb8yBgbfN8lkMxkeXJjecMt4gnkkivc8gJWBiZyQGucw8wkCRuHQ01GA1C yvyMHFOGO0KoUiudsMCNC/B16kkC5mMe+prFxXvK9sYRKDZQYRIoPXjOBANFYJCyNngc Ejfw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i3si11296149ejv.41.2019.11.11.23.19.51; Mon, 11 Nov 2019 23:20:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727116AbfKLHSY (ORCPT + 99 others); Tue, 12 Nov 2019 02:18:24 -0500 Received: from out30-42.freemail.mail.aliyun.com ([115.124.30.42]:35407 "EHLO out30-42.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725283AbfKLHSY (ORCPT ); Tue, 12 Nov 2019 02:18:24 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R461e4;CH=green;DM=||false|;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e07417;MF=tonylu@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0Thsv3KG_1573543100; Received: from localhost(mailfrom:tonylu@linux.alibaba.com fp:SMTPD_---0Thsv3KG_1573543100) by smtp.aliyun-inc.com(127.0.0.1); Tue, 12 Nov 2019 15:18:20 +0800 Date: Tue, 12 Nov 2019 15:18:19 +0800 From: Tony Lu To: Stephen Hemminger Cc: davem@davemloft.net, shemminger@osdl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] net: remove static inline from dev_put/dev_hold Message-ID: <20191112071819.GB67139@TonyMac-Alibaba> Reply-To: Tony Lu References: <20191111140502.17541-1-tonylu@linux.alibaba.com> <20191111085632.24d88706@hermes.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191111085632.24d88706@hermes.lan> User-Agent: Mutt/1.12.2 (2019-09-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 11, 2019 at 08:56:32AM -0800, Stephen Hemminger wrote: > On Mon, 11 Nov 2019 22:05:03 +0800 > Tony Lu wrote: > > > This patch removes static inline from dev_put/dev_hold in order to help > > trace the pcpu_refcnt leak of net_device. > > > > We have sufferred this kind of issue for several times during > > manipulating NIC between different net namespaces. It prints this > > log in dmesg: > > > > unregister_netdevice: waiting for eth0 to become free. Usage count = 1 > > > > However, it is hard to find out who called and leaked refcnt in time. It > > only left the crime scene but few evidence. Once leaked, it is not > > safe to fix it up on the running host. We can't trace dev_put/dev_hold > > directly, for the functions are inlined and used wildly amoung modules. > > And this issue is common, there are tens of patches fix net_device > > refcnt leak for various causes. > > > > To trace the refcnt manipulating, this patch removes static inline from > > dev_put/dev_hold. We can use handy tools, such as eBPF with kprobe, to > > find out who holds but forgets to put refcnt. This will not be called > > frequently, so the overhead is limited. > > > > Signed-off-by: Tony Lu > > In the past dev_hold/dev_put was in the hot path for several > operations. What is the performance implication of doing this? From code analysis, there should be a little performance backwards. I don't have the benchmark data for now. I will make a kernel module to take a series of benchmarks for dev_put/dev_hold. Actually there is a plan to take a whole solution for this issue. The benchmarks will be done after this. Cheers Tony Lu