Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp1122287ybd; Wed, 26 Jun 2019 11:34:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqx3IvFFT/Zhl3QpEZaAPdKmAP2F4YuRbed/NgXUaRLo+1XJOpUfm9oalmTIKWdFDraZ31Dx X-Received: by 2002:a65:664d:: with SMTP id z13mr3880810pgv.99.1561574098184; Wed, 26 Jun 2019 11:34:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561574098; cv=none; d=google.com; s=arc-20160816; b=LEt4kXyybXH6fLqL7fIup+qLCQa3jWht9r4DwEZ/ObYj04dLZuHWTC8QQiCC1NNzwV YrNIWvJS5UQ/nNbodIrP6nwuIT6jgHiiGK6z5cW8RnAYqB2TDvkVNjwrvjQioEdb1j0A v/BB2K3dpKwjVKVSWMcuMq3TYONVKKZ6Bxdet/xsEt5aa9DNRtNHsQGdoRgu1DaeLnD7 Fpt4uGsNSq/fbARm3r2s62ba9czJEVLIUqBX8VNBBzDiWcQqeeJmxQgu5Z1zVtQG4KZb SDCUoOo49URgp5qBJo04MI7v08dZIq15yQbolA9+VJEXQ+dS7R72um2+LuydxcPLhnNG 7rCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=bUsYiNyoZNoL9lby/1FtByidZxf9m7iN70pAJQ8cHC0=; b=VNRdq9RTgwV/V2LZcBkKKDVmk5JVzuHuQq1CKGsnMmFDd0/z487KedB7jvUIFPaEwk 2yR9enDnx7cvq3FhDCBN6r+jUrrD/qDL02QUpzLssaaGDTzPTHgl3PYPkHufDzz+TMx1 VPCTI3alH9sNzs+PJcn5sMVakN3VYM9Y7zUGy54up9+12IPTcbgIRWWJMdLnwWCSUmD/ gdKFBa0TWiWorr36c3d/8FZfkiG5rZvdi9A5jD08od2v54HAkGdpHIUT9NUDChZ/hfON fEK63FlsNflY70dXZd9DOevmZ9wf0ehpUmMiQDGF3BllTSJR9bCM7M8UKAIIwWgDrKkj /Iqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@netronome-com.20150623.gappssmtp.com header.s=20150623 header.b=r5VP+hiP; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r9si16385830pgv.272.2019.06.26.11.34.41; Wed, 26 Jun 2019 11:34:58 -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=@netronome-com.20150623.gappssmtp.com header.s=20150623 header.b=r5VP+hiP; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726525AbfFZSee (ORCPT + 99 others); Wed, 26 Jun 2019 14:34:34 -0400 Received: from mail-qk1-f195.google.com ([209.85.222.195]:34056 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726425AbfFZSee (ORCPT ); Wed, 26 Jun 2019 14:34:34 -0400 Received: by mail-qk1-f195.google.com with SMTP id t8so2546657qkt.1 for ; Wed, 26 Jun 2019 11:34:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :organization:mime-version:content-transfer-encoding; bh=bUsYiNyoZNoL9lby/1FtByidZxf9m7iN70pAJQ8cHC0=; b=r5VP+hiPFDl1KT2oQBakfOd9mxdQI719XRPTQTYuuG50ZfGHKYHwHjMUsKt7nA5WaF Ml3W+oex9LoGShtNebp+J8L3h3magpWY/DRmg1RCloe8suDVfKtVUzyNNZlNq473kJHC 28/KogVtHOP+FFbELPKWmrtSdx7SmbT6FKEtEsaqXVGH167iyJ73yvx8Wy9Hl585WwpP DvFfZtVg8v/Wqd9rGYl1mN55dTe/HeWcIcawx0FeA3GTlmyNBEjPYjMkZfyuznbFHM/O e59KtZnF3mQHBm9Ytx+AZb8EzpmC3YGuRJhGqQYl3uobg4plf1R6FzAO0DuczDGM1B2b fR2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:organization:mime-version:content-transfer-encoding; bh=bUsYiNyoZNoL9lby/1FtByidZxf9m7iN70pAJQ8cHC0=; b=eLwC/o6QMzr3DZYE3VtKIdqqDQ1HVXMSvAX20XjjFzVQD+vNXSJU1PwCZ/YLePt7GZ rM6Hp2w18I9OI6jVPL6cyKC15oQCnUMNZDVGe87dihphtOpOvjMkxRRUrzYXzHsSSR+K WxxdVl2rnNh82bOu5YB45JPvjEic8aTQP1y3Av8xdVD/kdSqUjAAvu/ypqcqwUm2ow4/ nLid0TVEtcLn0B9nVtTdh9m6cKklmPdt2zeT1/P00bsFpABxCbMQyLrMkKb15JtIloec 7ghvJyL81ElIah/jhe3OtDAXoFzCuvnsOjmXUYpH7F/XPtN53hKNomVUYpkXT0mRJh02 fszA== X-Gm-Message-State: APjAAAWKFBhdyZDwe9U6W63qLv9jN+E8nVF/BuekDPSdGZJjvJx7CEYy w7sJQH6jbYa6+00m83PF4jjdZQ== X-Received: by 2002:a05:620a:1497:: with SMTP id w23mr5125682qkj.49.1561574072737; Wed, 26 Jun 2019 11:34:32 -0700 (PDT) Received: from cakuba.netronome.com ([66.60.152.14]) by smtp.gmail.com with ESMTPSA id d17sm8220627qtp.84.2019.06.26.11.34.31 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 26 Jun 2019 11:34:32 -0700 (PDT) Date: Wed, 26 Jun 2019 11:34:27 -0700 From: Jakub Kicinski To: Ilya Maximets 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 Subject: Re: [PATCH bpf v4 2/2] xdp: fix hang while unregistering device bound to xdp socket Message-ID: <20190626113427.761cc845@cakuba.netronome.com> In-Reply-To: <20190626181515.1640-3-i.maximets@samsung.com> References: <20190626181515.1640-1-i.maximets@samsung.com> <20190626181515.1640-3-i.maximets@samsung.com> Organization: Netronome Systems, Ltd. MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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();