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 CA07AC3ABBC for ; Fri, 9 May 2025 17:32:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D66646B00C1; Fri, 9 May 2025 13:32:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D14146B00C2; Fri, 9 May 2025 13:32:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B8EF46B00C3; Fri, 9 May 2025 13:32:24 -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 9705C6B00C1 for ; Fri, 9 May 2025 13:32:24 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 81CC61402F1 for ; Fri, 9 May 2025 17:32:24 +0000 (UTC) X-FDA: 83424063408.01.F404218 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) by imf08.hostedemail.com (Postfix) with ESMTP id BFBCE160005 for ; Fri, 9 May 2025 17:32:22 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=KYewhj6r; spf=pass (imf08.hostedemail.com: domain of almasrymina@google.com designates 209.85.214.175 as permitted sender) smtp.mailfrom=almasrymina@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1746811942; 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=eksCJPPKUnzZZMnCwrQDL/i184EE28xZ4rbD/Sa6J8s=; b=VbWAFuNncCtNV9F9IY8hw5H5BpUR4TILqq1jOE/brVtJ8bM60T/wmMROFZWzQjwTTlsilI wzhedDKES1ftuD11wrwglwe6nBW0idFQsInb3jxcBOWgxc0+br/omOloDaGFNZEaBQLHUP EcOsQkC2Za8Ezs6iUQxEF5+6E19zwJw= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=KYewhj6r; spf=pass (imf08.hostedemail.com: domain of almasrymina@google.com designates 209.85.214.175 as permitted sender) smtp.mailfrom=almasrymina@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1746811942; a=rsa-sha256; cv=none; b=VIGZgvQYJTduzH8LhhczpbaY/cefzx7FQ4QOAXmxJJLxtjLLvY/ekQ3kcJ3uc3imn/1xf+ t4BwzJ8sa9OvFmr4EOQmYbsehoHS23W1E6lLj6PrjT1563zmXRteao0jJpFA/y9TrTqTBa kMvgzbFB2ch9UaV9/77iGB686Q41AJ4= Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-22fa47f295dso12165ad.1 for ; Fri, 09 May 2025 10:32:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1746811941; x=1747416741; darn=kvack.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=eksCJPPKUnzZZMnCwrQDL/i184EE28xZ4rbD/Sa6J8s=; b=KYewhj6rRfwJy7qYDqlPU39AwWclNMwMLCt3BjPUw5anzxTiw0T2jyUxdjVOkV1Aii tpeHSHymoJvaVEJKlW/jRzLLnkc+jGLyjuzlfb4cX0MODi2SvYrmbtmAyJPQyvKzGxKj k1OdlieDKQ955MXU0lQ4V2k5dRQ+se33uvebIxFMMAyNC5KNsOmFP+uFlrfftIySGqCN IhUdAHuaTSrTRD5FtMYpg+xXxaTkP7YztofehMtiSYp+dFFlG8yP37mn+KIYgfZNFsuu L5m1TgVvkxmB2rMVsJDMFpJhCHYYu+YYVmwPF3XcTyJZM9OChqcn2lF2QLPl62GkRFt0 wHsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746811941; x=1747416741; h=content-transfer-encoding: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=eksCJPPKUnzZZMnCwrQDL/i184EE28xZ4rbD/Sa6J8s=; b=IG6cZVn5OVnxS16rV33UrjYZuRutKAzgk2CQU5CkgzbD9jk7ZB4nK0gDcYSY/BL2NE VZKXY27QOeLHPqCRIBvgLdp2MDtRtnVTBz7xQhUMRQAqOt+MPhC4gapCyf9y3ak+5v6n cxCiXSRDCov3nuranAw7sWfJfBWGg6OfwoI+WbwuLtABVlw7MmEzlhEq972XbndX17sb 1FR8D/gIq+b/ZyPobQtzMdoB93vO8koEMv1Yd0QnDUU0UsaJBNss3MzLQF9240J4rgZy oPayn8QRjazPNaEXbijOUbQ9+L+uSw4fBorvc1Juu7uO02p5Ct9mzqZa6hT0RlEf3mlh hwPA== X-Forwarded-Encrypted: i=1; AJvYcCUgNSpPs3mAe0Tg0Cv5fS9ag85TAs494fOCVmVP4u0NLK7Vn/q6jZ7pFeNJVtZ980udjg6cSt1GXw==@kvack.org X-Gm-Message-State: AOJu0YwOZTzD5HYkwNIdJk8LdCnrsDVYbiK0Uos6ZLIJNNTkFijjoDfu yJnAwGvLf98lDyNMRWm0Kl7D/8xoB0LCW52Z5EwpOBnLa+AMy6hQwYMpi/qQiRQl1woHAhms8jV yaBChV8htm0osgEl+5DP+qwFWZB49VBpT5Jyu X-Gm-Gg: ASbGncvvPzNtFyGRP7kU4OHhMslrSvnS13JA1vOVJz9RxHmss6f82l50iI+PVDDS6Gp FddprMB2Vj370oo2YO9CTw7kZm0yKij/WAYXBKG3TC0HOc4IJ47RLsnwnL8O3/LrVdoJWcT5PUQ Jlo8nCmIYEIv/vq/X6IWpmQtZVuJy2Hax46fvxbREVcmnMDmkqoPiA X-Google-Smtp-Source: AGHT+IFj0TndIRh/lZTWlpbLPDcfoUAdbzU63ncHeXdLshLF4cedqgULo3qSXEtwteAKMmWMtY8DXC8psezDG8cJFVo= X-Received: by 2002:a17:903:4403:b0:216:21cb:2e14 with SMTP id d9443c01a7336-22fcfa67bbdmr2405535ad.21.1746811941138; Fri, 09 May 2025 10:32:21 -0700 (PDT) MIME-Version: 1.0 References: <20250509115126.63190-1-byungchul@sk.com> <20250509115126.63190-20-byungchul@sk.com> In-Reply-To: <20250509115126.63190-20-byungchul@sk.com> From: Mina Almasry Date: Fri, 9 May 2025 10:32:08 -0700 X-Gm-Features: ATxdqUGI6dEeIG5BsTRWq0lynejMc_q6rYi0sEc0AnPpkdnHxpWvN7YcbLR7W5c Message-ID: Subject: Re: [RFC 19/19] mm, netmem: remove the page pool members in struct page To: Byungchul Park Cc: willy@infradead.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, kernel_team@skhynix.com, kuba@kernel.org, ilias.apalodimas@linaro.org, harry.yoo@oracle.com, hawk@kernel.org, akpm@linux-foundation.org, ast@kernel.org, daniel@iogearbox.net, davem@davemloft.net, john.fastabend@gmail.com, andrew+netdev@lunn.ch, edumazet@google.com, pabeni@redhat.com, vishal.moola@gmail.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Stat-Signature: ep4ia4p4sjjfx9e1m8sd1jw8q6fkns1p X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: BFBCE160005 X-Rspam-User: X-HE-Tag: 1746811942-983474 X-HE-Meta: U2FsdGVkX19Owr6Jfy+923JobP7bc/ZfEM9ZzPOAvnET0VmLR78R2Vogolb0SBjrnKmp8X/PtVKDqQzOfKEGz648s2bWoxmcQbu9VsgScbOvahvAxPUMfmEd1W3ErmPq8HXkjdPTRAw1/lCeUczuhsAjEDA5PjqTSvK+C37YCM/6JbHbR6wOaaX1HDZXc3rOFRUFNnqUrCLI7+zpT5ewXBg29V8mg4+kDNj/ic/hD1x8yjyrPn0Rb51BC1JxSzKk7CqvCbKkwVKsoOioUQDQ7AqOfDS5V0RHK4yac/bXYF8wjoUu7xJkgBpVwRgDRSUX/QV38sW+E0YzATct/WuJ9sBpRdIFuvYq1pKxpxvYN9P8AXPKAiZrZQAY2WbygfQa1ekTSPmUkmtwo1IFTJGyCoJLYdP1V028aWVilbfkIs4i9f3raiSw/vAsSeEHpg9aOWUUQz2AW9T1vrYQ/cL80IZUQbBVzHiYL59GqXrRtBECqanROQUyuT+ZW+NRSWoueCo0MYQroNiCOY2COdY+k7w6qpXfJy/4Hx4ZZO7G+ufaEm8+awNHWBUFlvreWtV9mT32Sh4WZK+JAf6bXMLG42LjuiQm+nrcHtxy95lEpvbLy83RB+UzSC+v4lram8Ajk//q/jCPvW6tCum9VmwMzSEhlouF47myVE2alfuJ2Qls9PCJ3NWpNrxzgUdIqpWJahzWWkdXs3zXTJxyYMkg3NtbS7ac81I2Y2wAj3ZNroZQWJFnA5A/lCRVuZ72dMwHO9b1qoE1Yb6tkhsQNVFoZMKeFGs20absjXxwrPx+NaEDc4D5TsGdIPVAxCE9JsPxvLQ+ySS8i0hqdsqheAM7us6tQJEFRtiovgR511HP0VmkaO/weiPVCofJyUMH2SzsTCQmsjX69uB5WA/6EAjVAZFQrZeYYHmLZY+LaIzjISsVZuqHohv+AmHyHO7EgRSakdrFEPrBB1LSmuVc4ff 1R5dZ3nh 5rMsBB8UY+rkJTq8= 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, May 9, 2025 at 4:51=E2=80=AFAM Byungchul Park wr= ote: > > Now that all the users of the page pool members in struct page have been > gone, the members can be removed from struct page. However, the space > in struct page needs to be kept using a place holder with the same size, > until struct netmem_desc has its own instance, not overlayed onto struct > page, to avoid conficting with other members within struct page. > > Remove the page pool members in struct page and replace with a place > holder. The place holder should be removed once struct netmem_desc has > its own instance. > > Signed-off-by: Byungchul Park > --- > include/linux/mm_types.h | 13 ++----------- > include/net/netmem.h | 35 +---------------------------------- > include/net/netmem_type.h | 22 ++++++++++++++++++++++ > 3 files changed, 25 insertions(+), 45 deletions(-) > create mode 100644 include/net/netmem_type.h > > diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h > index e76bade9ebb12..69904a0855358 100644 > --- a/include/linux/mm_types.h > +++ b/include/linux/mm_types.h > @@ -20,6 +20,7 @@ > #include > #include > #include > +#include /* for page pool */ > > #include > > @@ -118,17 +119,7 @@ struct page { > */ > unsigned long private; > }; > - struct { /* page_pool used by netstack */ > - /** > - * @pp_magic: magic value to avoid recycling non > - * page_pool allocated pages. > - */ > - unsigned long pp_magic; > - struct page_pool *pp; > - unsigned long _pp_mapping_pad; > - unsigned long dma_addr; > - atomic_long_t pp_ref_count; > - }; > + struct __netmem_desc place_holder_1; /* for page pool */ > struct { /* Tail pages of compound page */ > unsigned long compound_head; /* Bit zero is se= t */ > }; > diff --git a/include/net/netmem.h b/include/net/netmem.h > index 00064e766b889..c414de6c6ab0d 100644 > --- a/include/net/netmem.h > +++ b/include/net/netmem.h > @@ -10,6 +10,7 @@ > > #include > #include > +#include > > /* net_iov */ > > @@ -20,15 +21,6 @@ DECLARE_STATIC_KEY_FALSE(page_pool_mem_providers); > */ > #define NET_IOV 0x01UL > > -struct netmem_desc { > - unsigned long __unused_padding; > - unsigned long pp_magic; > - struct page_pool *pp; > - struct net_iov_area *owner; > - unsigned long dma_addr; > - atomic_long_t pp_ref_count; > -}; > - > struct net_iov_area { > /* Array of net_iovs for this area. */ > struct netmem_desc *niovs; > @@ -38,31 +30,6 @@ struct net_iov_area { > unsigned long base_virtual; > }; > > -/* These fields in struct page are used by the page_pool and net stack: > - * > - * struct { > - * unsigned long pp_magic; > - * struct page_pool *pp; > - * unsigned long _pp_mapping_pad; > - * unsigned long dma_addr; > - * atomic_long_t pp_ref_count; > - * }; > - * > - * We mirror the page_pool fields here so the page_pool can access these= fields > - * without worrying whether the underlying fields belong to a page or ne= t_iov. > - * > - * The non-net stack fields of struct page are private to the mm stack a= nd must > - * never be mirrored to net_iov. > - */ > -#define NET_IOV_ASSERT_OFFSET(pg, iov) \ > - static_assert(offsetof(struct page, pg) =3D=3D \ > - offsetof(struct netmem_desc, iov)) > -NET_IOV_ASSERT_OFFSET(pp_magic, pp_magic); > -NET_IOV_ASSERT_OFFSET(pp, pp); > -NET_IOV_ASSERT_OFFSET(dma_addr, dma_addr); > -NET_IOV_ASSERT_OFFSET(pp_ref_count, pp_ref_count); > -#undef NET_IOV_ASSERT_OFFSET > - > static inline struct net_iov_area *net_iov_owner(const struct netmem_des= c *niov) > { > return niov->owner; > diff --git a/include/net/netmem_type.h b/include/net/netmem_type.h > new file mode 100644 > index 0000000000000..6a3ac8e908515 > --- /dev/null > +++ b/include/net/netmem_type.h > @@ -0,0 +1,22 @@ > +/* SPDX-License-Identifier: GPL-2.0 > + * > + * Author: Byungchul Park > + */ > + > +#ifndef _NET_NETMEM_TYPE_H > +#define _NET_NETMEM_TYPE_H > + > +#include > + > +struct netmem_desc { > + unsigned long __unused_padding; > + struct_group_tagged(__netmem_desc, actual_data, > + unsigned long pp_magic; > + struct page_pool *pp; > + struct net_iov_area *owner; > + unsigned long dma_addr; > + atomic_long_t pp_ref_count; > + ); > +}; > + > +#endif /* _NET_NETMEM_TYPE_H */ > -- > 2.17.1 > Currently the only restriction on net_iov is that some of its fields need to be cache aligned with some of the fields of struct page, but there is no restriction on new fields added to net_iov. We already have fields in net_iov that have nothing to do with struct page and shouldn't be part of struct page. Like net_iov_area *owner. I don't think net_iov_area should be part of struct page and I don't think we should add restrictions of net_iov. What I would suggest here is, roughly: 1. Add a new struct: struct netmem_desc { unsigned long pp_magic; struct page_pool *pp; unsigned long _pp_mapping_pad; unsigned long dma_addr; atomic_long_t pp_ref_count; }; 2. Then update struct page to include this entry instead of the definitions= : struct page { ... struct netmem_desc place_holder_1; /* for page pool */ ... } 3. And update struct net_iov to also include netmem_desc: struct net_iov { struct netmem_desc desc; struct net_iov_area *owner; /* More net_iov specific fields in the future */ }; And drop patch 1 which does a rename. Essentially netmem_desc can be an encapsulation of the shared fields between struct page and struct net_iov. --=20 Thanks, Mina