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 583C9CE8D79 for ; Thu, 19 Sep 2024 11:15:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B56376B009B; Thu, 19 Sep 2024 07:15:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B064B6B009C; Thu, 19 Sep 2024 07:15:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9CD6C6B009D; Thu, 19 Sep 2024 07:15:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 7FB396B009B for ; Thu, 19 Sep 2024 07:15:20 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id F0E00C016A for ; Thu, 19 Sep 2024 11:15:19 +0000 (UTC) X-FDA: 82581231558.18.E63F60C Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf10.hostedemail.com (Postfix) with ESMTP id 7C732C000D for ; Thu, 19 Sep 2024 11:15:16 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf10.hostedemail.com: domain of linyunsheng@huawei.com designates 45.249.212.190 as permitted sender) smtp.mailfrom=linyunsheng@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1726744506; a=rsa-sha256; cv=none; b=iCURlZ/p4jc0E0n4g8g+v0dM+8tCtX0Iw87rTXkQML0CzTQGkUq+KzbMRNVn0wrII14kIW 9OH+rpuRxj43RvFLnQQ5QcJDwMHpGH4NDl3fSnS5zT+5hmbO9TOtnsNtXA9mgCXItmkouu 8+rytQikc99dIJWWRlQHYXpQ0CqaDAM= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf10.hostedemail.com: domain of linyunsheng@huawei.com designates 45.249.212.190 as permitted sender) smtp.mailfrom=linyunsheng@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1726744506; 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; bh=p3rtOXABuszq7zwsUSot007jGp9KE4ganvdrQReiyj4=; b=jb4wziXN8a97SPSn3TLvI5ELKXicKi6sHtVDTA40CAnE1+TmMEUQ+Shy+6Q582gy2ckCBS JsWSmOHLxYrhQbxJhSEaqCwQkwbHszBaADMmGU8YGSDsiRAk+1Dgm0en8ZplTT0vivtINB Ab3jVz5co0bC6/2UOAT4nHaz9azHMRs= Received: from mail.maildlp.com (unknown [172.19.88.214]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4X8XwS0qCqz2DcFV; Thu, 19 Sep 2024 19:14:32 +0800 (CST) Received: from dggpemf200006.china.huawei.com (unknown [7.185.36.61]) by mail.maildlp.com (Postfix) with ESMTPS id BC8361A016C; Thu, 19 Sep 2024 19:15:11 +0800 (CST) Received: from [10.67.120.129] (10.67.120.129) by dggpemf200006.china.huawei.com (7.185.36.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 19 Sep 2024 19:15:11 +0800 Message-ID: Date: Thu, 19 Sep 2024 19:15:11 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net 2/2] page_pool: fix IOMMU crash when driver has already unbound To: Jesper Dangaard Brouer , Ilias Apalodimas CC: , , , , , , Robin Murphy , Alexander Duyck , IOMMU , Wei Fang , Shenwei Wang , Clark Wang , Eric Dumazet , Tony Nguyen , Przemek Kitszel , Alexander Lobakin , Alexei Starovoitov , Daniel Borkmann , John Fastabend , Saeed Mahameed , Leon Romanovsky , Tariq Toukan , Felix Fietkau , Lorenzo Bianconi , Ryder Lee , Shayne Chen , Sean Wang , Kalle Valo , Matthias Brugger , AngeloGioacchino Del Regno , Andrew Morton , , , , , , , , , , References: <20240918111826.863596-1-linyunsheng@huawei.com> <20240918111826.863596-3-linyunsheng@huawei.com> <894a3c2c-22f9-45b9-a82b-de7320066b42@kernel.org> Content-Language: en-US From: Yunsheng Lin In-Reply-To: <894a3c2c-22f9-45b9-a82b-de7320066b42@kernel.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.67.120.129] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemf200006.china.huawei.com (7.185.36.61) X-Rspam-User: X-Stat-Signature: gcb8pqucd4mc7qinhfx9nspcno3ngn71 X-Rspamd-Queue-Id: 7C732C000D X-Rspamd-Server: rspam02 X-HE-Tag: 1726744516-215193 X-HE-Meta: U2FsdGVkX1+df36ElC07MRFTWD9YApqzO2QzGQ2tmu/f138wdDYxbmVfz1y8KmAHVT8qtv2EuO4+XdGZchsAPMdt1w7YGjbkILcIfsW3pp2gBwBgRfKk0qZcAFSv03uW7hLkxDm+c5o23ED6XBJInKkFiv55jyY6iCrG7AaRIkRU5HY+r6L/b9MAK66GVnYJ1YBOuV/aTm4lELQ3nyscajit9T0Vh5sktdRM2Ll7Q7qaKucRdRK0SMsT5jS+WPA8CbXXynFEC/+vGRjQfapFVFMSugdDxxj98fwVV2aeKXOL2G3oxoxf2ddCppfJsDQdMB8Jr07hinxLM/HfnwO33ULMoS1MQUUmONrvafsCZpHX4+J5wZDbGrSQI4C9ePT1k/IL1LsC6KRwuv4BG86pn61+kG6xbr4u0C6SPTXSF4Q+V5c+YOI08etIObFjAmTLUKmLCt/GzslOgneYhXk52JdqMrFpD6b/k0Wqlvrmtgmjs6jpyMehJd6/HZgAEkY/HT6FMD+NdHV3uAoXXyF2QfDFvVTQPjp7b+dfcwOZx3bRxhnYByrhuBNy951hfBG8oDKr/ZyFHRCcAAbXcQ+ngv5S3BctMjt9hUhGaacVSmCXeqYMJi8XDijwLruXQOWXgx0ClB2wUSov+GzvpNjH44Psrx8ej8MJBWtcuyBOTfvmpqZtyHmsE/cFRJGh7NT5YO650F4aSI6SL/dG9MQ8HI+4xcNLSe8NnEh8bNLlDtKyljRWOC/NYtPTJFLWok4os0C7vLpZtAPj6IQVzXtCs8arWVK6HayNwvEf8L5d9xKmbrtptOdkE3crlo+4aHAbD0LIfBduLbL6Q/TzxSwod3qts4Eq+BsOCWdzhJ1OJbaaXmzpH0vh1B7bzJq2yi098YcUpbCFKK22tTwNbDefF0Rt7qiacWH7bs5dPF2trp9EII40Da2xXMpmBoi03FP0at0LSZXzUTczx1dbLV6 aaCcSAb8 JCso7mYkR3cREKFqGE2LqYdchecOF94xMw2T2aWm2woNrgrtoLtQQhyQjgAsQdkWXsEHxxrtg6ALQoFLIK+Z3kHT6pNccMY3+5Z6cX3O6k9qrXaQayYIz0oRccP2TaAaz8J/xmNwjug/fmw85U6ptjYzuxQLtioTs3M9o1wuVY0PNkSrx9yXOAt2RUwKABoK6oWDnBzZrH7C7GiSmDacn+SZ9MkQ6hIitNAETgYROY5nlvpHMegRCDsOG3cxc32JWifPy7ywPHOivPtotSV245PPAHBQYxBrWJZh5KcCGXze//MFyMisqDM32Cxy/BYSsBsWZ 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 2024/9/19 17:42, Jesper Dangaard Brouer wrote: > > On 18/09/2024 19.06, Ilias Apalodimas wrote: >>> In order not to do the dma unmmapping after driver has already >>> unbound and stall the unloading of the networking driver, add >>> the pool->items array to record all the pages including the ones >>> which are handed over to network stack, so the page_pool can >>> do the dma unmmapping for those pages when page_pool_destroy() >>> is called. >> >> So, I was thinking of a very similar idea. But what do you mean by >> "all"? The pages that are still in caches (slow or fast) of the pool >> will be unmapped during page_pool_destroy(). > > I really dislike this idea of having to keep track of all outstanding pages. > > I liked Jakub's idea of keeping the netdev around for longer. > > This is all related to destroying the struct device that have points to > the DMA engine, right? Yes, the problem seems to be that when device_del() is called, there is no guarantee hw behind the 'struct device ' will be usable even if we call get_device() on it. > > Why don't we add an API that allow netdev to "give" struct device to > page_pool.  And then the page_poll will take over when we can safely > free the stuct device? By 'allow netdev to "give" struct device to page_pool', does it mean page_pool become the driver for the device? If yes, it seems that is similar to jakub's idea, as both seems to stall the calling of device_del() by not returning when the driver unloading. If no, it seems that the problem is still existed when the driver for the device has unbound after device_del() is called. > > --Jesper