Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp1736350ybd; Thu, 27 Jun 2019 00:24:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqzyqG8IQhqb/Kws3pASk+awTJr+oHujFqBcCLMO5WT2OAPS/eb67nkurSERdkAM7w2PY7jB X-Received: by 2002:a65:4902:: with SMTP id p2mr2366174pgs.350.1561620253292; Thu, 27 Jun 2019 00:24:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561620253; cv=none; d=google.com; s=arc-20160816; b=HIU/w0r13BGGiGiX6IwIsFo97LaEfJh2mWzbQg1ZIBCi2UlEZ9uZq1EZyqNjzro0jg eT1jRXYhzaqIHO5CcJxPlF8QEvBwQWMMFbWSkCda2utqI+lHtfRVpbPhaUnujOL4bPgf WeE6GpgPtrrYq8n57lOAlns3oMtRkCLZWJ832rvbmbCl+GVjSsM4gtXfQrdAPSIeIUke LKeT1MAvUu8ZXoC1UcoAqCrluRYEapOaF++MyToVgZhdNgyqLeE+c6vpQ/DwvcKqxkuN HNicN5QDlOTjUukN/Zkm8H5zN/vWtHFyjIys/NONjmx2dX8BcV3gWw7xPt8hHEqlkKvA eg+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type :content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:from:cc:to:subject:dkim-signature :dkim-filter; bh=oGuHAPxwcWpfOMlWoWrei2vmhmacWVvsFMAeQZ+RIf0=; b=ayaAk81w7xtYJz1Q1AFCm1X2vZKimBTw0GULJsceU2mmb/Rc91Y0HTNp017hkAwvlB j8P1tzMF/KBQfZ95XOuBcIl9cCoRz0dCe9bjG8r7fXgEWTI6gq8sZENt7gLXSIvq4mBo Di9jTjYgeWaruHAfJ9hfJxGRUxO/kjHkKJ/xQqshvQ3Yc+TjD1HUOL8mR75qI0HgdfAB j+80bCqdkcjg0fS1uJ1WP9wJn4Wo4/LUbyJWXZCTRVPHq7VN4EZ4XvhY1IxburUhULV4 iU1dTbvtdlqFH6slQzbhsCtQCuMG29eHgK6xAh53qqVAUiL31la1+vae37MhVGMa7A1r +DaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=OsHZIxUF; 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=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 15si1406790pgb.546.2019.06.27.00.23.57; Thu, 27 Jun 2019 00:24:13 -0700 (PDT) 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; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=OsHZIxUF; 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=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726054AbfF0HXh (ORCPT + 99 others); Thu, 27 Jun 2019 03:23:37 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:56347 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726382AbfF0HXg (ORCPT ); Thu, 27 Jun 2019 03:23:36 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20190627072334euoutp01ee8beb1fb2d03a1e2d156408d20a6bb7~r-U_xWXSP0395003950euoutp01f for ; Thu, 27 Jun 2019 07:23:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20190627072334euoutp01ee8beb1fb2d03a1e2d156408d20a6bb7~r-U_xWXSP0395003950euoutp01f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1561620214; bh=oGuHAPxwcWpfOMlWoWrei2vmhmacWVvsFMAeQZ+RIf0=; h=Subject:To:Cc:From:Date:In-Reply-To:References:From; b=OsHZIxUFjWmECSIISSofxGe+YIg2bIThD6t83Pj6MlhVYXoPrLpToBU204O5BZb0B dia05kg9jUQy4zL5DcLmQeE8KXBW8xwJFN0b0y/NDTTPyIyQnKhKqCS7jQuP6cSnZJ 0/TI/gpgCX4+r5rvQVKqB2y6/DtASVd7LBFETti4= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20190627072333eucas1p204fec7f4ebf1f64a40a89d832d3c06f6~r-U91uXJb0553205532eucas1p2u; Thu, 27 Jun 2019 07:23:33 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 55.40.04325.5FE641D5; Thu, 27 Jun 2019 08:23:33 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20190627072332eucas1p19e61c94d225e7ff2a154e98fc4354047~r-U8-0tI41949519495eucas1p12; Thu, 27 Jun 2019 07:23:32 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20190627072332eusmtrp1c81dde32bcab36a468160b74f8323886~r-U8xsNPf1956919569eusmtrp1V; Thu, 27 Jun 2019 07:23:32 +0000 (GMT) X-AuditID: cbfec7f5-b75ff700000010e5-fe-5d146ef5a0ca Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 52.7B.04146.4FE641D5; Thu, 27 Jun 2019 08:23:32 +0100 (BST) Received: from [106.109.129.180] (unknown [106.109.129.180]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20190627072331eusmtip138c32d2e43c4ee49c9702f84e0b44316~r-U8G6Ho12895628956eusmtip1Y; Thu, 27 Jun 2019 07:23:31 +0000 (GMT) Subject: Re: [PATCH bpf v4 2/2] xdp: fix hang while unregistering device bound to xdp socket To: Jakub Kicinski Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, xdp-newbies@vger.kernel.org, "David S. Miller" , =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= , Magnus Karlsson , Jonathan Lemon , Daniel Borkmann From: Ilya Maximets Message-ID: <30d4e214-f53b-ac2d-e7f7-99bbd7b96b8f@samsung.com> Date: Thu, 27 Jun 2019 10:23:27 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.1 MIME-Version: 1.0 In-Reply-To: <20190626113427.761cc845@cakuba.netronome.com> Content-Language: en-GB Content-Transfer-Encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrGKsWRmVeSWpSXmKPExsWy7djP87pf80RiDaZ9FrD407aB0eLzkeNs FosXfmO2mHO+hcXiSvtPdotjL1rYLHatm8lscXnXHDaLFYdOAMUWiFls79/H6MDtsWXlTSaP nbPusnss3vOSyaPrxiVmj+ndD5k9+rasYvT4vEkugD2KyyYlNSezLLVI3y6BK+PVib+MBTc5 K1ZsrWpg3MvexcjJISFgInH7xE0gm4tDSGAFo8SeSZtZIJwvjBJLHl5hg3A+M0rc3N0HVMYB 1vLshh9EfDmjxOZl/xkhnI+MEndu7mcBmSssECex/3o7mC0iYCjx68YUVpAiZoHrTBL3b29m BkmwCehInFp9hBHE5hWwk3i57zgTiM0ioCox4/MjMFtUIELi8pZdUDWCEidnPmEBuYJTwFri 2hQDkDCzgLhE05eVrBC2vMT2t3OYQXZJCDxil5j96zILxKMuEvPXfGeFsIUlXh3fAg0AGYnT k3ugauol7re8Z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u5eQfjpY3BhxgFOBiVeHhX7BSOFWJNLCuuzD3EKMHBrCTCmx8mEivEm5JYWZValB9fVJqT WnyI0RTot4nMUqLJ+cBEklcSb2hqaG5haWhubG5sZqEkztshcDBGSCA9sSQ1OzW1ILUIpo+J g1OqgdHEfNuR7woLGnsyUl5OYOX9Pfvv3bObGeW6BZXqFJv/fV5yQeJCZ8P52WeCD19e+pbX 6NNmX7X/HnYTzi7dbaby7/qU0wlF6/QfzM/P9lobKq9zRvOo/8tWTgf+fdNWXXBPVuieF7TL fI3h8labs9Ofp/R0vVEK1rXduf2bKP8ds1Wsz748yjVTYinOSDTUYi4qTgQAaKZHDuwCAAA= X-CMS-MailID: 20190627072332eucas1p19e61c94d225e7ff2a154e98fc4354047 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20190626181528eucas1p190f20427a1d2a64f2efa6cedcfac0826 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20190626181528eucas1p190f20427a1d2a64f2efa6cedcfac0826 References: <20190626181515.1640-1-i.maximets@samsung.com> <20190626181515.1640-3-i.maximets@samsung.com> <20190626113427.761cc845@cakuba.netronome.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 26.06.2019 21:34, Jakub Kicinski wrote: > On Wed, 26 Jun 2019 21:15:15 +0300, Ilya Maximets wrote: >> diff --git a/net/xdp/xdp_umem.c b/net/xdp/xdp_umem.c >> index 267b82a4cbcf..56729e74cbea 100644 >> --- a/net/xdp/xdp_umem.c >> +++ b/net/xdp/xdp_umem.c >> @@ -140,34 +140,38 @@ int xdp_umem_assign_dev(struct xdp_umem *umem, struct net_device *dev, >> return err; >> } >> >> -static void xdp_umem_clear_dev(struct xdp_umem *umem) >> +void xdp_umem_clear_dev(struct xdp_umem *umem) >> { >> + bool lock = rtnl_is_locked(); > > How do you know it's not just locked by someone else? You need to pass > the locked state in if this is called from different paths, some of > which already hold rtnl. Oh. That's a shame. I need more sleep. Thanks for spotting. I'll re-work this part. Best regards, Ilya Maximets. > > Preferably factor the code which needs the lock out into a separate > function like this: > > void __function() > { > do(); > the(); > things(); > under(); > the(); > lock(); > } > > void function() > { > rtnl_lock(); > __function(); > rtnl_unlock(); > } > >> struct netdev_bpf bpf; >> int err; >> >> + if (!lock) >> + rtnl_lock(); > > >