Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3402813ybi; Mon, 10 Jun 2019 09:39:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqxEMXp0oV5AyHjxl3H2vhmc6bgLgEXNzkom57KPQBb/wAtghXwDRfiQBDBgzC7v6HfNNUtE X-Received: by 2002:aa7:9212:: with SMTP id 18mr36175072pfo.120.1560184745724; Mon, 10 Jun 2019 09:39:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560184745; cv=none; d=google.com; s=arc-20160816; b=GAPzb/u4bcr4W4HAlfVmlPLYZ03LpkpMBDrq0xWmGcR6vs82Q5TEKSrj9sa1Iy1fZL JNBRUM+moPkk4vTTnPGkvo/gZa0O84eW3cEA6Z0G02gZP+F5wqIXvxMNxIpGxsmhh4I5 OQ0pwZneUwx8Ud625g/FT2JLFroa7qyZV8+BvNBi2nEJepN6FiAxaVcyI3vLWDm5Dpri 5zVjHU5PRBTAsu0bGWdIXbGEutBR0D2l3peNAHiPutuKzkp++t1gydJ1DcnYV+BYokd3 ggGSSUUzR7OevmkyC8CGm+GrpVfrShReiaECAEARtn6JnwCA+A5beI7s62JUSnkXMjGu yxRw== 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:cc:to:from:subject:dkim-signature :dkim-filter; bh=sAFK7z11VVTb7FnfO2m2bg3sqAxX7frwXuQTxjAelag=; b=Q8YdBbjlPA2fA6NsKDfIwE9ULPJ3U/+d36kcTdgc3e/6XEAU/9FYi71jWsWO8vpVxm b82pXT5t+fxb4dzOBbrzHlSoOkDwXH0JM8triPECqWTg6iUJcJhFghLgI0uQankbmBrE H6FEc1PDdzbshpz7KBzftWDGpoz8gH8szkswITtKvIVwDssAeqSW01AdhVhXdNz9A69G q6FfGLG1eAEUvMV86YbBQCdfJxGauneMP8UheYAc9YPbUacQQ7P629MuV+urunJglB0A +7y0zGmJGuoplzVmJ7krBSfpoHfrxcucp3bJbfN4A81MaeHOvvkBUhwvdoMggvQXjBkb 6giw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=bKVhvvtQ; 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 s68si10420002pfb.39.2019.06.10.09.38.51; Mon, 10 Jun 2019 09:39:05 -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=bKVhvvtQ; 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 S2404102AbfFJQRm (ORCPT + 99 others); Mon, 10 Jun 2019 12:17:42 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:58468 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389123AbfFJQRl (ORCPT ); Mon, 10 Jun 2019 12:17:41 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20190610161740euoutp02fc1efeba5893347e5c13bba1565d3126~m4pdXc3la2503525035euoutp02G for ; Mon, 10 Jun 2019 16:17:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20190610161740euoutp02fc1efeba5893347e5c13bba1565d3126~m4pdXc3la2503525035euoutp02G DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1560183460; bh=sAFK7z11VVTb7FnfO2m2bg3sqAxX7frwXuQTxjAelag=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=bKVhvvtQaX5z3yG5D3noiVf8R9JGqcQzsgM4ySLGGbT0PomeYQBC83qR9mTw9Jyua 3pIcMsHBxaAqZBjhD1EsUUfHxAaZhn+A06VLXpezFDFwaZvziwulPTd0A4AHAPGkS3 0ad0WjSl04p41ZhcwN5Bg5uxwlfgd6rr9JcPH+go= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20190610161739eucas1p17c0338184126cab4edaa1e201e70e2dc~m4pcjC3Pk1445614456eucas1p10; Mon, 10 Jun 2019 16:17:39 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id E8.D4.04298.3A28EFC5; Mon, 10 Jun 2019 17:17:39 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20190610161738eucas1p18e8ea92ad360435f32979380caed7f0b~m4pbzh9tt1445614456eucas1p1z; Mon, 10 Jun 2019 16:17:38 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20190610161738eusmtrp2a2a495b577bf1fbfabfc5ce074264323~m4pbj2g5A1476914769eusmtrp2g; Mon, 10 Jun 2019 16:17:38 +0000 (GMT) X-AuditID: cbfec7f2-f2dff700000010ca-7f-5cfe82a3680a Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 0E.D3.04140.2A28EFC5; Mon, 10 Jun 2019 17:17:38 +0100 (BST) Received: from [106.109.129.180] (unknown [106.109.129.180]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20190610161737eusmtip1dd37683d70038d9f90fe32a0dfdf9043~m4parH2bQ2310323103eusmtip1d; Mon, 10 Jun 2019 16:17:37 +0000 (GMT) Subject: Re: [PATCH bpf v2] xdp: fix hang while unregistering device bound to xdp socket From: Ilya Maximets 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 Message-ID: <06eee1e3-283a-d665-904b-f0bc89b73232@samsung.com> Date: Mon, 10 Jun 2019 19:17:37 +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: Content-Language: en-GB Content-Transfer-Encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrJKsWRmVeSWpSXmKPExsWy7djP87qLm/7FGDT+ErH407aB0eLzkeNs FnPOt7BYXGn/yW5x7EULm8WudTOZLS7vmsNmseLQCaDYAjGL7f37GB24PLasvMnksXPWXXaP xXteMnlM737I7NG3ZRWjx+dNcgFsUVw2Kak5mWWpRfp2CVwZKy7rFGznrVh17S1bA+MRri5G Tg4JAROJqZOOsXQxcnAICaxglHguDBIWEvjCKPF5WVYXIxeQ/ZlRYsHF7aww9Y9evWaESCwH Knq6lw3C+cgoMeP1YiaQKmGBKIlv/56C2WwCOhKnVh9hBLFFBAwlft2YwgrSwCywlkni0p+J YKt5BewkJnRmg5gsAqoSl6+Kg5SLCkRIfNm5CayVV0BQ4uTMJywgNqeAvcSJo2/AbGYBcYmm LytZIWx5ie1v5zCDjJcQOMcu0X3kKyPE1S4St1t3MEPYwhKvjm9hh7BlJP7vnM8EYddL3G95 yQjR3MEoMf3QP6iEvcSW1+fYQY5jFtCUWL9LHyLsKPH9UjtYWEKAT+LGW0GIG/gkJm2b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dBvE5mlRJPz gSkjryTe0NTQ3MLS0NzY3NjMQkmct0PgYIyQQHpiSWp2ampBahFMHxMHp1QDY013I0vBsWkv o9t26bKZSC1yOG7au+/nevabLk0iQpOUdA4Ylhd4rKm/bblMYM0HkTv1Tis8SjelXXggp11i V/jXdv3zKxzfjs/cnGrCuPDq7qDe//PXeaf722dWh9xMTGidWL11wvQl9S7H67JSmTxe3Nx7 SrN43rFX5lJsnRUvyxh2r7/7QomlOCPRUIu5qDgRAGsFRj/hAgAA X-CMS-MailID: 20190610161738eucas1p18e8ea92ad360435f32979380caed7f0b 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 10.06.2019 11:05, Ilya Maximets wrote: > 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; I've sent v3 with this variant and with moved msg check to the top level. > > 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. >