From patchwork Wed Oct 9 14:23:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Maximets X-Patchwork-Id: 1173792 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ovn.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46pGfq5WYNz9sCJ for ; Thu, 10 Oct 2019 01:23:47 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 5057DCC2; Wed, 9 Oct 2019 14:23:44 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id D7D709D for ; Wed, 9 Oct 2019 14:23:42 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 4562714D for ; Wed, 9 Oct 2019 14:23:42 +0000 (UTC) X-Originating-IP: 90.177.210.238 Received: from localhost.localdomain (238.210.broadband10.iol.cz [90.177.210.238]) (Authenticated sender: i.maximets@ovn.org) by relay2-d.mail.gandi.net (Postfix) with ESMTPSA id 7194140012; Wed, 9 Oct 2019 14:23:39 +0000 (UTC) From: Ilya Maximets To: ovs-dev@openvswitch.org Date: Wed, 9 Oct 2019 16:23:31 +0200 Message-Id: <20191009142331.12891-1-i.maximets@ovn.org> X-Mailer: git-send-email 2.17.1 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Ilya Maximets Subject: [ovs-dev] [PATCH] netdev-afxdp: Update memory locking limits unconditionally. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Any type of AF_XDP socket in all modes implies creation of BPF map of type BPF_MAP_TYPE_XSKMAP. This leads to BPF_MAP_CREATE syscall and subsequently 'xsk_map_alloc()' function that will charge required memory from the memlock limit and fail with EPERM if we're trying to allocate more. On my system with 64K bytes of max locked memory by default, OVS frequently starts to fail after addition of 3rd afxdp port in SKB mode: netdev_afxdp|ERR|xsk_socket__create failed (Operation not permitted) mode: SKB qid: 0 Fixes: 0de1b425962d ("netdev-afxdp: add new netdev type for AF_XDP.") Signed-off-by: Ilya Maximets --- lib/netdev-afxdp.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/lib/netdev-afxdp.c b/lib/netdev-afxdp.c index 6e0180327..50ac1c5a5 100644 --- a/lib/netdev-afxdp.c +++ b/lib/netdev-afxdp.c @@ -524,19 +524,12 @@ netdev_afxdp_reconfigure(struct netdev *netdev) netdev->n_rxq = dev->requested_n_rxq; netdev->n_txq = netdev->n_rxq; - if (dev->requested_xdpmode == XDP_ZEROCOPY) { - dev->xdpmode = XDP_ZEROCOPY; - VLOG_INFO("AF_XDP device %s in DRV mode.", netdev_get_name(netdev)); - if (setrlimit(RLIMIT_MEMLOCK, &r)) { - VLOG_ERR("ERROR: setrlimit(RLIMIT_MEMLOCK): %s", - ovs_strerror(errno)); - } - } else { - dev->xdpmode = XDP_COPY; - VLOG_INFO("AF_XDP device %s in SKB mode.", netdev_get_name(netdev)); - /* TODO: set rlimit back to previous value - * when no device is in DRV mode. - */ + dev->xdpmode = dev->requested_xdpmode; + VLOG_INFO("%s: Setting XDP mode to %s.", netdev_get_name(netdev), + dev->xdpmode == XDP_ZEROCOPY ? "DRV" : "SKB"); + + if (setrlimit(RLIMIT_MEMLOCK, &r)) { + VLOG_ERR("setrlimit(RLIMIT_MEMLOCK) failed: %s", ovs_strerror(errno)); } err = xsk_configure_all(netdev);