From patchwork Thu Jan 6 11:45:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Van Haaren, Harry" X-Patchwork-Id: 1576053 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=Aurw26NW; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JV4LP0Snnz9sSs for ; Thu, 6 Jan 2022 22:46:02 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 39B276FBE4; Thu, 6 Jan 2022 11:46:00 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id pveB5fMAqQAW; Thu, 6 Jan 2022 11:45:59 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id 83C8F60DBA; Thu, 6 Jan 2022 11:45:58 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 53AF1C002F; Thu, 6 Jan 2022 11:45:58 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 89108C001E for ; Thu, 6 Jan 2022 11:45:56 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 65E9B82ACD for ; Thu, 6 Jan 2022 11:45:56 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp1.osuosl.org (amavisd-new); dkim=pass (2048-bit key) header.d=intel.com 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 zs2qQ-4cCc97 for ; Thu, 6 Jan 2022 11:45:55 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by smtp1.osuosl.org (Postfix) with ESMTPS id B0A5182977 for ; Thu, 6 Jan 2022 11:45:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1641469555; x=1673005555; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=lqGJOK41bRfGxut6KRwnUc+Ye3e1XuA2NYLbjAraQWA=; b=Aurw26NWir5e4bkQ7icgGiS8MkEOnzmwR+960ISe5Y+keALe4A3ewCx3 P/lfSIkoDZwsjHnD+r+wjppkvGXX1WlOTrLp69bR6QpgdgQaJI12SBbUb tkktSSJAgXPpMo/jHKsSV0GvE10MQQ6K6wwvOQa90+K1h1U9vYAlE8Rsw C3rS90ycEA1DYW3q+3eFxgNHQXX52qidIGJmkCaT0OYi9eJN24/3DEM9u WdsTEFSIM90/9OtSXdwLH2umHMMwK6uY5csqXBmNfiMEtZspHPcBgd2a9 VX0Yx9ya4PbV3PxF0jwgmLbD7wBWLjsS5q5uuX+1b/2LD41W6ZUpCNrDM g==; X-IronPort-AV: E=McAfee;i="6200,9189,10217"; a="222637038" X-IronPort-AV: E=Sophos;i="5.88,266,1635231600"; d="scan'208";a="222637038" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jan 2022 03:45:55 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,266,1635231600"; d="scan'208";a="488911565" Received: from silpixa00401120.ir.intel.com ([10.55.128.255]) by orsmga002.jf.intel.com with ESMTP; 06 Jan 2022 03:45:53 -0800 From: Harry van Haaren To: ovs-dev@openvswitch.org Date: Thu, 6 Jan 2022 11:45:51 +0000 Message-Id: <20220106114551.3779260-1-harry.van.haaren@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Cc: i.maximets@ovn.org Subject: [ovs-dev] [PATCH] dpif-netdev: improve loading of packet data for undersized packets 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" This commit improves handling of packets where the allocated memory is less than 64 bytes. In the DPDK datapath this never matters, as an mbuf always pre-allocates enough space, however this can occur in test environments such as the dummy netdev. The fix is required to ensure ASAN enabled builds don't error on testing this, hence the fix is valuable. The solution implemented uses a mask-to-zero if the available buffer size is less than 64 bytes, and a branch for which type of load is used. Fixes: 250ceddcc2d0 ("dpif-netdev/mfex: Add AVX512 based optimized miniflow extract") Reported-by: Ilya Maximets Signed-off-by: Harry van Haaren Acked-by: Eelco Chaudron --- lib/dpif-netdev-extract-avx512.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/dpif-netdev-extract-avx512.c b/lib/dpif-netdev-extract-avx512.c index e060ab14a..d23349482 100644 --- a/lib/dpif-netdev-extract-avx512.c +++ b/lib/dpif-netdev-extract-avx512.c @@ -488,7 +488,14 @@ mfex_avx512_process(struct dp_packet_batch *packets, /* Load packet data and probe with AVX512 mask & compare. */ const uint8_t *pkt = dp_packet_data(packet); - __m512i v_pkt0 = _mm512_loadu_si512(pkt); + __m512i v_pkt0; + if (size >= 64) { + v_pkt0 = _mm512_loadu_si512(pkt); + } else { + uint64_t load_kmask = (1ULL << size) - 1; + v_pkt0 = _mm512_maskz_loadu_epi8(load_kmask, pkt); + } + __m512i v_pkt0_masked = _mm512_and_si512(v_pkt0, v_mask); __mmask64 k_cmp = _mm512_cmpeq_epi8_mask(v_pkt0_masked, v_vals); if (k_cmp != UINT64_MAX) {