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 38FD5D42B85 for ; Tue, 12 Nov 2024 14:20:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9C28F6B00E1; Tue, 12 Nov 2024 09:20:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 924A36B00E3; Tue, 12 Nov 2024 09:20:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 777566B00E8; Tue, 12 Nov 2024 09:20:03 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 4AFF36B00E1 for ; Tue, 12 Nov 2024 09:20:03 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id EC4201A01CB for ; Tue, 12 Nov 2024 14:20:02 +0000 (UTC) X-FDA: 82777650942.21.A0803C6 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf20.hostedemail.com (Postfix) with ESMTP id 137D81C000F for ; Tue, 12 Nov 2024 14:19:08 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=mH8IrupO; spf=pass (imf20.hostedemail.com: domain of hawk@kernel.org designates 139.178.84.217 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=1731420968; 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=EFUhzZZhIhayFiz/2l1RgvgEBdMfvIS4hSueQ+6E0yM=; b=wEZIiVP4hVnkJGZGVSLJWgoNPvTmdJUfLAMeNV7wIbN++AbqxrsnCFr1TaIO5pmzwL/mXF c6GqtYryhyUZAYUmhPAvww01DV6qiL91JjEHZLwRBQkUkUQIsQf5jy5orJiVxI45W+TLDm wPy1X1NpEbIjtkOpS4RfFPXOl0cYXkU= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=mH8IrupO; spf=pass (imf20.hostedemail.com: domain of hawk@kernel.org designates 139.178.84.217 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=1731420968; a=rsa-sha256; cv=none; b=lV/7i7hhy8jul6SKvLiU6dP53rcqSBtLd13/0nbPFtvBOdddbBjJen8XKDohLs+PxP04Ga oV4+Du4yXG7ZXLt3/pCF+WwIHwU+UniIcT8Zk1ODx5yPRP4R0cygnsWqhCmFgCKufh8tcQ JQ1pxj8EIKKD2GwFvzpUGIfP60AiYLI= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id B36295C060F; Tue, 12 Nov 2024 14:19:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C8D22C4CED0; Tue, 12 Nov 2024 14:19:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731421199; bh=pyCRt7WsO3Xx1qWQt6wDCYbx1z5ltqc3D58U2xm3SxI=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=mH8IrupOR8xDLzqnBWoXNh0OSoCs8trWxSM5z987hNW/Y/i1EhmNa28VebFQ0OIx5 pTUaApI/oK8fFlMk8S0r/AxmcYAZ78iuJJNompwZuzlE+ek+zNrSxSx34XwySJ3VGg got8/Ra1SW4huMVdaEfvjuiSPUS41VSn97NvKP6HmVsGRc6NfxKOvrqAEgXK542RcI y7tzuGLv12YmAJQ7nN4TviSrYAn3vUU7a6t32OnHEUoFN2fmqdrbaTe9KFrx+u1d8E 0HvX9ruCIaSWkbU6j/KnLJQFPxVt4H839dNYlPPsWZt+g1gG+oKVnZtTapRRhr8es5 koq6gJQehkYrQ== Message-ID: Date: Tue, 12 Nov 2024 15:19:53 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net-next v3 3/3] page_pool: fix IOMMU crash when driver has already unbound To: Yunsheng Lin , =?UTF-8?Q?Toke_H=C3=B8iland-J=C3=B8rgensen?= , davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com Cc: zhangkun09@huawei.com, fanghaiqing@huawei.com, liuyonglong@huawei.com, Robin Murphy , Alexander Duyck , IOMMU , Andrew Morton , Eric Dumazet , Ilias Apalodimas , linux-mm@kvack.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, kernel-team References: <20241022032214.3915232-1-linyunsheng@huawei.com> <20241022032214.3915232-4-linyunsheng@huawei.com> <113c9835-f170-46cf-92ba-df4ca5dfab3d@huawei.com> <878qudftsn.fsf@toke.dk> <87r084e8lc.fsf@toke.dk> <0c146fb8-4c95-4832-941f-dfc3a465cf91@kernel.org> <204272e7-82c3-4437-bb0d-2c3237275d1f@huawei.com> <4564c77b-a54d-4307-b043-d08e314c4c5f@huawei.com> <87ldxp4n9v.fsf@toke.dk> Content-Language: en-US From: Jesper Dangaard Brouer In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 137D81C000F X-Stat-Signature: bi7smpcqud53nx369nxsmsmz7tookeho X-Rspam-User: X-HE-Tag: 1731421148-84017 X-HE-Meta: U2FsdGVkX18aWz54cwuNRAfxCubcOp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RYnVamx9PYcc2xMb+t7f0FvK509iJVwC/tpHWqfkP7jRV+G95mBPUCnheYCSmxokfHDvkA4AvgutTeuhFFWx0GqkH3d12Sk7iuCwP5ULNmzyPYx+ZXwxG8awYfhPRmudbhF4FFwz3my1V4Chti9bts4nwO2lQABuF699pVpJs9OXGuv7+a0/3Ifn45GUNX18/WgXJ2gUPiV6aN1N0yn4e527XEPZCVK0OKhHL3xaK2Zf0k37ZFELEx4zbPECgNSiQbAKTVj6GU6jaMvYrOLgZGju1fgAXfptc4/df6YkvZ2eD6Dhog8ORuwQ+oHrF1zm8B7k+MV24x4XGIRa4CG3wrW7nP2WsK4j+d3ZHswNUThbPk4Alqj9lxK7ufw= 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 12/11/2024 13.22, Yunsheng Lin wrote: > On 2024/11/12 2:51, Toke Høiland-Jørgensen wrote: > > ... > >>> >>> Is there any other suggestion/concern about how to fix the problem here? >>> >>> From the previous discussion, it seems the main concern about tracking the >>> inflight pages is about how many inflight pages it is needed. >> >> Yeah, my hardest objection was against putting a hard limit on the >> number of outstanding pages. >> >>> If there is no other suggestion/concern , it seems the above concern might be >>> addressed by using pre-allocated memory to satisfy the mostly used case, and >>> use the dynamically allocated memory if/when necessary. >> >> For this, my biggest concern would be performance. >> >> In general, doing extra work in rarely used code paths (such as device >> teardown) is much preferred to adding extra tracking in the fast path. >> Which would be an argument for Alexander's suggestion of just scanning >> the entire system page table to find pages to unmap. Don't know enough >> about mm system internals to have an opinion on whether this is >> feasible, though. > > Yes, there seems to be many MM system internals, like the CONFIG_SPARSEMEM* > config, memory offline/online and other MM specific optimization that it > is hard to tell it is feasible. > > It would be good if MM experts can clarify on this. > Yes, please. Can Alex Duyck or MM-experts point me at some code walking entire system page table? Then I'll write some kernel code (maybe module) that I can benchmark how long it takes on my machine with 384GiB. I do like Alex'es suggestion, but I want to assess the overhead of doing this on modern hardware. >> >> In any case, we'll need some numbers to really judge the overhead in >> practice. So benchmarking would be the logical next step in any case :) > > Using POC code show that using the dynamic memory allocation does not > seems to be adding much overhead than the pre-allocated memory allocation > in this patch, the overhead is about 10~20ns, which seems to be similar to > the overhead of added overhead in the patch. > Overhead around 10~20ns is too large for page_pool, because XDP DDoS use-case have a very small time budget (which is what page_pool was designed for). [1] https://github.com/xdp-project/xdp-project/blob/master/areas/hints/traits01_bench_kmod.org#benchmark-basics | Link speed | Packet rate | Time-budget | | | at smallest pkts size | per packet | |------------+-----------------------+---------------| | 10 Gbit/s | 14,880,952 pps | 67.2 nanosec | | 25 Gbit/s | 37,202,381 pps | 26.88 nanosec | | 100 Gbit/s | 148,809,523 pps | 6.72 nanosec | --Jesper