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 2C3F0CEBF8C for ; Fri, 27 Sep 2024 09:59:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 903EF6B00C7; Fri, 27 Sep 2024 05:59:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8B43E6B00C9; Fri, 27 Sep 2024 05:59:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7A27E6B00CB; Fri, 27 Sep 2024 05:59:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 583416B00C7 for ; Fri, 27 Sep 2024 05:59:35 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id F119FABE7F for ; Fri, 27 Sep 2024 09:59:34 +0000 (UTC) X-FDA: 82610071068.29.5A5BFE2 Received: from mail-pg1-f170.google.com (mail-pg1-f170.google.com [209.85.215.170]) by imf29.hostedemail.com (Postfix) with ESMTP id 3182F12000F for ; Fri, 27 Sep 2024 09:59:32 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=linaro.org header.s=google header.b="MZjOSV/k"; dmarc=pass (policy=none) header.from=linaro.org; spf=pass (imf29.hostedemail.com: domain of ilias.apalodimas@linaro.org designates 209.85.215.170 as permitted sender) smtp.mailfrom=ilias.apalodimas@linaro.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1727431038; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=/wFHvQrnJe6+I0Hk404NsRdbI8eFHq8tb62kLJdsI/o=; b=aS4jIvvAjOT1t2J8hjkYQ7OPbrSfcjUceC5/ZGu0CnBaBZTN4LoIgZM8lqgiPMXDTMh7Ju k4R+CNoXpmENXR/W3VGI3GRlCgnTdo8aO/K+4EmfuPJX7vufervM7zoQR5lRhnxPw8sZSq WUgG1ZDqI8n+z/ifU/dncztel+c0YjI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727431038; a=rsa-sha256; cv=none; b=lsZFnS5lOshBpYbiLivycZdi/iSHuouHX1PUmfwfBoIhCFBEQ5nKnwnZMBaioTAt1Ski9a Qc7EIRx/5T/o0jD/ROTsqpPqlD6FAl3/q0ts5bOLilBFtP3tYNsr3kQy/puwmxVczBgMag en+dFOJm7CGN5EpTsPghh6FTDkNiKns= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=linaro.org header.s=google header.b="MZjOSV/k"; dmarc=pass (policy=none) header.from=linaro.org; spf=pass (imf29.hostedemail.com: domain of ilias.apalodimas@linaro.org designates 209.85.215.170 as permitted sender) smtp.mailfrom=ilias.apalodimas@linaro.org Received: by mail-pg1-f170.google.com with SMTP id 41be03b00d2f7-7db637d1e4eso1550258a12.2 for ; Fri, 27 Sep 2024 02:59:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727431172; x=1728035972; darn=kvack.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=/wFHvQrnJe6+I0Hk404NsRdbI8eFHq8tb62kLJdsI/o=; b=MZjOSV/k/O4LTFgsHZgw6zgmqi4vLGMlc6tbcHrKj/Vzj5ksMmDJoZHtdmtiHdumkX VSjpXQOsCfkX/iydPd/RL+XSCiiqZJ+OerQMvdSnTv5IrA/mHWfyYuXj/a4iCuvC9asm +NtsKaEFKFKTuBNN+XgHpCah4rsv7g5i2PawRG36Krxg+lWweTEnwKLETix5J9CP51DF ohGQO9FT8FThU2VleKqCO91OssXH296D0e8rtlRKYOhhd0yQ1W7++na/rsKS7c/jUj4J zwV3qZ3bRUfDd+/nl7jQk6JYnts1Q4Q/99n/d45f0ybuK3BlpU5ajiYLPoQlcvnrM0uo /HJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727431172; x=1728035972; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=/wFHvQrnJe6+I0Hk404NsRdbI8eFHq8tb62kLJdsI/o=; b=VY14VAeHtrUE7TWFHPuAORXAnkAtAfzofBWj4JWfZkfj4Nb7xpEo9xcMs9zZATawci NLUopLcj4znipxxoBL/MdtMG5G8t9oEcfO9ezVdrNx4KcIFW+Xws5Xcf0ISPrcUCUNES YtvCg2kFrtEU3TOQlLSCRAh3VyoghUiTmXAlNJYYzjbDKPPgX8zsjoYho2I8t7w9CLwU BwFm8gZz2jCX7wpqYpJyNcC0ZA5dVcESMeuh4QBbeG37Zk3XkOtbAvxB24iJPhoq9nSb 9Bz4GzLMh4/QxXwNjUcG/SnEpRrM0blVkA/q1RBOn1+DLCe/CdJrYpuwddZnbHCMkrI0 huGA== X-Forwarded-Encrypted: i=1; AJvYcCV7Uo10D8E+kXWlLaxA0JucMQ7Pv5vN+TEJcBA9YjlZhs9HLloh0L6RsDBryXaNz7syI0ztIm3g8g==@kvack.org X-Gm-Message-State: AOJu0YyLGWHUJOVNvTBDRZmxZUgTr6If+GyMMmT9ZOkFqYuxbR0Hy1z+ C+00m8D8iYIsA6fFtZOzOO18DGNksgQyylnD8hJFH4vTuPhDTbWKH+Wrzlgcdlxtk7uOn0Tiu+W A7dckL7hOUP19RziACIvsJ/vEbjx46THH+VgURg== X-Google-Smtp-Source: AGHT+IFPw7TdHI7xAVBejSYDuXRNyLLxKTG1ESrzw48y3A/pOuf25zX23NWOfeE/8MxH7DAW+JoIMvACw7ATICsO3w0= X-Received: by 2002:a05:6a20:6f03:b0:1cf:23cb:b927 with SMTP id adf61e73a8af0-1d4fa7a6f8emr3754825637.34.1727431171797; Fri, 27 Sep 2024 02:59:31 -0700 (PDT) MIME-Version: 1.0 References: <20240925075707.3970187-1-linyunsheng@huawei.com> <20240925075707.3970187-3-linyunsheng@huawei.com> <842c8cc6-f716-437a-bc98-70bc26d6fd38@huawei.com> <0ef315df-e8e9-41e8-9ba8-dcb69492c616@huawei.com> In-Reply-To: <0ef315df-e8e9-41e8-9ba8-dcb69492c616@huawei.com> From: Ilias Apalodimas Date: Fri, 27 Sep 2024 12:58:55 +0300 Message-ID: Subject: Re: [PATCH net v2 2/2] page_pool: fix IOMMU crash when driver has already unbound To: Yunsheng Lin Cc: Mina Almasry , davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, liuyonglong@huawei.com, fanghaiqing@huawei.com, zhangkun09@huawei.com, 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 , imx@lists.linux.dev, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, intel-wired-lan@lists.osuosl.org, bpf@vger.kernel.org, linux-rdma@vger.kernel.org, linux-wireless@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-mm@kvack.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 3182F12000F X-Stat-Signature: 45ko9te6hirxa6uftrt8u4oj3bm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kKZC3u2FA9uCtLuBSZKsvPIZqvjGWpOO9QKG7hozDqtoJAXdyQ5Tv6vo1RUC6LG6mOhXeexVpT4NiGaSE4sIPcpbRtsde1EWxDdGOSjh9mwXPSpTOXMQPoXEmgbas4gEYfUlD+oPHOzcnAvtkxPslIRims2hrjRm/YHCTT/pXWzZBn3XUN9Z8Tp9jwqC30wUZ34PpEG4u95el8/vJ83ir9ZSaq/GUe0EehwDaayhs8FXbqtChWW4oxB0uXx+6um0W1lUOs7oYhomeDqMvMDPFWBOOebkY2l9eK7A9uViKH7atGiyFolbZZG5lIdTGp/ZAgb+EF5E/bHnLgZcrjBeJZqqzCZZFRBk5/Ge9/k= 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 Fri, 27 Sept 2024 at 12:50, Yunsheng Lin wrote: > > 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. > Ah good point, I just grepped for it and didn't look at the surrounding unions. > 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. Yes, but do you think that keeping that list of allocated pages in struct page_pool will end up being more costly somehow compared to struct page? Thanks /Ilias