Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp1090568lqo; Thu, 9 May 2024 04:42:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUnVQ/xrYksqZQbOxmAgPALSNpdCB2urKyVhhx63HqkCACjtRogktfUkArYf/wf0pZKV8l2lewQXVz5kSHCDLlKeQCu+kzqZ0kZlvukyQ== X-Google-Smtp-Source: AGHT+IF/UHkdarPbs8uKIl0uRCGyIg7ZrXvKR2LT9yIQ23NtIUfwePaXqeJqUzKwW5cQdlpvI9Tg X-Received: by 2002:a05:6a21:680d:b0:1af:d44c:cfc3 with SMTP id adf61e73a8af0-1afd44cd228mr1401709637.32.1715254955082; Thu, 09 May 2024 04:42:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715254955; cv=pass; d=google.com; s=arc-20160816; b=f1GsHE1sLBZcY2BU5csXINatENYgGbT3Md08M0FG1n4CEGq9gfEQmoO80qzbq19xRe J6OttinNeq2jyBzeZa8LaO/RF6jE6vYnh78BawbI/bP9tEdlG/FlVyDHTqg24wkBYMd+ vsHcFygH9uyoEodN7qQ2Rl0fKyvZo7l/cAbwzao3MEV2+G/x3fQb6SVsSyf2+75Ryq9Q JRGd/SudWZGhkvQ9vdBfJQ78QIgmoz044hlPbVZFMhrO4ZNAFSH3w3yED7IUnIVca+Om XKg+Of4kueIMHLVUipzJVebIs72zVx0WvmE6W7Fhbk5n8P4LPR+Z1icIl4SBEfHDQefV zang== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:cms-type:content-transfer-encoding:in-reply-to:from :content-language:cc:to:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature:dkim-filter; bh=sFuV/tFX3qlWPW5/hEAfuW4Mb0Qblw1Ko/UBLqs3gjE=; fh=WEsT+g0nNfbJHJI/P7KnoAp5os+UxZX/ngThFKpI3kk=; b=NxbNP2Eyhx9rJrAibs/j9D9RaD55xpCg3HjKN3amCc32Dh5O4XridVUICXSIoLbgl8 yiuuJs+v+wv48g1tAp2lAEdq/SyJTXYLw1XXVW70OJ5ubPan2xXIFFmpMU0xud50Z4pi 9ZP8M881zDp77B7jCtpTMNN4Z59+Umq2x1jmE+cyc4OIfWo/MwcE4rZekzTH+DB9yMJq cSKhbzKwP56iq1gMECuTD5Ujxa1XpyO5xwtr6SMPsV1MvKqe8SAeWE+sCtxmAqWprenA jl9+F63EiKXoYJsBB3raW1NOTO594hUqwR0gMFReeVQnmkYytqjhT0ZrztWkJr1jcewi hYXw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=LUsluixc; arc=pass (i=1 spf=pass spfdomain=samsung.com dkim=pass dkdomain=samsung.com dmarc=pass fromdomain=samsung.com); spf=pass (google.com: domain of linux-kernel+bounces-174450-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-174450-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d2e1a72fcca58-6f4d2a72861si1301280b3a.7.2024.05.09.04.42.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 May 2024 04:42:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-174450-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=LUsluixc; arc=pass (i=1 spf=pass spfdomain=samsung.com dkim=pass dkdomain=samsung.com dmarc=pass fromdomain=samsung.com); spf=pass (google.com: domain of linux-kernel+bounces-174450-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-174450-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.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 E9E3BB214DD for ; Thu, 9 May 2024 11:41:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6EE2E149E0B; Thu, 9 May 2024 11:41:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="LUsluixc" Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) (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 1982D12FF8E for ; Thu, 9 May 2024 11:41:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.118.77.12 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715254890; cv=none; b=YlN3AtZII0B8J1aA1GzQpBbGyEeew2ubKlunqczWmPAriBwwxJoIM8mhj9V8KufPym8L7R3yR6QubF0EHv0Qi44NXXbwq+0It42Lfc1BeXWYsMWK0pAmCTKnaJYdcM4JUvG0zUFV9PwLQbQIOL2JX87a6razscdeTnIEeLPDgks= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715254890; c=relaxed/simple; bh=1jdDjfryC/Txk3Ehog5XJe8lFu+V6W6ew2Ru5wmFwlg=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:From:In-Reply-To: Content-Type:References; b=qPN0FcU+FKQbMGq/JC9tWPZdfEOQIuBrXiyHrGXxsxs6mt8smlEWZoGiscA7wwZkbFajOcNm7dN3Jpe/8AtlBK1fvZWQb1wkNTLj/PHV75BlI3LXQyjEmomjiaU4sbvCGeLrSU4eSPDl63HRqtJTkMRvd78BsHkaAoi5JE456sk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=LUsluixc; arc=none smtp.client-ip=210.118.77.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20240509114120euoutp02b3084ce42d499f0d9ef504ba0d14a1ea~NzznHdaGz0039600396euoutp02B for ; Thu, 9 May 2024 11:41:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20240509114120euoutp02b3084ce42d499f0d9ef504ba0d14a1ea~NzznHdaGz0039600396euoutp02B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1715254880; bh=sFuV/tFX3qlWPW5/hEAfuW4Mb0Qblw1Ko/UBLqs3gjE=; h=Date:Subject:To:Cc:From:In-Reply-To:References:From; b=LUsluixcUNWf9hRnJ/2qvWhFlr35sBCrH2g1GJ1Rxaa276Rw1LDURgZ5IJwkb+ywL XMhJgaAVYKz/dCGoc7nqEVfoIsqm/hfiN62oL+WHJ86PVCt1qwmy45ZrW+NBLZEO82 GfWpTPga8Li3tYceMBah/WO8CftrSSJC6P25dQQY= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20240509114119eucas1p2587f7335c4115d3633d2237e25638521~Nzzm3f-NM2502625026eucas1p2r; Thu, 9 May 2024 11:41:19 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 10.7C.09624.F56BC366; Thu, 9 May 2024 12:41:19 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20240509114119eucas1p232697f21d70fde9a42d6d6488aa5d31a~NzzmfrTEZ2502625026eucas1p2q; Thu, 9 May 2024 11:41:19 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240509114119eusmtrp238e878d6f387c6d0e266316b035d27a9~Nzzme36xc0201902019eusmtrp2P; Thu, 9 May 2024 11:41:19 +0000 (GMT) X-AuditID: cbfec7f2-bfbff70000002598-02-663cb65f2399 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 45.9A.08810.F56BC366; Thu, 9 May 2024 12:41:19 +0100 (BST) Received: from [106.210.134.192] (unknown [106.210.134.192]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240509114118eusmtip1f4321fd1d43f2b0bab0d3c1116a1d9e6~NzzlViG3C1979819798eusmtip1r; Thu, 9 May 2024 11:41:18 +0000 (GMT) Message-ID: <46160534-5003-4809-a408-6b3a3f4921e9@samsung.com> Date: Thu, 9 May 2024 13:41:16 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v6 2/7] dma: avoid redundant calls for sync operations To: Alexander Lobakin , Christoph Hellwig Cc: Eric Dumazet , Jakub Kicinski , Robin Murphy , Joerg Roedel , Will Deacon , "Rafael J. Wysocki" , Magnus Karlsson , nex.sw.ncis.osdt.itp.upstreaming@intel.com, bpf@vger.kernel.org, netdev@vger.kernel.org, iommu@lists.linux.dev, linux-kernel@vger.kernel.org Content-Language: en-US From: Marek Szyprowski In-Reply-To: <20240507112026.1803778-3-aleksander.lobakin@intel.com> Content-Transfer-Encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrLKsWRmVeSWpSXmKPExsWy7djP87rx22zSDC7sMrS4+Hkhq8XnI8fZ LJ4ee8RusXL1USaLX18sLDpnb2C3uLCtj9Xi8q45bBYrDp1gtzi2QMxixu2lzBZzv0xltjj4 4QmrRcsdUwc+jycH5zF5rJm3htFjwaZSj8V7XjJ5bFrVyebxYvNMRo/dNxvYPD5vkgvgiOKy SUnNySxLLdK3S+DKuH5/DXvBK5GK1wcnsjQwtgt2MXJySAiYSPw79pipi5GLQ0hgBaPEkgvT 2CGcL4wSj7q3MYNUCQl8ZpS4ssgapuPR/H5WiKLljBJ3L29lhHA+MkqsmHeNEaSKV8BOYuLj 1UwgNouAikTrorfMEHFBiZMzn7CA2KIC8hL3b81gB7GFBbwkDr/rBbNFBMIkHh3tARvKLDCL WeLUzedgzcwC4hK3nswHG8omYCjR9baLDcTmFHCRONuznhWiRl5i+9s5zCDNEgKzOSU+tF5n gbjbReLS3X+sELawxKvjW9ghbBmJ/zvnM0E0tDNKLPh9H8qZwCjR8PwWI0SVtcSdc7+A1nEA rdCUWL9LHyLsKLFgxz6wsIQAn8SNt4IQR/BJTNo2nRkizCvR0SYEUa0mMev4Ori1By9cYp7A qDQLKVxmIXlzFpJ3ZiHsXcDIsopRPLW0ODc9tdgwL7Vcrzgxt7g0L10vOT93EyMwxZ3+d/zT Dsa5rz7qHWJk4mA8xCjBwawkwltVY50mxJuSWFmVWpQfX1Sak1p8iFGag0VJnFc1RT5VSCA9 sSQ1OzW1ILUIJsvEwSnVwKQ3xcvs58aNlSkeooJHPncGvmGeVBG3x6t42Qa3olftkpNybFeE 3vudPMfxZlh4rkO3qm7CF4srmzQq7VwK86JfvPc+nbNfuFLrziH5Pv732zg6PnKdD8pgsWna eZN57kRR7XJz3SzjdnFL2YlL3fryBK8k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B3fDP73ZeD6wbrdI0lKni0WSBiFH jhk+Xrtg3bl7K3ZMq9JN0uY+vLd3cp5q3RUu97Ue6f2lm06nfeuZyj+JfY7fkRBnmW990zdH tHE7vzft2C1021t1xUvVnZO45msVv/i3VuKJboybm/ka/uluF9a5+douv/9N4rTGll5L5cWf fl3ZeK3Pqt77vpvSMQ63xfP1NY9NaC6eZNkdJ5clz1TEt+S+eO8942Kt3gfPM+yEH176VfbZ h3/RSiWW4oxEQy3mouJEAJGPshlyAwAA X-CMS-MailID: 20240509114119eucas1p232697f21d70fde9a42d6d6488aa5d31a X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20240507112115eucas1p117bc01652d4cdbe810de841830227f47 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20240507112115eucas1p117bc01652d4cdbe810de841830227f47 References: <20240507112026.1803778-1-aleksander.lobakin@intel.com> <20240507112026.1803778-3-aleksander.lobakin@intel.com> Dear All, On 07.05.2024 13:20, Alexander Lobakin wrote: > Quite often, devices do not need dma_sync operations on x86_64 at least. > Indeed, when dev_is_dma_coherent(dev) is true and > dev_use_swiotlb(dev) is false, iommu_dma_sync_single_for_cpu() > and friends do nothing. > > However, indirectly calling them when CONFIG_RETPOLINE=y consumes about > 10% of cycles on a cpu receiving packets from softirq at ~100Gbit rate. > Even if/when CONFIG_RETPOLINE is not set, there is a cost of about 3%. > > Add dev->need_dma_sync boolean and turn it off during the device > initialization (dma_set_mask()) depending on the setup: > dev_is_dma_coherent() for the direct DMA, !(sync_single_for_device || > sync_single_for_cpu) or the new dma_map_ops flag, %DMA_F_CAN_SKIP_SYNC, > advertised for non-NULL DMA ops. > Then later, if/when swiotlb is used for the first time, the flag > is reset back to on, from swiotlb_tbl_map_single(). > > On iavf, the UDP trafficgen with XDP_DROP in skb mode test shows > +3-5% increase for direct DMA. > > Suggested-by: Christoph Hellwig # direct DMA shortcut > Co-developed-by: Eric Dumazet > Signed-off-by: Eric Dumazet > Signed-off-by: Alexander Lobakin > --- > include/linux/device.h | 4 +++ > include/linux/dma-map-ops.h | 12 ++++++++ > include/linux/dma-mapping.h | 53 +++++++++++++++++++++++++++++++---- > kernel/dma/mapping.c | 55 +++++++++++++++++++++++++++++-------- > kernel/dma/swiotlb.c | 6 ++++ > 5 files changed, 113 insertions(+), 17 deletions(-) This patch landed in today's linux-next as commit f406c8e4b770 ("dma: avoid redundant calls for sync operations"). Unfortunately I found that it breaks some of the ARM 32bit boards by forcing skipping DMA sync operations on non-coherent systems. This happens because this patch hooks dma_need_sync=true initialization into set_dma_mask(), but set_dma_mask() is not called from all device drivers, especially from those which operates properly with the default 32bit dma mask (like most of the platform devices created by the OF layer). Frankly speaking I have no idea how this should be fixed. I expect that there are lots of broken devices after this change, because I don't remember that calling set_dma_mask() is mandatory for device drivers. After adding dma_set_mask(dev, DMA_BIT_MASK(32)) to the drivers relevant for my boards the issues are gone, but I'm not sure this is the right approach... > ... Best regards -- Marek Szyprowski, PhD Samsung R&D Institute Poland