From patchwork Thu Dec 5 06:05:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Tu X-Patchwork-Id: 1204478 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.138; helo=whitealder.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="QRN28VFu"; dkim-atps=neutral Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47T4x76bBHz9sP6 for ; Thu, 5 Dec 2019 17:06:51 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 3FF95880D2; Thu, 5 Dec 2019 06:06:49 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id IqlMQr1tuNaD; Thu, 5 Dec 2019 06:06:48 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by whitealder.osuosl.org (Postfix) with ESMTP id 0305C87DB8; Thu, 5 Dec 2019 06:06:47 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id E5688C1DD7; Thu, 5 Dec 2019 06:06:47 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 9938FC077D for ; Thu, 5 Dec 2019 06:06:46 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 8ED6B2042C for ; Thu, 5 Dec 2019 06:06:46 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3Sp0cgZ+6vUI for ; Thu, 5 Dec 2019 06:06:46 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by silver.osuosl.org (Postfix) with ESMTPS id 2970120361 for ; Thu, 5 Dec 2019 06:06:46 +0000 (UTC) Received: by mail-pg1-f193.google.com with SMTP id k25so1071796pgt.7 for ; Wed, 04 Dec 2019 22:06:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=o093XSVSGlbQm9f6OlmErXWI+xGd6CGythqBZB6uRWI=; b=QRN28VFu6NwCp+Ydf3AVDWYrZZUCGkw39P8E19II6zxaHEJv70LhCuzEgWghCdypDh yHoIulP6QGelZ+6FyRKfqCnIngtBbBnycfXHe6Awawyov3q0IKIy6Lm5RWahFYafBfpP QELq0LeQ9bqeRM0can4MrT2AQIZcjoHlKAW6H7nklYCBWIaK0nuUDY4Rn5TlM1TEKgWx etVsMtXqoENIMUQWRIHEc/fBIAyBf7gDZzj+fiWwABKfvE96KCVCDZBcNAvb8L3wAhGm F4bVvgoWTWOOs13O/Sb1B0zjdvcryItgazxxCiGLuLpcUebVBCUCCs4RcTTe10CVrHLB yD1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=o093XSVSGlbQm9f6OlmErXWI+xGd6CGythqBZB6uRWI=; b=RWLr/mYixHr/LYr3klhByhU/eDHTYi/srFMz32S3FzLaow49sqFq6oh+KK9BaTGv0t gI4FBhOrVrbbq3HFD/y7TcHbl7Za4hYuzNR9VyBDktxxfDCZ3R0HBumipNIxHteosuM5 cIIlia29RUvW3FM6z23Dk2oSKz/QffKbhQqSB+sj4cilS1fVA1r1vJwTD73HJqF19y1P nSWGQZkTHz3QUzP2bbMoKEZQKrAzxmU/raWPfEjVOWBTs12eGrONH0EsF8xa6rFRkR0c VadXAIFRZQAUtG7BtwRaekCVI2+13uAb0rGtekMxlIQIWhdLb4At+N4RVFVTD3XFm4JC 4juw== X-Gm-Message-State: APjAAAWjHFPe5IQgrPV6ZBQkkJmMpYIkC3ZKGWFLnhNVy8uhuqjQSIG/ NvmOCFRuQhRGXibKNAUuc2GVPkT3 X-Google-Smtp-Source: APXvYqxEn1EoYos00FLaZqI/6VIsZ3Urfycmtl2bp8pVD/0zaX8DAxwKOjBXizaHwgDLU7RAblsf1Q== X-Received: by 2002:a63:770c:: with SMTP id s12mr7859153pgc.25.1575526004845; Wed, 04 Dec 2019 22:06:44 -0800 (PST) Received: from osboxes.localdomain ([73.93.153.184]) by smtp.gmail.com with ESMTPSA id h68sm11037884pfe.162.2019.12.04.22.06.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 04 Dec 2019 22:06:44 -0800 (PST) From: William Tu To: dev@openvswitch.org Date: Wed, 4 Dec 2019 22:05:07 -0800 Message-Id: <1575525907-63828-1-git-send-email-u9012063@gmail.com> X-Mailer: git-send-email 2.7.4 Cc: i.maximets@ovn.org Subject: [ovs-dev] [PATCH] netdev-afxdp: Add delay when reconfiguring xsk. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" The patch works around an error when reconfigure the netdev-afxdp device into different modes. Currently, when OVS destroy xsk, the xsk_destruct() in linux kernel calls xdp_put_umem() and defers calling xdp_umem_release_deferred(). This creates an -EBUSY error when xsk_socket__create() calls xsk_bind() xdp_umem_assign_dev() xdp_get_umem_from_qid() And this is because xdp_clear_umem_at_qid() is deferred so not clearing umem yet. The issue can be reproduced by just changing xdp-mode multiple times, ex: ovs-vsctl -- set interface afxdp-p0 \ options:n_rxq=1 type="afxdp" options:xdp-mode=best-effort ovs-vsctl -- set interface afxdp-p0 \ options:n_rxq=1 type="afxdp" options:xdp-mode=generic The patch fixes it by adding a delay, hopefully the umem has been properly cleanup. Signed-off-by: William Tu --- lib/netdev-afxdp.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/netdev-afxdp.c b/lib/netdev-afxdp.c index ca2dfd005b9f..84897f1fd025 100644 --- a/lib/netdev-afxdp.c +++ b/lib/netdev-afxdp.c @@ -661,6 +661,9 @@ netdev_afxdp_reconfigure(struct netdev *netdev) struct rlimit r = {RLIM_INFINITY, RLIM_INFINITY}; int err = 0; + /* Time for umem to be released in kernel. */ + xnanosleep(500000); + ovs_mutex_lock(&dev->mutex); if (netdev->n_rxq == dev->requested_n_rxq