From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) (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 5BC27186E58; Fri, 27 Sep 2024 09:49:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.191 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727430592; cv=none; b=naRQxzwDgm7grhk+rUTCYnnFssQ4nKJU1K+AuWbUuxQm6VVF9hoECEq5a+C9J/GhzksiaWDTa6vON/jfCPuvVdhxm0va5E0WwSEUKXvU1Wd2ZsFwVaoObXCgoedFEu2FjxfgoM31KPlAETiTo7A/P6vcFkYDf7s9UGCa//NkMWM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727430592; c=relaxed/simple; bh=NC7KgdCdhPtOVGJUsIpjLuEb6Y2Xbx97UfH4DLBwsg0=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=Yc9bd2d9+jgx+C4RTyhSfCdMxIdyVPEe+Z/cNK0XAMX+rYrr5sy4MQNCcj3OGddw1PdeXTgGp+65gNg0VlmtMyXFDaWCQaPLhdbwVOM+D3kqMOA/v9Ii9LiCbn7jOc2hXub94jqOzxcgEx7zI17xjeb8ItF38UlMO7QEcwFAesE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.191 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.163]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4XFQZN2v7qz1HKJ6; Fri, 27 Sep 2024 17:45:48 +0800 (CST) Received: from dggpemf200006.china.huawei.com (unknown [7.185.36.61]) by mail.maildlp.com (Postfix) with ESMTPS id 0AC2018002B; Fri, 27 Sep 2024 17:49:41 +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; Fri, 27 Sep 2024 17:49:40 +0800 Message-ID: <0ef315df-e8e9-41e8-9ba8-dcb69492c616@huawei.com> Date: Fri, 27 Sep 2024 17:49:40 +0800 Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net v2 2/2] page_pool: fix IOMMU crash when driver has already unbound To: Ilias Apalodimas CC: Mina Almasry , , , , , , , Robin Murphy , Alexander Duyck , IOMMU , Wei Fang , Shenwei Wang , Clark Wang , Eric Dumazet , Tony Nguyen , Przemek Kitszel , Alexander Lobakin , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , 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: <20240925075707.3970187-1-linyunsheng@huawei.com> <20240925075707.3970187-3-linyunsheng@huawei.com> <842c8cc6-f716-437a-bc98-70bc26d6fd38@huawei.com> Content-Language: en-US From: Yunsheng Lin In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemf200006.china.huawei.com (7.185.36.61) On 2024/9/27 17:21, Ilias Apalodimas wrote: > Hi Yunsheng > > On Fri, 27 Sept 2024 at 06:58, Yunsheng Lin wrote: >> >> On 2024/9/27 2:15, Mina Almasry 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. >>> >>> One thing I could not understand from looking at the code: if the >>> items array is in the struct page_pool, why do you need to modify the >>> page_pool entry in the struct page and in the struct net_iov? I think >>> the code could be made much simpler if you can remove these changes, >>> and you wouldn't need to modify the public api of the page_pool. >> >> As mentioned in [1]: >> "There is no space in 'struct page' to track the inflight pages, so >> 'pp' in 'struct page' is renamed to 'pp_item' to enable the tracking >> of inflight page" > > I have the same feeling as Mina here. First of all, we do have an > unsigned long in struct page we use for padding IIRC. More I am assuming you are referring to '_pp_mapping_pad' in 'struct page', unfortunately the field might be used when a page is mmap'ed to user space as my understanding. https://elixir.bootlin.com/linux/v6.7-rc8/source/include/linux/mm_types.h#L126 > importantly, though, why does struct page need to know about this? > Can't we have the same information in page pool? > When the driver allocates pages it does via page_pool_dev_alloc_XXXXX > or something similar. Cant we do what you suggest here ? IOW when we > allocate a page we put it in a list, and when that page returns to > page_pool (and it's mapped) we remove it. Yes, that is the basic idea, but the important part is how to do that with less performance impact. 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 smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 623E3CEBF8C for ; Fri, 27 Sep 2024 09:49:53 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 0613B424C7; Fri, 27 Sep 2024 09:49:53 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 5B_XwOMswF6B; Fri, 27 Sep 2024 09:49:51 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.166.34; helo=ash.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org C909D424CC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1727430591; bh=7AYI6NCmdRDuABQX7HORneVc3Wnz4MDmFG9L55U74f8=; h=Date:To:References:From:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=CH9HPdRQt0QktmSfiqnLGkC48eckqlG6NgZiLNgwpneN37zZu/3xzh7HfEE1OHAkC g9Y0PMr1InTE7ofP6S+Z4Luihavh2oi9K6ychlCcZ9mgbnKf5OK3eWcc8rVMFlJ+KM rnX5Doz9IohAApBrox5iieWD2ub5wxlTiLylxxcAwuRsTC8h+yrxVz92C9VioItF/e yU/quOMObrewwwsDtML5dgR+5VLL6aUX1SYhr3iggCSJ6jtMQzNxoSb3LWVcQoVILN BwugemqyAvbYo/sLFutMVysoc6SnhguIjhDz7n+TEpPjtcoW/Xdd5MOCb3bQl4CBpK oMW7KGSNhh3tg== Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp4.osuosl.org (Postfix) with ESMTP id C909D424CC; Fri, 27 Sep 2024 09:49:51 +0000 (UTC) Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 2F6101BF980 for ; Fri, 27 Sep 2024 09:49:50 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 1C41941C18 for ; Fri, 27 Sep 2024 09:49:50 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 91DSD8d9v9Mn for ; Fri, 27 Sep 2024 09:49:48 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=45.249.212.191; helo=szxga05-in.huawei.com; envelope-from=linyunsheng@huawei.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp2.osuosl.org CA8AB41BFB DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org CA8AB41BFB Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by smtp2.osuosl.org (Postfix) with ESMTPS id CA8AB41BFB for ; Fri, 27 Sep 2024 09:49:46 +0000 (UTC) Received: from mail.maildlp.com (unknown [172.19.88.163]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4XFQZN2v7qz1HKJ6; Fri, 27 Sep 2024 17:45:48 +0800 (CST) Received: from dggpemf200006.china.huawei.com (unknown [7.185.36.61]) by mail.maildlp.com (Postfix) with ESMTPS id 0AC2018002B; Fri, 27 Sep 2024 17:49:41 +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; Fri, 27 Sep 2024 17:49:40 +0800 Message-ID: <0ef315df-e8e9-41e8-9ba8-dcb69492c616@huawei.com> Date: Fri, 27 Sep 2024 17:49:40 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: Ilias Apalodimas References: <20240925075707.3970187-1-linyunsheng@huawei.com> <20240925075707.3970187-3-linyunsheng@huawei.com> <842c8cc6-f716-437a-bc98-70bc26d6fd38@huawei.com> Content-Language: en-US From: Yunsheng Lin In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit 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-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Subject: Re: [Intel-wired-lan] [PATCH net v2 2/2] page_pool: fix IOMMU crash when driver has already unbound X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: imx@lists.linux.dev, Alexei Starovoitov , Alexander Duyck , linux-mm@kvack.org, Eric Dumazet , Tony Nguyen , Shenwei Wang , Mina Almasry , Ryder Lee , Daniel Borkmann , linux-rdma@vger.kernel.org, Przemek Kitszel , John Fastabend , IOMMU , liuyonglong@huawei.com, Clark Wang , zhangkun09@huawei.com, fanghaiqing@huawei.com, pabeni@redhat.com, Lorenzo Bianconi , Jesper Dangaard Brouer , Kalle Valo , Sean Wang , Wei Fang , kuba@kernel.org, Matthias Brugger , intel-wired-lan@lists.osuosl.org, bpf@vger.kernel.org, linux-arm-kernel@lists.infradead.org, AngeloGioacchino Del Regno , Leon Romanovsky , Robin Murphy , linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, Tariq Toukan , Alexander Lobakin , netdev@vger.kernel.org, linux-mediatek@lists.infradead.org, Andrew Morton , Shayne Chen , Saeed Mahameed , davem@davemloft.net, Felix Fietkau Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" On 2024/9/27 17:21, Ilias Apalodimas wrote: > Hi Yunsheng > > On Fri, 27 Sept 2024 at 06:58, Yunsheng Lin wrote: >> >> On 2024/9/27 2:15, Mina Almasry 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. >>> >>> One thing I could not understand from looking at the code: if the >>> items array is in the struct page_pool, why do you need to modify the >>> page_pool entry in the struct page and in the struct net_iov? I think >>> the code could be made much simpler if you can remove these changes, >>> and you wouldn't need to modify the public api of the page_pool. >> >> As mentioned in [1]: >> "There is no space in 'struct page' to track the inflight pages, so >> 'pp' in 'struct page' is renamed to 'pp_item' to enable the tracking >> of inflight page" > > I have the same feeling as Mina here. First of all, we do have an > unsigned long in struct page we use for padding IIRC. More I am assuming you are referring to '_pp_mapping_pad' in 'struct page', unfortunately the field might be used when a page is mmap'ed to user space as my understanding. https://elixir.bootlin.com/linux/v6.7-rc8/source/include/linux/mm_types.h#L126 > importantly, though, why does struct page need to know about this? > Can't we have the same information in page pool? > When the driver allocates pages it does via page_pool_dev_alloc_XXXXX > or something similar. Cant we do what you suggest here ? IOW when we > allocate a page we put it in a list, and when that page returns to > page_pool (and it's mapped) we remove it. Yes, that is the basic idea, but the important part is how to do that with less performance impact.