Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2938043ybi; Mon, 10 Jun 2019 01:06:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqwalMzSQkb1pp5otYL4IDpX3GNoWBm1fC+NzmIcF33UI/dzCXK46IH/H2JNTydFyo0AVaCW X-Received: by 2002:a17:90a:21ac:: with SMTP id q41mr20368820pjc.31.1560153972392; Mon, 10 Jun 2019 01:06:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560153972; cv=none; d=google.com; s=arc-20160816; b=MMCtE37/BhM6GjvxYL9JQxbUB9roxrUzaqNrdGEyk0XQBOrrVFLJs71JJp4kMeoj0X X1vkiVMpaOUSXVAa+po4DEEcwPEw9zZuJjWl7Yk70Mtq+VL7VfzQr1psWdzqiqbX3Grr YeG7UCPSPYAn2liRut3Sl77WmnOGrVq3dPo4zgJOGz3X71bPlhpwP6iPqCrSj7H091qQ tsP15d12FYjuvX4S1DyzCDkrP7cGIxTysHYIVRskhnDHb9JC1Xb6YV5dFwachsone74M wv7017VuuKcDVw8vPXkLdW81JEY6vf+rd3LLZYV6GtmSuHWH2pehsOFNNmvD9vEwPcoD /oEw== 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=Iydzu+34xMOqZUeL4a5kLloyjoWo0xPAO3gew+uxnu8=; b=kXuG0+okX73ARu58N6ahuZKU+ylLIvWcq7xXCo1qMQAUH6QtrUj80+vzaemMuWejR5 i1E9dRjVqVfTSQR4rbwTUJJ2Mp2aAkj+flhkMI0ZzaH7YNOXWxUIz6xJVdZ/05uACgsf i/kPxHlHNniNaWOG9ugYZ7/6g6qwPOjWd7+XHVAnh7B32RwrVpnv4q6P46B+fRHX27Bs tf21cSfLAzqZG9I2TJ1hSHzmaBzU0m+ZKDitWQoxCwSSDnXVhSK2C/mZygxNIzEcgOkc F0YsLYRqpN3FLZmiSGofX/mFiURGvJ+KUWcWiffDmsyde0RQKShj7tmV85OzppGK9TJo oTmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b="sH/4LAkH"; 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 g69si4270270pgc.159.2019.06.10.01.05.53; Mon, 10 Jun 2019 01:06:12 -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="sH/4LAkH"; 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 S2388235AbfFJIFs (ORCPT + 99 others); Mon, 10 Jun 2019 04:05:48 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:37449 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388114AbfFJIFr (ORCPT ); Mon, 10 Jun 2019 04:05:47 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20190610080545euoutp01a42c15853c9f2c19f0568857850ff6ba~mx79Mi6cP3174731747euoutp01D for ; Mon, 10 Jun 2019 08:05:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20190610080545euoutp01a42c15853c9f2c19f0568857850ff6ba~mx79Mi6cP3174731747euoutp01D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1560153945; bh=Iydzu+34xMOqZUeL4a5kLloyjoWo0xPAO3gew+uxnu8=; h=Subject:To:Cc:From:Date:In-Reply-To:References:From; b=sH/4LAkHLx5LaovrpNwy12MpT8CJXv7/xkiwiDpXtHPdZ7fQDMTcWf7X+sL6btgr9 rkPl7nPCboz85OMHt+8Kl8OUle3NIX7UCfzqEiCaKtdAeiJvXnHPeqLMd78IyHkgaR hEED+yxS8Ue2nSnWuUFHF64XBzqns9f4FunbBPjs= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20190610080544eucas1p22efd8450d445146257a36b83adde084a~mx78aOjzV0238302383eucas1p2l; Mon, 10 Jun 2019 08:05:44 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 12.DD.04325.85F0EFC5; Mon, 10 Jun 2019 09:05:44 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20190610080543eucas1p1925be58eed3fadb6df90b58541e87cbb~mx77lHQId2351823518eucas1p1A; Mon, 10 Jun 2019 08:05:43 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20190610080543eusmtrp1f50cfc06142c71af65eb2953a6d6aff2~mx77VWRmP3063330633eusmtrp1G; Mon, 10 Jun 2019 08:05:43 +0000 (GMT) X-AuditID: cbfec7f5-b8fff700000010e5-b1-5cfe0f5899b8 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 35.D7.04146.75F0EFC5; Mon, 10 Jun 2019 09:05:43 +0100 (BST) Received: from [106.109.129.180] (unknown [106.109.129.180]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20190610080542eusmtip23f447e2d8dc20e3cf266844fb3998a84~mx76qbxxV0105901059eusmtip2V; Mon, 10 Jun 2019 08:05:42 +0000 (GMT) Subject: Re: [PATCH bpf v2] 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 From: Ilya Maximets Message-ID: Date: Mon, 10 Jun 2019 11:05:41 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <20190607163156.12cd3418@cakuba.netronome.com> Content-Language: en-GB Content-Transfer-Encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrHKsWRmVeSWpSXmKPExsWy7djP87oR/P9iDM618ln8advAaPH5yHE2 iznnW1gsrrT/ZLc49qKFzWLXupnMFpd3zWGzWHHoBFBsgZjF9v59jA5cHltW3mTy2DnrLrvH 4j0vmTymdz9k9ujbsorR4/MmuQC2KC6blNSczLLUIn27BK6MWfdeMha846648voZSwPjJs4u Rg4OCQETiS+Tg7oYuTiEBFYwSnz9vZIZwvnCKHGvsYsVwvnMKHGy9z9QhhOs4+W/FjaIxHJG iQ8t36BaPjJKfJv/DqxKWCBK4tu/p0wgtoiAocSvG1PARjELrGWSuPRnIgtIgk1AR+LU6iOM IDavgJ1E/+6F7CA2i4CqxJwZJ8AGiQpESHzZuQmqRlDi5MwnYL2cAtYS7cvvsILYzALiEk1f VkLZ8hLb384Bu0hC4By7RFvndyaIu10k5t+YxAJhC0u8Or6FHcKWkTg9uQcqXi9xv+UlI0Rz B6PE9EP/oJrtJba8PscOCjJmAU2J9bv0IcKOEt8vtbNDQpJP4sZbQYgb+CQmbZvODBHmle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hJNzgem jrySeENTQ3MLS0NzY3NjMwslcd4OgYMxQgLpiSWp2ampBalFMH1MHJxSDYy6Equ6i9YVXTOJ 7+mo3zd5xWnLz3cvX4t+IDRDvNdugv2hM91zfy9o+3ijq/Vcv5OSTt85lorF1yuWcCtM7N8Q l3/1kvelhVazLL2FszlfrgnbuiWJzf6/c1fWyu+1Pm1f2V4Ue89a219xM7DsgPJtq+d/7i/M WC9mua1PesVqm+rfS9ZlMy5VYinOSDTUYi4qTgQAAmzqW+UCAAA= X-CMS-MailID: 20190610080543eucas1p1925be58eed3fadb6df90b58541e87cbb X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20190607173149eucas1p1d2ebedcab469ebd66acfe7c7dcd18d7e X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20190607173149eucas1p1d2ebedcab469ebd66acfe7c7dcd18d7e References: <20190607173143.4919-1-i.maximets@samsung.com> <20190607163156.12cd3418@cakuba.netronome.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08.06.2019 2:31, Jakub Kicinski wrote: > On Fri, 7 Jun 2019 20:31:43 +0300, Ilya Maximets wrote: >> +static int xsk_notifier(struct notifier_block *this, >> + unsigned long msg, void *ptr) >> +{ >> + struct sock *sk; >> + struct net_device *dev = netdev_notifier_info_to_dev(ptr); >> + struct net *net = dev_net(dev); >> + int i, unregister_count = 0; > > Please order the var declaration lines longest to shortest. > (reverse christmas tree) Hi. I'm not a fan of mixing 'struct's with bare types in the declarations. Moving the 'sk' to the third place will make a hole like this: struct net_device *dev = netdev_notifier_info_to_dev(ptr); struct net *net = dev_net(dev); struct sock *sk; int i, unregister_count = 0; Which is not looking good. Moving to the 4th place: struct net_device *dev = netdev_notifier_info_to_dev(ptr); struct net *net = dev_net(dev); int i, unregister_count = 0; struct sock *sk; This variant doesn't look good for me because of mixing 'struct's with bare integers. Do you think I need to use one of above variants? > >> + mutex_lock(&net->xdp.lock); >> + sk_for_each(sk, &net->xdp.list) { >> + struct xdp_sock *xs = xdp_sk(sk); >> + >> + mutex_lock(&xs->mutex); >> + switch (msg) { >> + case NETDEV_UNREGISTER: > > You should probably check the msg type earlier and not take all the > locks and iterate for other types.. Yeah. I thought about it too. Will fix in the next version. Best regards, Ilya Maximets.