From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.9 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2D039C04A6B for ; Wed, 8 May 2019 17:36:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0BB0B21726 for ; Wed, 8 May 2019 17:36:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728996AbfEHRgR (ORCPT ); Wed, 8 May 2019 13:36:17 -0400 Received: from shards.monkeyblade.net ([23.128.96.9]:49590 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728735AbfEHRgR (ORCPT ); Wed, 8 May 2019 13:36:17 -0400 Received: from localhost (unknown [IPv6:2601:601:9f80:35cd::3d8]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) (Authenticated sender: davem-davemloft) by shards.monkeyblade.net (Postfix) with ESMTPSA id 805AE142C00B7; Wed, 8 May 2019 10:36:16 -0700 (PDT) Date: Wed, 08 May 2019 10:36:13 -0700 (PDT) Message-Id: <20190508.103613.1782548019381525988.davem@davemloft.net> To: jasowang@redhat.com Cc: netdev@vger.kernel.org, mst@redhat.com, yuehaibing@huawei.com, xiyou.wangcong@gmail.com, weiyongjun1@huawei.com, eric.dumazet@gmail.com Subject: Re: [PATCH net V2] tuntap: synchronize through tfiles array instead of tun->numqueues From: David Miller In-Reply-To: <1557201816-19945-1-git-send-email-jasowang@redhat.com> References: <1557201816-19945-1-git-send-email-jasowang@redhat.com> X-Mailer: Mew version 6.8 on Emacs 26.1 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Wed, 08 May 2019 10:36:16 -0700 (PDT) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Jason Wang Date: Tue, 7 May 2019 00:03:36 -0400 > @@ -1313,6 +1315,10 @@ static int tun_xdp_xmit(struct net_device *dev, int n, > > tfile = rcu_dereference(tun->tfiles[smp_processor_id() % > numqueues]); > + if (!tfile) { > + rcu_read_unlock(); > + return -ENXIO; /* Caller will free/return all frames */ > + } > > spin_lock(&tfile->tx_ring.producer_lock); > for (i = 0; i < n; i++) { The only way we can see a NULL here is if a detach happened in parallel, and if that happens we should retry the tfile[] indexing after resampling numqueues rather than dropping the packet.