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 0030EC27C79 for ; Mon, 17 Jun 2024 17:52:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8570F6B025F; Mon, 17 Jun 2024 13:52:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8076D6B0260; Mon, 17 Jun 2024 13:52:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 680BC6B0261; Mon, 17 Jun 2024 13:52:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 45B096B025F for ; Mon, 17 Jun 2024 13:52:58 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id D53251C3339 for ; Mon, 17 Jun 2024 17:52:57 +0000 (UTC) X-FDA: 82241126394.08.6C20397 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) by imf24.hostedemail.com (Postfix) with ESMTP id D13DA180007 for ; Mon, 17 Jun 2024 17:52:55 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=c1HBr6jY; spf=pass (imf24.hostedemail.com: domain of asml.silence@gmail.com designates 209.85.221.43 as permitted sender) smtp.mailfrom=asml.silence@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718646771; 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=TpAELCdjsBD+JrbERWD7mTd4OMlGherBa7u+JgUwCuU=; b=u322idGkQl7gAMD72dz5EyUYvwn5PuiuNiFXNVVCrZf+RvP0ErW8pHnaS111gloDYg/6UJ 4/vOiWLxkOk++sjxgL1uNJTqc1xJwpn1MvlhVsZmi2W1c2NSXJO66K2U/oAnTnvzXDhpgs /3S1FZI2ovXAPTCUpiMBOJgRcVPhpY8= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=c1HBr6jY; spf=pass (imf24.hostedemail.com: domain of asml.silence@gmail.com designates 209.85.221.43 as permitted sender) smtp.mailfrom=asml.silence@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718646771; a=rsa-sha256; cv=none; b=AdFAss7dDFUo9HwLCf2odi5W0ipzO73QAODZAEQ+na5zu7ltk3DaW3gy5wBla+kNfkN6wd Pqz0xoBqp3eTgkr7TFP0Fwlqxl43yZlG7ooXCq8El2DuNOc7nd44+QLxp9T/GOPjyLrWOs 7vaEvxGwV25kIbryB0gKazR9pexUFbw= Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-35f22d3abf1so4200230f8f.1 for ; Mon, 17 Jun 2024 10:52:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718646774; x=1719251574; darn=kvack.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=TpAELCdjsBD+JrbERWD7mTd4OMlGherBa7u+JgUwCuU=; b=c1HBr6jYnlsXNt0KBr7pt9nxmxw9zq2JeeCPJM6cg8aB0q/F1UNIRbg3WlYuy7J5PV pneKF2Ta+1EpQ4zFndFtDka+B4nMEHD7tfhSkmMkHcb7O3pZL8Vak0QdZv3pEiWfHXmi fOmFJbfOmj4RWYpm4grz3kixP4oGzo55FnTxUnpbr6FPZEHAf6ivKujdlctDoYK+Qqvm WlbOTLPXocsMEWFBK86DNLSQtYxZ6EYrf8hZ91iALBr8/64WPl7g+2n8By67gzEMulQi ZkAVdWpXBkmSCe+2P8CBvO5/ZhMY1ozVpc6XN6b1N27KJJ/McubpWfDGa7qOcTRdopfQ 4lKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718646774; x=1719251574; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=TpAELCdjsBD+JrbERWD7mTd4OMlGherBa7u+JgUwCuU=; b=CWbc6c0I7lzqJoqO67O4FE2NhWCcYwPWotq0iRb/DXvRwVY0qzpEUMeIHiwWSxIw+y VgRBuhmX9EFFCqzimoNxZGyU8MCrPkdx3d+2hFOk4WOnVL9Ft9VuH03L1BxNT0skVDrU hfmk919QpgjGG0gOKFejm1z9NvVx+owa1kEo6tw8nwk+qI4qCYzrY1nzDjlDQT15oCw3 G1lx8979MfBevi0y3kyLNEO5o/O7tB8E2iF7KnuOPuKU0+iy4PxXT8PZte7fnLGT511i z9keBSIe+j3Vvs7tHReUQR59CJXkAcH6oibNAu9C/iHHsO3d8X7zfiJ8BBJm5hN7e83b o/BA== X-Forwarded-Encrypted: i=1; AJvYcCUKZh+SCUpfIlF0TA/jGE59bsE+hkygd8WulYbx1AD2EO77oSwdFirsIu02WFLidHKrKiuCZfb3cZlBBpOYstHtTMA= X-Gm-Message-State: AOJu0Ywdt40Sbpt8zlCisszhzHzbuaQzWcnPc6kHj6FTL+XPyFCxen2G NFam2IA5s4nyL58S8JEreHIbgy0EKRwAPTQIkd2MeSDiRP1eg46Z X-Google-Smtp-Source: AGHT+IGl45hl8z5GTV7cP0mMya2j77Ernk+fngMh6lTe4ik8n3cM/4R8lGNxKRhI8iXovlNIXIeAXQ== X-Received: by 2002:adf:efc9:0:b0:35f:219d:e529 with SMTP id ffacd0b85a97d-3607a78338cmr10492439f8f.47.1718646774132; Mon, 17 Jun 2024 10:52:54 -0700 (PDT) Received: from [192.168.42.223] ([163.114.131.193]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6f56ecdce5sm531595666b.108.2024.06.17.10.52.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 17 Jun 2024 10:52:53 -0700 (PDT) Message-ID: Date: Mon, 17 Jun 2024 18:52:54 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net-next v12 05/13] page_pool: convert to use netmem To: Mina Almasry , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-alpha@vger.kernel.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, sparclinux@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-arch@vger.kernel.org, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Donald Hunter , Jonathan Corbet , Richard Henderson , Ivan Kokshaysky , Matt Turner , Thomas Bogendoerfer , "James E.J. Bottomley" , Helge Deller , Andreas Larsson , Sergey Shtylyov , Jesper Dangaard Brouer , Ilias Apalodimas , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Arnd Bergmann , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Steffen Klassert , Herbert Xu , David Ahern , Willem de Bruijn , Shuah Khan , Sumit Semwal , =?UTF-8?Q?Christian_K=C3=B6nig?= , Bagas Sanjaya , Christoph Hellwig , Nikolay Aleksandrov , David Wei , Jason Gunthorpe , Yunsheng Lin , Shailend Chand , Harshitha Ramamurthy , Shakeel Butt , Jeroen de Borst , Praveen Kaligineedi , linux-mm@kvack.org, Matthew Wilcox References: <20240613013557.1169171-1-almasrymina@google.com> <20240613013557.1169171-6-almasrymina@google.com> Content-Language: en-US From: Pavel Begunkov In-Reply-To: <20240613013557.1169171-6-almasrymina@google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Stat-Signature: 8k6efp65kiqc61k1kpbad37pcqjcohrm X-Rspam-User: X-Rspamd-Queue-Id: D13DA180007 X-Rspamd-Server: rspam02 X-HE-Tag: 1718646775-866512 X-HE-Meta: U2FsdGVkX18o4QP0xLjS+1VCfFSEBzrlSOp7/aKxRc+p3we0U1LP3KIrhG0sWZbBvy0JCJOLCBRaTxz6Q8zOFMkmig7C3pvt3yMnwePYg4pJO7aRm5IMnM1UBw3SXFFh7ip6VoktSXClDE4ujEa9cWgZmzURf7jnuhwOQbnz2LdoQokXFO3m2LRrt0tVCEeyVFc1Co6UTK0HqtBdKjud4FT6QSUiQOxig+1ZKbLq69rcZOI7yGeFMTmgmGri1q7hUr4GeC3LcxGskqqzGuGKEn0l3P/9FJDtUkw6iyMj/WqSNIvcHRgbsnZoEqW9bxYQqjIkwANgRu+JEI2mguNMnZ40EGy6r03A/S+YW9m2y58r+mRM9nkqaA7pPuRxKw5gqMZpXGVWyACQv5dtzM0r8SdSaEBJGkHo7StC8HEKjiOULVT1VNBAOa9F8AM5T0/5LqmkyC2gfP6cED4c8bc7RcUuNHFlIjf6YMy379sz8wVsGJtuiXtywkw9ApOKaYK5K99PNYQND7OKEk6UM03YLk74SMdMftt5gSy/+n34ccUfIBRv0suoqxzGOnKPfKpPgq76iGuV/v6nscKQmdCeqn7BpdMZuOTFBCRaoPZuuDn6ErdXlrzO3goK1ckLP05bKjYw68R++L3a99J6gl5cTsYhTaycDPFtIl1Swj/oO1Uo9iJiSXyDo2gQBqX6FQc8x6W+8g2u50KfBs7OhjHf9UyoV6KolS89pe552HwpEn9HhVb7nsTKOApdB4ZTOWGhB99LM03iG3h2TXA7ck3UkHHbLVsBY4ZP8roSS8gqmYlPIRIs6OXOJ7mggP9jrku/PyprcN1xo3KQnP7B8PWXzb48/YYJaRZuWhEAUhb9StivMHCJuVxS1+kmAwutwxNX4RPsPlqAv3qfENNuslHgHGgwAovNoqrqXHDqz/a9lzlQgk5eq+qH/sIFfYzDvxcqPRw8rZk5p8fPv20pGvu jlqdrs0t ylW2fBTCSVRQmdfKvCExQwN6VoDraAWSuMfIW2uhaStJEyynoq34hsMdJq/wmqCYRmIUr3N7jOnIXstq9V2Ui8DlJ4xJyp0t4yo/wPQWBVX6lgwxmICTzJPf/TQPjAicNXA7ccGO1YXbPOFwqO8w+iRDhH/kqKcKcKtzyk/lNZS5wP9yi1BM9HkIiDsnMnoeeKtliqr35HPePZ8zfNQSkqbrffmsnxxyOkIZsnfINh0u1Sh/HF/C3yeAf7jW2Vn/DLlO8a65PiIV39vlbEhbp3Maa5FYdTc3mo2q2+bbx10vgIDtQ1a6c7le5rJFe+GEU4tfqE8L2xpxoIPw6kNek0i2DnPg6fDfVR+kOzW+sBPOSms3/l3l9DahAKNeqZLQOWQHjGlzi9SoF4+mJuyZjPwzK3KLKJf0LjcAWNF46xhjcNki+Om1zNcsORw0Mu4UrSoNmT8UdK64aPi11zT9ATcOfIbnmi9Rj01p/o7+a+qHahrqyooChmsrm8sI97SBXp8pDCeAndZMjtemLX601LDRlK1CREamKVh8J+AZVJWa1YFFtet8UurVK+/K412jb0eavObV9JsS/v1H8j9NGwXtn3ePH2gJSb9U0K7CC70wOieg= 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 6/13/24 02:35, Mina Almasry wrote: > Abstrace the memory type from the page_pool so we can later add support > for new memory types. Convert the page_pool to use the new netmem type > abstraction, rather than use struct page directly. > > As of this patch the netmem type is a no-op abstraction: it's always a > struct page underneath. All the page pool internals are converted to > use struct netmem instead of struct page, and the page pool now exports > 2 APIs: > > 1. The existing struct page API. > 2. The new struct netmem API. nits below, Reviewed-by: Pavel Begunkov > Keeping the existing API is transitional; we do not want to refactor all > the current drivers using the page pool at once. > > The netmem abstraction is currently a no-op. The page_pool uses > page_to_netmem() to convert allocated pages to netmem, and uses > netmem_to_page() to convert the netmem back to pages to pass to mm APIs, > > Follow up patches to this series add non-paged netmem support to the > page_pool. This change is factored out on its own to limit the code > churn to this 1 patch, for ease of code review. > > Signed-off-by: Mina Almasry > #endif /* _NET_NETMEM_H */ > diff --git a/include/net/page_pool/helpers.h b/include/net/page_pool/helpers.h > index 873631c79ab16..5e129d5304f53 100644 > --- a/include/net/page_pool/helpers.h > +++ b/include/net/page_pool/helpers.h > @@ -55,6 +55,8 @@ > #include > > #include > +#include > +#include > > #ifdef CONFIG_PAGE_POOL_STATS > /* Deprecated driver-facing API, use netlink instead */ > @@ -103,7 +105,7 @@ static inline struct page *page_pool_dev_alloc_pages(struct page_pool *pool) > * Get a page fragment from the page allocator or page_pool caches. > * > * Return: > - * Return allocated page fragment, otherwise return NULL. > + * Return allocated page fragment, otherwise return 0. It's a page_pool_dev_alloc_frag()'s comment, and the function still returns a pointer. ... > static inline void *page_pool_alloc_va(struct page_pool *pool, > @@ -172,7 +174,8 @@ static inline void *page_pool_alloc_va(struct page_pool *pool, > struct page *page; > > /* Mask off __GFP_HIGHMEM to ensure we can use page_address() */ > - page = page_pool_alloc(pool, &offset, size, gfp & ~__GFP_HIGHMEM); > + page = netmem_to_page( > + page_pool_alloc(pool, &offset, size, gfp & ~__GFP_HIGHMEM)); > if (unlikely(!page)) > return NULL; > > @@ -189,7 +192,7 @@ static inline void *page_pool_alloc_va(struct page_pool *pool, > * it returns va of the allocated page or page fragment. > * > * Return: > - * Return the va for the allocated page or page fragment, otherwise return NULL. > + * Return the va for the allocated page or page fragment, otherwise return 0. ditto > */ > static inline void *page_pool_dev_alloc_va(struct page_pool *pool, > unsigned int *size) > @@ -212,6 +215,11 @@ page_pool_get_dma_dir(const struct page_pool *pool) > return pool->p.dma_dir; > } > > +static inline void page_pool_fragment_netmem(netmem_ref netmem, long nr) > +{ > + atomic_long_set(&netmem_to_page(netmem)->pp_ref_count, nr); > +} ... -- Pavel Begunkov