Received: by 2002:a05:7412:3290:b0:fa:6e18:a558 with SMTP id ev16csp625446rdb; Fri, 26 Jan 2024 06:09:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IEvr5EXcKyqjOBXRrpsT9DwKHdZLowpcOajI2S0tU2t+P/UBwoa+EExbf2JxMIYdiWfMLLU X-Received: by 2002:a05:6a20:2513:b0:19a:534a:26ab with SMTP id j19-20020a056a20251300b0019a534a26abmr1083427pzd.57.1706278151629; Fri, 26 Jan 2024 06:09:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706278151; cv=pass; d=google.com; s=arc-20160816; b=HN/cnXRWiSgQxgImL9Xx7TKbtMphSpIfrNoQNSO7c0vhWKhUwCgsmq64N0apwWZGk5 /jLBVOV/XJfxl/6Ew55jEq5d/urdCrvbElpJgsOk01yH7ZEaRtoYDaPRlONj0q6L2Ls8 mN7uV3W3p8GT3V+YSeQsdV5tMpsx8Ep5pf1UcDb2nkW76sTlqLoMosEKst5qI1VC8zHi o84UHFRsjNpCyOSlea+M5kX3cIaNGonD+nbA8iUv3I6Q0kvw2sBbqgtvp7KugMWlxZBA 0OeNef6VSgCrVmLwdgQUbPdgLRsCPGFfrT+cTaFP5/4q1vMTQGjYubc3AnrccqaJjqc3 Xxzw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=xcpBQusEmy/n3+uTt9cMg26BamVEodtNdIAwxl61Xg4=; fh=eTd7umz5bDwrA2O8RT65r37r0t9PpqaUSn0Me2ng9gY=; b=Ag0iiY/73q8kotW0fQ35nO1+NteL86xC9hdJfZYR5aCX15x2DauPEX0sdzX2ntaIS5 9PQisGsjSnRCvn2nQeHLGBLWayjt6e/0Rn2oO6PWwx4g8uuxi/e3kdgbqQoNgS7jNSj2 94HkgokP8NK8U1Gd2dZ3or/eUMO0SC0mblYBuYGujbOwUiUg7Pz5roFSr2DlcmXOyyny Ah1+me8G1R8ZwsMSg44H6ExpQzGcxyRi+b5A/C35c9T+ZJTv8QQOu1JUvnKIyK8lyWRE qnDTvfqxnh3GHPe5sU/Wmp9SjEF04qcjCInAoXX7+hLIB5SyDo2kDCRqxHwqaz23i3DJ u6uQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GgwJmQ2g; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-40149-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-40149-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id b23-20020a656697000000b005cdf55cb5b5si1201455pgw.840.2024.01.26.06.09.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 06:09:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-40149-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GgwJmQ2g; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-40149-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-40149-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id D92D8B2407E for ; Fri, 26 Jan 2024 13:56:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 526931B97F; Fri, 26 Jan 2024 13:55:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="GgwJmQ2g" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BE99D1B955; Fri, 26 Jan 2024 13:55:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.8 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706277355; cv=none; b=nrFgEUXjSmc5gCSbJGzllf2ylhd6yECDLuP4SapIYJhon+JZ+/EOnPjU7aF5uHQHewB8r/F60lRFBlYgPbedJNFpFAHZxAmQ4asvRAnGt0AMBeUOPoWgRpzS5w9UcTOytQATcCZMC7h4b1so3VoLCiSYNX3pOiTRmIOULMRGZqM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706277355; c=relaxed/simple; bh=imVjlmmk3YaSrnGHNgfVdxJTZcpjli9usBMpCEom9t8=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=AHFPjEO0nujdGmjuy76JkD85ZjKjMu479ahW+kODmePv4hcXJcEuX/bu9Etoq4IKV0rUrKoQhYM4EegqO4yhwdiIIeRlWY6NNKsa+DS1jQEfDBtsDu/t6oAapmAbn0D6edgPqI5ualuTeQEsvXI/XOUDnhvfoFiKjgrM1IOy8lA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=GgwJmQ2g; arc=none smtp.client-ip=192.198.163.8 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1706277354; x=1737813354; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=imVjlmmk3YaSrnGHNgfVdxJTZcpjli9usBMpCEom9t8=; b=GgwJmQ2ge/TptGQGtLvgssofIs7/MImcTQj7eqOaaiGMmYPRUeyYSOGY 7vtpIjTWsFxzRwAcvmrRm2sMKARTio1iRt6Ut/53hwSl5HanlGkpmSiJJ Q+s6suqqk2XJkLjIOWBSvwy9kjqR3MZ2qpjQ5p6Hy/uWLPltHSkesWiWE efojdEUvt8KZJ736OGRXl8A1PvH2ftuZ8B94dBosk5/6gKvwEK4apvebf l0QOaJE2vBXIar/HpG8Zi64FcagKGVfoIcKTb1uYmuLTe8J5kSeyW5tC4 ZJ7rUYX8ZgH4GcVOJbNoRBuFm6XG81+LtEMz6aiiPpgFZDsykUksXd7RN Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10964"; a="15998390" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="15998390" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jan 2024 05:55:53 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10964"; a="821142817" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="821142817" Received: from newjersey.igk.intel.com ([10.102.20.203]) by orsmga001.jf.intel.com with ESMTP; 26 Jan 2024 05:55:47 -0800 From: Alexander Lobakin To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Alexander Lobakin , Christoph Hellwig , Marek Szyprowski , Robin Murphy , Joerg Roedel , Will Deacon , Greg Kroah-Hartman , "Rafael J. Wysocki" , Magnus Karlsson , Maciej Fijalkowski , Alexander Duyck , bpf@vger.kernel.org, netdev@vger.kernel.org, iommu@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH net-next 0/7] dma: skip calling no-op sync ops when possible Date: Fri, 26 Jan 2024 14:54:49 +0100 Message-ID: <20240126135456.704351-1-aleksander.lobakin@intel.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The series grew from Eric's idea and patch at [0]. The idea of using the shortcut for direct DMA as well belongs to Chris. When an architecture doesn't need DMA synchronization and the buffer is not an SWIOTLB buffer, most of times the kernel and the drivers end up calling DMA sync operations for nothing. Even when DMA is direct, this involves a good non-inline call ladder and eats a bunch of CPU time. With IOMMU, this results in calling indirect calls on hotpath just to check what is already known and return. XSk is been using a custom shortcut for that for quite some time. I recently wanted to introduce a similar one for Page Pool. Let's combine all this into one generic shortcut, which would cover all DMA sync ops and all types of DMA (direct, IOMMU, ...). * #1 adds stub inlines to be able to skip DMA sync ops or even compile them out when not needed. * #2 adds the generic shortcut and enables it for direct DMA. * #3 adds ability to skip DMA syncs behind an IOMMU. * #4-5 are just cleanups for Page Pool to avoid merge conflicts in future. * #6 checks for the shortcut as early as possible in the Page Pool code to make sure no cycles wasted. * #7 replaces XSk's shortcut with the generic one. On 100G NIC, the result is +3-5% for direct DMA and +10-11% for IOMMU. As a bonus, XSk core now allows batched buffer allocations for IOMMU setups. If the shortcut is not available on some system, there should be no visible performance regressions. [0] https://lore.kernel.org/netdev/20221115182841.2640176-1-edumazet@google.com Alexander Lobakin (5): dma: compile-out DMA sync op calls when not used page_pool: make sure frag API fields don't span between cachelines page_pool: don't use driver-set flags field directly page_pool: check for DMA sync shortcut earlier xsk: use generic DMA sync shortcut instead of a custom one Eric Dumazet (2): dma: avoid expensive redundant calls for sync operations iommu/dma: avoid expensive indirect calls for sync operations kernel/dma/Kconfig | 4 + include/net/page_pool/types.h | 21 +++- include/linux/device.h | 5 + include/linux/dma-map-ops.h | 17 +++ include/linux/dma-mapping.h | 100 +++++++++++++----- include/net/xdp_sock_drv.h | 7 +- include/net/xsk_buff_pool.h | 13 +-- drivers/base/dd.c | 2 + drivers/iommu/dma-iommu.c | 1 + drivers/net/ethernet/engleder/tsnep_main.c | 2 +- .../net/ethernet/freescale/dpaa2/dpaa2-xsk.c | 2 +- drivers/net/ethernet/intel/i40e/i40e_xsk.c | 2 +- drivers/net/ethernet/intel/ice/ice_xsk.c | 2 +- drivers/net/ethernet/intel/igc/igc_main.c | 2 +- drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c | 2 +- .../ethernet/mellanox/mlx5/core/en/xsk/rx.c | 4 +- .../net/ethernet/mellanox/mlx5/core/en_rx.c | 2 +- drivers/net/ethernet/netronome/nfp/nfd3/xsk.c | 2 +- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +- kernel/dma/mapping.c | 60 ++++++++--- kernel/dma/swiotlb.c | 14 +++ net/core/page_pool.c | 67 +++++++----- net/xdp/xsk_buff_pool.c | 29 +---- 23 files changed, 237 insertions(+), 125 deletions(-) -- 2.43.0