From patchwork Mon Nov 13 13:00:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yunsheng Lin X-Patchwork-Id: 164463 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp1182606vqg; Mon, 13 Nov 2023 05:01:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IHs4cw0kndUVeVbpQ5YaK244AzsMqnIp0SOTWg5JnJ1KcTkxK0Ww+Xxl0sz5GBCHYHEUyMt X-Received: by 2002:a9d:7e91:0:b0:6bf:1e78:cc52 with SMTP id m17-20020a9d7e91000000b006bf1e78cc52mr7843506otp.25.1699880496641; Mon, 13 Nov 2023 05:01:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699880496; cv=none; d=google.com; s=arc-20160816; b=BqQRwXTtlXCDloAC4D/E2Jd79pNeMtEGIGi6GgcHOaGg3hvPkn9alLJR/+75lnpMQm D2SjPpWj+RXqeUdPHEAhDewm4wSD9kweiYMXuUnR9+q3lWWz6E364pVVK/1fwOb3E2QA eAUb0kt9eLW3A9emuak+iaz66R4ZfeQJ5jgxwTqogwhEe4i/iAbZ3Yr+66wHFWN/t/Ly 92WZqWST0MMb87sr/Vr3Eak2XnHwe/ddlkWE5rFUhi0SDXS7rRQJWiGl7ySqgPQxmsKn FHb3+pyVpJquHdblDgV2ihWeA28JvMP4zH3MKfyOfhyZcnxhen+WwZm2HbMuBLaKhRBh YoCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=y58kFmZpX3EILqiR8ZBPIVJUozNKi9peP7z59HEirw4=; fh=cURveIlAsDWLrnfJFZhNYW9+lOK4hKD2b5uY2n7BOnU=; b=W/dFS2iHXQwNUSdzVRKB6QO0TiPTCxshwgtmuQlXsKHoBg2XxY+7RRBzwN/+bK9r3n vkpYTaADsWVlHz7A9VCMRKYNsCj79Bx+bUngg+0dsRCnNoLYMAxTwLKC0C9Erv0LZEo0 17GcrQe0q20TU/rUtRzEDmHNEip58bsSs48rgv6nOJVd1mbvIncpQrUIlB7RInU/714J rmGpCGNIBlndl4R2u/yH41KwTKCfHOzkeB/3tZ7LPiQhoCoZWRY5h1hs9Q8xECIB64R/ HzZwWlv1jc/sHz/RwzaivN8ktJeF5uIjOsoaSpT0CpZsXZjcSHNnq9pmO8/JEUTkxrMr faiA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id d17-20020a056830045100b006ce2a47bc3asi1779100otc.351.2023.11.13.05.01.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Nov 2023 05:01:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id B8DCF805743D; Mon, 13 Nov 2023 05:01:29 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231200AbjKMNAs (ORCPT + 29 others); Mon, 13 Nov 2023 08:00:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47628 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230502AbjKMNAl (ORCPT ); Mon, 13 Nov 2023 08:00:41 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 917E419B5; Mon, 13 Nov 2023 05:00:33 -0800 (PST) Received: from dggpemm500005.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4STTzv4QsTzWhJn; Mon, 13 Nov 2023 21:00:11 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by dggpemm500005.china.huawei.com (7.185.36.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Mon, 13 Nov 2023 21:00:31 +0800 From: Yunsheng Lin To: , , CC: , , Mina Almasry , Jesper Dangaard Brouer , Ilias Apalodimas , Eric Dumazet Subject: [PATCH RFC 1/8] net: page_pool: factor out releasing DMA from releasing the page Date: Mon, 13 Nov 2023 21:00:33 +0800 Message-ID: <20231113130041.58124-2-linyunsheng@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20231113130041.58124-1-linyunsheng@huawei.com> References: <20231113130041.58124-1-linyunsheng@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm500005.china.huawei.com (7.185.36.74) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Mon, 13 Nov 2023 05:01:29 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782453891541625107 X-GMAIL-MSGID: 1782453891541625107 From: Jakub Kicinski Releasing the DMA mapping will be useful for other types of pages, so factor it out. Make sure compiler inlines it, to avoid any regressions. Signed-off-by: Jakub Kicinski Signed-off-by: Mina Almasry --- net/core/page_pool.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/net/core/page_pool.c b/net/core/page_pool.c index 5e409b98aba0..578b6f2eeb46 100644 --- a/net/core/page_pool.c +++ b/net/core/page_pool.c @@ -514,21 +514,16 @@ static s32 page_pool_inflight(struct page_pool *pool) return inflight; } -/* Disconnects a page (from a page_pool). API users can have a need - * to disconnect a page (from a page_pool), to allow it to be used as - * a regular page (that will eventually be returned to the normal - * page-allocator via put_page). - */ -static void page_pool_return_page(struct page_pool *pool, struct page *page) +static __always_inline +void __page_pool_release_page_dma(struct page_pool *pool, struct page *page) { dma_addr_t dma; - int count; if (!(pool->p.flags & PP_FLAG_DMA_MAP)) /* Always account for inflight pages, even if we didn't * map them */ - goto skip_dma_unmap; + return; dma = page_pool_get_dma_addr(page); @@ -537,7 +532,19 @@ static void page_pool_return_page(struct page_pool *pool, struct page *page) PAGE_SIZE << pool->p.order, pool->p.dma_dir, DMA_ATTR_SKIP_CPU_SYNC | DMA_ATTR_WEAK_ORDERING); page_pool_set_dma_addr(page, 0); -skip_dma_unmap: +} + +/* Disconnects a page (from a page_pool). API users can have a need + * to disconnect a page (from a page_pool), to allow it to be used as + * a regular page (that will eventually be returned to the normal + * page-allocator via put_page). + */ +void page_pool_return_page(struct page_pool *pool, struct page *page) +{ + int count; + + __page_pool_release_page_dma(pool, page); + page_pool_clear_pp_info(page); /* This may be the last page returned, releasing the pool, so