From patchwork Wed Sep 27 00:13:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1840027 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=Sly9styC; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RwTxv51cpz1yp0 for ; Wed, 27 Sep 2023 18:17:55 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 10D9E82BF4; Wed, 27 Sep 2023 08:17:52 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 10D9E82BF4 Authentication-Results: smtp1.osuosl.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=Sly9styC X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id AKPdtb5Ce_xr; Wed, 27 Sep 2023 08:17:49 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id CAEB2829B6; Wed, 27 Sep 2023 08:17:47 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org CAEB2829B6 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id CA2AEC0DE2; Wed, 27 Sep 2023 08:17:43 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 8E025C0071 for ; Wed, 27 Sep 2023 00:13:31 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 677F5408E5 for ; Wed, 27 Sep 2023 00:13:31 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 677F5408E5 Authentication-Results: smtp2.osuosl.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=Sly9styC X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1sL1oelRn_Kh for ; Wed, 27 Sep 2023 00:13:30 +0000 (UTC) Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by smtp2.osuosl.org (Postfix) with ESMTPS id B1BF440116 for ; Wed, 27 Sep 2023 00:13:30 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org B1BF440116 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1c5cd27b1acso89172075ad.2 for ; Tue, 26 Sep 2023 17:13:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695773610; x=1696378410; darn=openvswitch.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TofRGtMhRPGgNgEwxNU34TFDCu+gzuDMLfb+dtqCXjQ=; b=Sly9styCrDkAIHPzbuIRUmVDAAI4ZwA/0xomCngw5Ym03OuO2W6qFACjxQrdHjHQW5 rtgTF7lmZBu1Zi8/yFdCDUb9MbJ2vtNPvbbghj59e/0VJAe2FvYM/Pl/BA4X1RAInBG7 hMsrgmp8Hjj3/6oas0B9juSAqFsFczEKULgg6wNxRP7VifK8k2n6Z8hMlToZzirSKPEi xjPqQhf32ReRecFDVnhwseVDT2fB6ea3eSA75IuS6OXXzYUlNhdh20i11PbK/io1uFoj VwACQo/4xzOl7wlG8LPxkehAj71/NcHc3WaTgYryAiR7RZSCE6R9WwEHhrhjbxmKV0vc qCvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695773610; x=1696378410; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TofRGtMhRPGgNgEwxNU34TFDCu+gzuDMLfb+dtqCXjQ=; b=lYL69deZNVSBzex044Yz+zh+jbQPfM2cBrxgH1YW+NHkV+8rtz3bl2iWFvqmtP9fKf jwfEYIKq1/KH//wPsnW0LLGy5a4PvEFATr926nbJ6Nd8kb8OaYTB2KuzQ3Ua0VqUHM1e XE7oWUxTqea2GTC+iqwm+QcFOI1/aVF8S6ucLbqwSn2U4DQo+7t3JB2hdOzSgq8pihV6 xARHdCybm5WUlhtjt6Ly/2DFfaYhbKbrHNTe7/0WdPMeLp5NSa3hlHBBUK2QZ8xiiv4b XSn0C6TkTs+cZib4+T4pV9CEwt/FY3yS23JQeVdvYWMiGyL/d8wR90fsHUw5Davmgsyu NbsA== X-Gm-Message-State: AOJu0YwEhAqxEaQsOnmv1B6oHJUG//nOGcBfV5Zlef+7p09fYZjq3xgQ F/uoYav3sDdbpfgUbvUK8ig= X-Google-Smtp-Source: AGHT+IFe+bxcLw9zxVvgyqKXSHnAy+bFRf2KFsXmH/SxtFIR/KsLXcxpyIpTdqZfJrcK7IUcTzhdvw== X-Received: by 2002:a17:903:1cf:b0:1c4:375c:110a with SMTP id e15-20020a17090301cf00b001c4375c110amr475177plh.19.1695773610188; Tue, 26 Sep 2023 17:13:30 -0700 (PDT) Received: from wheely.local0.net ([203.63.110.121]) by smtp.gmail.com with ESMTPSA id j1-20020a170902c3c100b001bc18e579aesm5623333plj.101.2023.09.26.17.13.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 17:13:29 -0700 (PDT) From: Nicholas Piggin To: netdev@vger.kernel.org Date: Wed, 27 Sep 2023 10:13:05 +1000 Message-Id: <20230927001308.749910-5-npiggin@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230927001308.749910-1-npiggin@gmail.com> References: <20230927001308.749910-1-npiggin@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 27 Sep 2023 08:17:38 +0000 Cc: dev@openvswitch.org, Nicholas Piggin Subject: [ovs-dev] [RFC PATCH 4/7] net: openvswitch: ovs_vport_receive reduce stack usage 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: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Dynamically allocating the sw_flow_key reduces stack usage of ovs_vport_receive from 544 bytes to 64 bytes at the cost of another GFP_ATOMIC allocation in the receive path. XXX: is this a problem with memory reserves if ovs is in a memory reclaim path, or since we have a skb allocated, is it okay to use some GFP_ATOMIC reserves? Signed-off-by: Nicholas Piggin --- net/openvswitch/vport.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/net/openvswitch/vport.c b/net/openvswitch/vport.c index 972ae01a70f7..ddba3e00832b 100644 --- a/net/openvswitch/vport.c +++ b/net/openvswitch/vport.c @@ -494,9 +494,13 @@ u32 ovs_vport_find_upcall_portid(const struct vport *vport, int ovs_vport_receive(struct vport *vport, struct sk_buff *skb, const struct ip_tunnel_info *tun_info) { - struct sw_flow_key key; + struct sw_flow_key *key; int error; + key = kmalloc(sizeof(*key), GFP_ATOMIC); + if (!key) + return -ENOMEM; + OVS_CB(skb)->input_vport = vport; OVS_CB(skb)->mru = 0; OVS_CB(skb)->cutlen = 0; @@ -510,12 +514,16 @@ int ovs_vport_receive(struct vport *vport, struct sk_buff *skb, } /* Extract flow from 'skb' into 'key'. */ - error = ovs_flow_key_extract(tun_info, skb, &key); + error = ovs_flow_key_extract(tun_info, skb, key); if (unlikely(error)) { kfree_skb(skb); + kfree(key); return error; } - ovs_dp_process_packet(skb, &key); + ovs_dp_process_packet(skb, key); + + kfree(key); + return 0; }