From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 31F07A0567; Tue, 9 Mar 2021 17:33:18 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AE91A4069D; Tue, 9 Mar 2021 17:33:17 +0100 (CET) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id C17D14068A for ; Tue, 9 Mar 2021 17:33:15 +0100 (CET) IronPort-SDR: o1QH9L6EPHoPvSPpu4XGXkwMGDRdTEhTPVf+XtHS7bfPaWexIQ9yR8PqzYQcO88h8iZJzNA2NI rd25WHEo5IKg== X-IronPort-AV: E=McAfee;i="6000,8403,9917"; a="167544687" X-IronPort-AV: E=Sophos;i="5.81,234,1610438400"; d="scan'208";a="167544687" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Mar 2021 08:33:14 -0800 IronPort-SDR: lAoEwLKJ4DdZ/12mEb1DfB7uvYNqCYl5oDE4Sx/MPWhagC8+Ig8oR7ri20WB0V61It57sQPZni taEXWgKI3hhQ== X-IronPort-AV: E=Sophos;i="5.81,234,1610438400"; d="scan'208";a="409803049" Received: from fyigit-mobl1.ger.corp.intel.com (HELO [10.213.196.3]) ([10.213.196.3]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Mar 2021 08:33:13 -0800 To: Ciara Loftus , dev@dpdk.org References: <20210224111852.11947-1-ciara.loftus@intel.com> <20210309101958.27355-1-ciara.loftus@intel.com> <20210309101958.27355-4-ciara.loftus@intel.com> From: Ferruh Yigit X-User: ferruhy Message-ID: Date: Tue, 9 Mar 2021 16:33:10 +0000 MIME-Version: 1.0 In-Reply-To: <20210309101958.27355-4-ciara.loftus@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-dev] [PATCH v2 3/3] net/af_xdp: preferred busy polling X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 3/9/2021 10:19 AM, Ciara Loftus wrote: > This commit introduces support for preferred busy polling > to the AF_XDP PMD. This feature aims to improve single-core > performance for AF_XDP sockets under heavy load. > > A new vdev arg is introduced called 'busy_budget' whose default > value is 64. busy_budget is the value supplied to the kernel > with the SO_BUSY_POLL_BUDGET socket option and represents the > busy-polling NAPI budget. To set the budget to a different value > eg. 256: > > --vdev=net_af_xdp0,iface=eth0,busy_budget=256 > > Preferred busy polling is enabled by default provided a kernel with > version >= v5.11 is in use. To disable it, set the budget to zero. > > The following settings are also strongly recommended to be used in > conjunction with this feature: > > echo 2 | sudo tee /sys/class/net/eth0/napi_defer_hard_irqs > echo 200000 | sudo tee /sys/class/net/eth0/gro_flush_timeout > > .. where eth0 is the interface being used by the PMD. > > Signed-off-by: Ciara Loftus <...> > --- a/doc/guides/rel_notes/release_21_05.rst > +++ b/doc/guides/rel_notes/release_21_05.rst > @@ -70,6 +70,10 @@ New Features > * Added command to display Rx queue used descriptor count. > ``show port (port_id) rxq (queue_id) desc used count`` > > +* **Updated the AF_XDP driver.** > + > + * Added support for preferred busy polling. > + > Can you please move the update after above the testpmd updates? For more details the expected order is in the section comment. > +static int > +configure_preferred_busy_poll(struct pkt_rx_queue *rxq) > +{ > + int sock_opt = 1; > + int fd = xsk_socket__fd(rxq->xsk); > + int ret = 0; > + > + ret = setsockopt(fd, SOL_SOCKET, SO_PREFER_BUSY_POLL, > + (void *)&sock_opt, sizeof(sock_opt)); > + if (ret < 0) { > + AF_XDP_LOG(DEBUG, "Failed to set SO_PREFER_BUSY_POLL\n"); > + goto err_prefer; > + } > + > + sock_opt = ETH_AF_XDP_DFLT_BUSY_TIMEOUT; > + ret = setsockopt(fd, SOL_SOCKET, SO_BUSY_POLL, (void *)&sock_opt, > + sizeof(sock_opt)); > + if (ret < 0) { > + AF_XDP_LOG(DEBUG, "Failed to set SO_BUSY_POLL\n"); [1] > + goto err_timeout; > + } > + > + sock_opt = rxq->busy_budget; > + ret = setsockopt(fd, SOL_SOCKET, SO_BUSY_POLL_BUDGET, > + (void *)&sock_opt, sizeof(sock_opt)); > + if (ret < 0) { > + AF_XDP_LOG(DEBUG, "Failed to set SO_BUSY_POLL_BUDGET\n"); In above [1] and here, shouldn't the function return error, even the rollback is successful. I am thinking a case an invalid 'busy_budget' provided, like a very big number or negative value. > + } else { > + AF_XDP_LOG(INFO, "Busy polling budget set to: %u\n", > + rxq->busy_budget); > + return 0; > + } > + > + /* setsockopt failure - attempt to restore xsk to default state and > + * proceed without busy polling support. > + */ > + sock_opt = 0; > + ret = setsockopt(fd, SOL_SOCKET, SO_BUSY_POLL, (void *)&sock_opt, > + sizeof(sock_opt)); > + if (ret < 0) { > + AF_XDP_LOG(ERR, "Failed to unset SO_BUSY_POLL\n"); > + return -1; > + } > + > +err_timeout: > + sock_opt = 0; > + ret = setsockopt(fd, SOL_SOCKET, SO_PREFER_BUSY_POLL, > + (void *)&sock_opt, sizeof(sock_opt)); > + if (ret < 0) { > + AF_XDP_LOG(ERR, "Failed to unset SO_PREFER_BUSY_POLL\n"); > + return -1; > + } > + > +err_prefer: > + rxq->busy_budget = 0; > + return 0; > +} > + <...>