From patchwork Fri Jan 22 15:47:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= X-Patchwork-Id: 12040131 X-Patchwork-Delegate: bpf@iogearbox.net 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT 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 D6AD4C433E6 for ; Fri, 22 Jan 2021 17:50:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AB51E23A79 for ; Fri, 22 Jan 2021 17:50:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729687AbhAVR3D (ORCPT ); Fri, 22 Jan 2021 12:29:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729283AbhAVPt0 (ORCPT ); Fri, 22 Jan 2021 10:49:26 -0500 Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9F1AC06121C; Fri, 22 Jan 2021 07:47:45 -0800 (PST) Received: by mail-lf1-x136.google.com with SMTP id b26so8119685lff.9; Fri, 22 Jan 2021 07:47:45 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=UNnUlBe99LdDA4M1w7ZyuRqsbUedR9JBc0FKV+8YSIA=; b=nQnkW7SX3zSxlVPRi+TOB0BjJAOJOtyNtW7KZpQbeM7zzU7BIZTuvr+UaewQbtBSJc SxZGE0ms8uNbidwrc4nn6GlSlcx4UqAY2DIacctD0RWDIOXXAjsZH44cg3e60iBHgtB4 x9y3Yi9PemysBc9WVz344hwjg1zXEeALaJOVV7wk46TDAz9N+7yIiJ+f0M07CmfPzIxl CAHHtiRgXYkyW7t6MmaDo43Ua04mNjx9tNCUUBEcVFrNrSMPVFehy5WVWbOy/dZnOvjN K5vJVdWhASxRU7N5bM6eFnXEZUpl9fiDT2SqN6ak8WECxCXLUwM6IaFjMcdVZHh9RsuM bZSg== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=UNnUlBe99LdDA4M1w7ZyuRqsbUedR9JBc0FKV+8YSIA=; b=N7NzM4oguoA2V2Ee38zp4/ITyJhh5l/cmMcFnBQTWURmrmhJleJyOgV5U8FWC3LalX QOqfCq2e7hUV4xzKQZ1qLXKLqPg803yXTYBh2V9k00gqq/BP4WwJzHx1QVBBPJnoPdeP 1U1nONvJngLPnnREqxHAvwe3BkqQW/uh+U0NdzUeJ8euyWF3xDnlM90+Xm5SYlVq/k06 1sRIbz2b9NAgWBy5toIQzYbZ+MjkyW8WMnyY3n0Mz6I0YPQUH6M+dYkIkrciMpxTOqgL 6B76VLlsYgEO3Sq0xcAuvA61rLUJzbxpleJLYkeY5QLcHpnGAt+Gh618933kvEOo6sB8 Dibg== X-Gm-Message-State: AOAM533bADX+1Sqe+2f37KkkPVO9/N/Xb6iBlp7XT6zBI8frpXqllpfH Ethj8mIvZ8EHEOZf4m1DDrI= X-Google-Smtp-Source: ABdhPJz/48D0xBVgV0J3bWPZAg+5dn+jEzdcUFXrW1ytaOxObNtGn3s7HeQcRsWgZ+b5Ec/EJJpc7w== X-Received: by 2002:a19:4f4f:: with SMTP id a15mr851516lfk.309.1611330464338; Fri, 22 Jan 2021 07:47:44 -0800 (PST) Received: from btopel-mobl.ger.intel.com (c213-102-90-208.bredband.comhem.se. [213.102.90.208]) by smtp.gmail.com with ESMTPSA id w17sm928589lft.52.2021.01.22.07.47.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jan 2021 07:47:43 -0800 (PST) From: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= To: ast@kernel.org, daniel@iogearbox.net, netdev@vger.kernel.org, bpf@vger.kernel.org Cc: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , magnus.karlsson@intel.com, jonathan.lemon@gmail.com, ciara.loftus@intel.com, weqaar.a.janjua@intel.com Subject: [PATCH bpf-next 10/12] selftests/bpf: avoid heap allocation Date: Fri, 22 Jan 2021 16:47:23 +0100 Message-Id: <20210122154725.22140-11-bjorn.topel@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210122154725.22140-1-bjorn.topel@gmail.com> References: <20210122154725.22140-1-bjorn.topel@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net From: Björn Töpel The data variable is only used locally. Instead of using the heap, stick to using the stack. Signed-off-by: Björn Töpel --- tools/testing/selftests/bpf/xdpxceiver.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/bpf/xdpxceiver.c b/tools/testing/selftests/bpf/xdpxceiver.c index 34bdcae9b908..2da59b142c03 100644 --- a/tools/testing/selftests/bpf/xdpxceiver.c +++ b/tools/testing/selftests/bpf/xdpxceiver.c @@ -807,10 +807,10 @@ static void *worker_testapp_validate(void *arg) { struct udphdr *udp_hdr = (struct udphdr *)(pkt_data + sizeof(struct ethhdr) + sizeof(struct iphdr)); - struct generic_data *data = (struct generic_data *)malloc(sizeof(struct generic_data)); struct iphdr *ip_hdr = (struct iphdr *)(pkt_data + sizeof(struct ethhdr)); struct ethhdr *eth_hdr = (struct ethhdr *)pkt_data; struct ifobject *ifobject = (struct ifobject *)arg; + struct generic_data data; void *bufs = NULL; pthread_attr_setstacksize(&attr, THREAD_STACK); @@ -840,17 +840,16 @@ static void *worker_testapp_validate(void *arg) for (int i = 0; i < num_frames; i++) { /*send EOT frame */ if (i == (num_frames - 1)) - data->seqnum = -1; + data.seqnum = -1; else - data->seqnum = i; - gen_udp_hdr(data, ifobject, udp_hdr); + data.seqnum = i; + gen_udp_hdr(&data, ifobject, udp_hdr); gen_ip_hdr(ifobject, ip_hdr); gen_udp_csum(udp_hdr, ip_hdr); gen_eth_hdr(ifobject, eth_hdr); gen_eth_frame(ifobject->umem, i * XSK_UMEM__DEFAULT_FRAME_SIZE); } - free(data); ksft_print_msg("Sending %d packets on interface %s\n", (opt_pkt_count - 1), ifobject->ifname); tx_only_all(ifobject);