From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7817C02187 for ; Thu, 16 Jan 2025 18:03:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E64906B0082; Thu, 16 Jan 2025 13:03:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E145A6B0083; Thu, 16 Jan 2025 13:03:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CB4EB6B0085; Thu, 16 Jan 2025 13:03:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id AC4C36B0082 for ; Thu, 16 Jan 2025 13:03:10 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 64C4F458FA for ; Thu, 16 Jan 2025 18:03:10 +0000 (UTC) X-FDA: 83014086540.17.1A3AE15 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf14.hostedemail.com (Postfix) with ESMTP id 8DABC10000F for ; Thu, 16 Jan 2025 18:03:08 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=JeJd3zIn; spf=pass (imf14.hostedemail.com: domain of hawk@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=hawk@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1737050588; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=T/ueRQzMQN/S+kB1tovVzhUu17r+Mocepb7YVFoxlgE=; b=FjbmP7wNQUGBBapgheEohxWec09PiuBVXUn3bN1AE8wsXD/rbfpDm9UU5Z5rIM1UnvkGdO Pqi4B1vDNEDAqEv2qpjpGmsiTafnToAZlMaqkeqirZ3YMVcR6Xkfm1jEgL3yh7Hj/gjiLH zZIx+UAaMz+hbVndyqpgoUAYMbFXpwo= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=JeJd3zIn; spf=pass (imf14.hostedemail.com: domain of hawk@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=hawk@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1737050588; a=rsa-sha256; cv=none; b=QHmxSbuXYikfpjz1XgE2sEjYcS08mcEJynIusWPOCS7OYRrEmJrP5nEUxx+TnjBVLTQecy 6y3CTZa08jsoWZPU3emi9DmenqZk44DcJzev3QWwdFyvesenO4hWmhAUYj00lCWGQYYalz qr2iJv2pPhBnjnUYpo0dRZpsDLOYnLA= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 8DC1BA4252A; Thu, 16 Jan 2025 18:01:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E65FAC4CED6; Thu, 16 Jan 2025 18:03:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1737050587; bh=NJ3mCKVaerTWKdIY3yecqSXXrLTSZSkqHQ/cdTJWkEI=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=JeJd3zInKgbOG12tOr+M4tKEbxueUw/GyR+YtZoFsftDzz0NwbDdOaZmqF5FjYFUW fq6OXxaf+kc1UKQI2xkfNOn0SjTKJnNQ6aXrCf7yXLUanwJgEZH991A6sCCJnotDSa 45KUpiLVVf0vfVmDz6J+L0vQgxFwLj175YRjmd52cG4KnnH6aZEz/BDLoa+3C2t4i0 kFtpeTJZdQUiafVv1ZfytHfbDixLf90R7zdAKIEem/f2ynVZGfoZoC/U9Zb8dAxh/z MRQBfGJg4zbVKAH1DtDFnZUofqYFq86ctZEd5OYqGxAaLB1XT8L0cfy+QG3chLi3AZ KqN2d3gF1mAPw== Message-ID: Date: Thu, 16 Jan 2025 19:02:59 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net-next v7 0/8] fix two bugs related to page_pool To: Yunsheng Lin , davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com Cc: zhangkun09@huawei.com, liuyonglong@huawei.com, fanghaiqing@huawei.com, Alexander Lobakin , Robin Murphy , Alexander Duyck , Andrew Morton , IOMMU , MM , Alexei Starovoitov , Daniel Borkmann , John Fastabend , Matthias Brugger , AngeloGioacchino Del Regno , netdev@vger.kernel.org, intel-wired-lan@lists.osuosl.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org References: <20250110130703.3814407-1-linyunsheng@huawei.com> <3c8e4f86-87e2-470d-84d8-86c70b3e2fcc@kernel.org> <3a853e1b-b5bf-4709-b8f6-e466e3e7375e@kernel.org> <1bef4a35-efaa-4083-8ed5-8818fe285db5@huawei.com> Content-Language: en-US From: Jesper Dangaard Brouer In-Reply-To: <1bef4a35-efaa-4083-8ed5-8818fe285db5@huawei.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 8DABC10000F X-Stat-Signature: wd5soaqzcmkykazsxo6kjds8y3pys3n1 X-HE-Tag: 1737050588-259742 X-HE-Meta: U2FsdGVkX1+j0KDruN2FxHrOVE+pq/Bjp5FGskhEohweImW7Uqi7rBQUfu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wWkGlZXXogqPF6PU33zGB80RL4aGuslC/KSn/AjGxE+cCvP3/zo5DJhsssxa4kc3zzPeyHngQPzUt+zXE5OfXo4FAL+LHXDwWHPbzOv7xdMKoFrANplZdST5uh+NVtwmDgBg8YcilRjZsrqTcC2WTePP7prB4Picfx3bMSnLsXKEZTOFY+Qg7uFKpVvuSCEbw2u/HPgrbSBPEA0UXFjvgk3cgHcb0UWdywBC6KrqHgPXrndmOLAkaqmwz+gFEV1oWN2+9Qxlb8VockRClRwtoX61Op+yAqSKZxBNProdKJL94nzqlXBUeyinCFrMqVuii0Axn7Vm52gHYqQebHzUnM0tizEIlw5BeC8jYycFKkoIe5k= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 16/01/2025 13.52, Yunsheng Lin wrote: > On 2025/1/16 1:40, Jesper Dangaard Brouer wrote: >> >> >> On 15/01/2025 12.33, Yunsheng Lin wrote: >>> On 2025/1/14 22:31, Jesper Dangaard Brouer wrote: >>>> >>>> >>>> On 10/01/2025 14.06, Yunsheng Lin wrote: >>>>> This patchset fix a possible time window problem for page_pool and >>>>> the dma API misuse problem as mentioned in [1], and try to avoid the >>>>> overhead of the fixing using some optimization. >>>>> >>>>>   From the below performance data, the overhead is not so obvious >>>>> due to performance variations for time_bench_page_pool01_fast_path() >>>>> and time_bench_page_pool02_ptr_ring, and there is about 20ns overhead >>>>> for time_bench_page_pool03_slow() for fixing the bug. >>>>> >>>> >>>> My benchmarking on x86_64 CPUs looks significantly different. >>>>   - CPU: Intel(R) Xeon(R) CPU E5-1650 v4 @ 3.60GHz >>>> >>>> Benchmark (bench_page_pool_simple) results from before and after patchset: >>>> >>>> | Test name  | Cycles |       |    |Nanosec |        |       |      % | >>>> | (tasklet_*)| Before | After |diff| Before |  After |  diff | change | >>>> |------------+--------+-------+----+--------+--------+-------+--------| >>>> | fast_path  |     19 |    24 |   5|  5.399 |  6.928 | 1.529 |   28.3 | >>>> | ptr_ring   |     54 |    79 |  25| 15.090 | 21.976 | 6.886 |   45.6 | >>>> | slow       |    238 |   299 |  61| 66.134 | 83.298 |17.164 |   26.0 | >>>> #+TBLFM: $4=$3-$2::$7=$6-$5::$8=(($7/$5)*100);%.1f >>>> >>>> My above testing show a clear performance regressions across three >>>> different page_pool operating modes. >>> >>> I retested it on arm64 server patch by patch as the raw performance >>> data in the attachment, it seems the result seemed similar as before. >>> >>> Before this patchset: >>>              fast_path              ptr_ring            slow >>> 1.         31.171 ns               60.980 ns          164.917 ns >>> 2.         28.824 ns               60.891 ns          170.241 ns >>> 3.         14.236 ns               60.583 ns          164.355 ns >>> >>> With patch 1-4: >>> 4.         31.443 ns               53.242 ns          210.148 ns >>> 5.         31.406 ns               53.270 ns          210.189 ns >>> >>> With patch 1-5: >>> 6.         26.163 ns               53.781 ns          189.450 ns >>> 7.         26.189 ns               53.798 ns          189.466 ns >>> >>> With patch 1-8: >>> 8.         28.108 ns               68.199 ns          202.516 ns >>> 9.         16.128 ns               55.904 ns          202.711 ns >>> >>> I am not able to get hold of a x86 server yet, I might be able >>> to get one during weekend. >>> >>> Theoretically, patch 1-4 or 1-5 should not have much performance >>> impact for fast_path and ptr_ring except for the rcu_lock mentioned >>> in page_pool_napi_local(), so it would be good if patch 1-5 is also >>> tested in your testlab with the rcu_lock removing in >>> page_pool_napi_local(). >>> >> >> What are you saying? >>  - (1) test patch 1-5 >>  - or (2) test patch 1-5 but revert patch 2 with page_pool_napi_local() > > patch 1-5 with below applied. > > --- a/net/core/page_pool.c > +++ b/net/core/page_pool.c > @@ -1207,10 +1207,8 @@ static bool page_pool_napi_local(const struct page_pool *pool) > /* Synchronizated with page_pool_destory() to avoid use-after-free > * for 'napi'. > */ > - rcu_read_lock(); > napi = READ_ONCE(pool->p.napi); > napi_local = napi && READ_ONCE(napi->list_owner) == cpuid; > - rcu_read_unlock(); > > return napi_local; > } > Benchmark (bench_page_pool_simple) results from before and after patchset with patches 1-5m and rcu lock removal as requested. | Test name |Cycles | 1-5 | | Nanosec | 1-5 | | % | | (tasklet_*)|Before | After |diff| Before | After | diff | change | |------------+-------+-------+----+---------+--------+--------+--------| | fast_path | 19 | 19 | 0| 5.399 | 5.492 | 0.093 | 1.7 | | ptr_ring | 54 | 57 | 3| 15.090 | 15.849 | 0.759 | 5.0 | | slow | 238 | 284 | 46| 66.134 | 78.909 | 12.775 | 19.3 | #+TBLFM: $4=$3-$2::$7=$6-$5::$8=(($7/$5)*100);%.1f This test with patches 1-5 looks much better regarding performance. --Jesper https://github.com/xdp-project/xdp-project/blob/main/areas/mem/page_pool07_bench_DMA_fix.org#e5-1650-pp01-dma-fix-v7-p1-5 Kernel: - 6.13.0-rc6-pp01-DMA-fix-v7-p1-5+ #5 SMP PREEMPT_DYNAMIC Thu Jan 16 18:06:53 CET 2025 x86_64 GNU/Linux Machine: Intel(R) Xeon(R) CPU E5-1650 v4 @ 3.60GHz modprobe bench_page_pool_simple loops=100000000 Raw data: [ 187.309423] bench_page_pool_simple: time_bench_page_pool01_fast_path(): Cannot use page_pool fast-path [ 187.872849] time_bench: Type:no-softirq-page_pool01 Per elem: 19 cycles(tsc) 5.539 ns (step:0) - (measurement period time:0.553906443 sec time_interval:553906443) - (invoke count:100000000 tsc_interval:1994123064) [ 187.892023] bench_page_pool_simple: time_bench_page_pool02_ptr_ring(): Cannot use page_pool fast-path [ 189.611070] time_bench: Type:no-softirq-page_pool02 Per elem: 61 cycles(tsc) 17.095 ns (step:0) - (measurement period time:1.709580367 sec time_interval:1709580367) - (invoke count:100000000 tsc_interval:6154679394) [ 189.630414] bench_page_pool_simple: time_bench_page_pool03_slow(): Cannot use page_pool fast-path [ 197.222387] time_bench: Type:no-softirq-page_pool03 Per elem: 272 cycles(tsc) 75.826 ns (step:0) - (measurement period time:7.582681388 sec time_interval:7582681388) - (invoke count:100000000 tsc_interval:27298499214) [ 197.241926] bench_page_pool_simple: pp_tasklet_handler(): in_serving_softirq fast-path [ 197.249968] bench_page_pool_simple: time_bench_page_pool01_fast_path(): in_serving_softirq fast-path [ 197.808470] time_bench: Type:tasklet_page_pool01_fast_path Per elem: 19 cycles(tsc) 5.492 ns (step:0) - (measurement period time:0.549225541 sec time_interval:549225541) - (invoke count:100000000 tsc_interval:1977272238) [ 197.828174] bench_page_pool_simple: time_bench_page_pool02_ptr_ring(): in_serving_softirq fast-path [ 199.422305] time_bench: Type:tasklet_page_pool02_ptr_ring Per elem: 57 cycles(tsc) 15.849 ns (step:0) - (measurement period time:1.584920736 sec time_interval:1584920736) - (invoke count:100000000 tsc_interval:5705890830) [ 199.442087] bench_page_pool_simple: time_bench_page_pool03_slow(): in_serving_softirq fast-path [ 207.342120] time_bench: Type:tasklet_page_pool03_slow Per elem: 284 cycles(tsc) 78.909 ns (step:0) - (measurement period time:7.890955151 sec time_interval:7890955151) - (invoke count:100000000 tsc_interval:28408319289)