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 2E7DCC369BA for ; Wed, 16 Apr 2025 16:02:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 869776B02A6; Wed, 16 Apr 2025 12:02:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7F30B6B02A7; Wed, 16 Apr 2025 12:02:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6934C6B02A8; Wed, 16 Apr 2025 12:02:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 474066B02A6 for ; Wed, 16 Apr 2025 12:02:18 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id A75CD5BCD6 for ; Wed, 16 Apr 2025 16:02:18 +0000 (UTC) X-FDA: 83340373956.03.7F96419 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) by imf24.hostedemail.com (Postfix) with ESMTP id BB90718000F for ; Wed, 16 Apr 2025 16:02:16 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=bc3wj84k; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf24.hostedemail.com: domain of almasrymina@google.com designates 209.85.214.180 as permitted sender) smtp.mailfrom=almasrymina@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1744819336; a=rsa-sha256; cv=none; b=S5/6200R70NTzFdBJvMMjWmfCeiGyuX7RLgfTTvBZCHu13EWeTVeYjJkyUploXU3F8gUno rgu7+eibxvjyoXlGtYqsQQs5B+zhsz1/t8+yx36jwSY8q0jN9Z1xf3nlFPKxrBJzr8+cRw AILpJWjsSSJeEiW7+jQ3Zw4hjJuN1NQ= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=bc3wj84k; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf24.hostedemail.com: domain of almasrymina@google.com designates 209.85.214.180 as permitted sender) smtp.mailfrom=almasrymina@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1744819336; 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=jqCWfRvW8Bx8z1ILw2vfbu9SHIro4MFtgFt1NLNthqk=; b=3lu0zTMzeePQlYxdlExk7fWgwLGJauFsy/1VdUK/pEcuJ55My3svf1nhBCczWqN/sjNUfo Dje3590F3NdB6Gy4SWON0rX2AjcyuaJuKsHQavcFFRG+tHaeica+YMPvM+ph1P1UcYZSdz LsfrVJkSz8MtXZIZdjm8SXy7vR7Oqvc= Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-2242ac37caeso185505ad.1 for ; Wed, 16 Apr 2025 09:02:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1744819335; x=1745424135; 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=jqCWfRvW8Bx8z1ILw2vfbu9SHIro4MFtgFt1NLNthqk=; b=bc3wj84kqIX6cmAp9Q6Gp9UVVkD9MtdIMptTEuudYgcVI6Zed0EdInnpYPvYjWqxXs CkBXMAraYjt8KMdrfCK/FQgwAyqvTNQiR8XstB44srlx2iwZiUodSrnJtf7lcP6NibeT IgBuCWwGm1O14NH+b/YXjheXGqIiwT5FdZjZ8HT/mKEJ1qdqPZVkynprLn6BftZrHZnV je7FehS16NfBzk33KQDe5df8ws1KiL25WddjyhF6BvLjnVshQkVZlFmAUPb4d9AHpj2e 5E6rICthmxWRfVNdgHBWtqwFXVnI6eVOxU0ak+4a3AijIc5zylQTPODAAxAtG15rGxqh H7sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744819335; x=1745424135; 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=jqCWfRvW8Bx8z1ILw2vfbu9SHIro4MFtgFt1NLNthqk=; b=LueQT+w9ajwTZTTIJCVaW30X/rMGojbpNakimh33lC1NCH9ucSWQC4s+KPgGg6iXr5 UPNi/DQeV3QDUtLP5XEHXTzG8xmDLDdbo+0eeOfI2/ZYdrPe0j5bmZSPDl6MDcEU5IGX fXeKOJCJfn1Sq984JBU8g1NTd5xDTXrw+1Bxhv3IC1Mg5Uo4z279yhe+KypJtO9f+Ndo hwIVYe5Zra2BHM/no8d7aB9EyeiXpiv9wBh0DiaOwxtSE5GiQKIL2OX0bsNunvCAMLlw TrkZ6jv8czopd5AMuKFpxmlTjZR4sBF3M7Ya6mXVuEapphMoLL143Tvn59/Mf9Ap1BBt xBOQ== X-Forwarded-Encrypted: i=1; AJvYcCUma8szIYMxBDemTfiDlNr4LrYGrEZsNkj07vVh6J5agKzcP16Zxupf+toNUtC/QpP2ZT4/FDdyjQ==@kvack.org X-Gm-Message-State: AOJu0YyO21/LLOl2oaTvsChr28+bMXFoUzhnc9J0DQybbW39fUf65A56 faW8QKHnff4l5mWTisyCSiyViW6ObT1lMc5fiJ379gEjTlmepQ2YmSwQvSQ9QdB1FtOth5D+LYT fEIoDtgMumbQy/ZGH+OgCUsoLOMH0SQJpnz8s X-Gm-Gg: ASbGncvjtPXJ3rLkejlJjFBMq4sauFwbl6EtqQTZVSve6lSMHvJv9OiBCVAWrbB4Bjy 4BzPssGYGUtb6gvyj1PeRNHp0mG/f+ZOxvSS/hOl2qlwyY2sK5Tv0FD/RSxqZ2gHuGdcR3CztH4 atNVoXAHP+4eCnJnwm1XJih2E= X-Google-Smtp-Source: AGHT+IGmXnoJWXyazz6OrcQcouYZy2ZIDpRCboysaJm6EomGa8Bzpqr8J0kyO/817NzRaxUHrWJ9IrdI1Ae7sknyiqk= X-Received: by 2002:a17:903:17c3:b0:215:7ced:9d67 with SMTP id d9443c01a7336-22c355161cemr1864695ad.24.1744819335138; Wed, 16 Apr 2025 09:02:15 -0700 (PDT) MIME-Version: 1.0 References: <20250414013627.GA9161@system.software.com> <20250416052448.GB39145@system.software.com> In-Reply-To: <20250416052448.GB39145@system.software.com> From: Mina Almasry Date: Wed, 16 Apr 2025 09:02:02 -0700 X-Gm-Features: ATxdqUE8Uy9s1W0wBSH4YndYvAUuaOEDBPb9H8KtBNFdSKFp9YHFmbwrniBNsUs Message-ID: Subject: Re: [RFC] shrinking struct page (part of page pool) To: Byungchul Park Cc: Jesper Dangaard Brouer , netdev , willy@infradead.org, ilias.apalodimas@linaro.org, kernel_team@skhynix.com, 42.hyeyoo@gmail.com, linux-mm@kvack.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: BB90718000F X-Stat-Signature: rijib3gtbfc73kjjtxawtwk5iiip1u6n X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1744819336-912561 X-HE-Meta: U2FsdGVkX1+IL9o8mY5oCvHTc4oYvIhFT9witYxeD9ZqdUFiYKU3d2omeypoFmbk/p9e7gkaq9GkTHF+hJDX9I8tjdvU+MvaLvjZtGoqhgS1bf+iBCuTdkksv+XTwZCh15E9uR2iLZyrYYJjfR0vx1xZ/3z1Cl//VO5OOFNRJ5I7Jsf10kKHKgJPXiIbowMqeLlOFvau2IImYS2J7fAUXXIvqqHhfvv031cPmudGLd0r9e169K6A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5NjT+LPFmP0EgIXfAZLolE1Len9SI+fr7lJkrM3YGb608p3NH4xzzluU54Zw734T2XsRchV0/NUrHQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000390, 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 Tue, Apr 15, 2025 at 10:24=E2=80=AFPM Byungchul Park = wrote: > > On Tue, Apr 15, 2025 at 08:39:47AM -0700, Mina Almasry wrote: > > On Sun, Apr 13, 2025 at 6:36=E2=80=AFPM Byungchul Park wrote: > > > > > > Hi guys, > > > > > > I'm looking at network's page pool code to help 'shrinking struct pag= e' > > > project by Matthew Wilcox. See the following link: > > > > > > https://kernelnewbies.org/MatthewWilcox/Memdescs/Path > > > > > > My first goal is to remove fields for page pool from struct page like= : > > > > > > > Remove them, but put them where? The page above specificies "Split the > > We need to introduce a new struct that will be used as a new descriptor > e.g. bump, instead of struct page, similar to net_iov, overlaying struct > page for now. > > > pagepool bump allocator out of struct page, as has been done for, eg, > > slab and ptdesc.", but I'm not familiar what happened with slab and > > ptdesc. Are these fields moving to a different location? Or being > > Move to the newly introduced struct e.g. bump and temporarily let it > overlay struct page for now. > > > somehow removed entirely? > > And then we can remove the fields from struct page. > OK, IIUC, what you're trying to do is fairly straightforward actually. We already have struct net_iov which overlays the page_pool entries in struct page, and we use it to represent non-paged memory. You can create struct bump which overlays the page_pool entries in struct page (just like net_iov does), and modify all the places in the net stack and page_pool where we query these entries to query the entries from the struct bump instead of from the struct page. > > > 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; > > > }; > > > > > > Fortunately, many prerequisite works have been done by Mina but I gue= ss > > > he or she has done it for other purpose than 'shrinking struct page'. > > > > > > > Yeah, we did it to support non-page memory in the net stack, which is > > quite orthogonal to what you're trying to do AFAICT so far. Looks like > > maybe some implementation details are shared by luck? > > Oh. > > > > I'd like to just finalize the work so that the fields above can be > > > removed from struct page. However, I need to resolve a curiousity > > > before starting. > > > > > > Network guys already introduced a sperate strcut, struct net_iov, > > > to overlay the interesting fields. However, another separate stru= ct > > > for system memory might be also needed e.g. struct bump so that > > > struct net_iov and struct bump can be overlayed depending on the > > > source: > > > > > > struct bump { > > > unsigned long _page_flags; > > > unsigned long bump_magic; > > > struct page_pool *bump_pp; > > > unsigned long _pp_mapping_pad; > > > unsigned long dma_addr; > > > atomic_long_t bump_ref_count; > > > unsigned int _page_type; > > > atomic_t _refcount; > > > }; > > > > > > To netwrok guys, any thoughts on it? > > > > Need more details. What does struct bump represent? If it's meant to > > 'bump' comes from how page pool works. See the following link: > > https://en.wikipedia.org/wiki/Region-based_memory_management > > However, any better name suggestion from network guys should be > appreciated. > > > replace the fields used by the page_pool referenced above, then it > > should not have _page_flags, bump_ref_count should be pp_ref_count, > > and should not have _page_type or _refcount. > > These are place holders that might be needed for now but should be > removed later. > I think they need to not be added at all, rather than removed later. It makes little sense to me to have a _page_type or _refcount entries in this bump struct when the original page_pool entries in struct page don't have a _page_flags or _page_type or _refcount, but maybe I misunderstood and looking at patches would make this clearer. > > > To Willy, do I understand correctly your direction? > > > > > > Plus, it's a quite another issue but I'm curious, that is, what do yo= u > > > guys think about moving the bump allocator(=3D page pool) code from > > > network to mm? I'd like to start on the work once gathering opinion > > > from both Willy and network guys. > > > > > > > What is the terminology "bump"? Are you wanting to rename page_pool to > > "bump"? What does the new name mean? > > I hope the link above explain it. > To be honest I would drop renaming the page_pool and moving the page_pool to mm as part of your changes. Those seem to have very little benefit for what you're trying to do, and what you're doing seems straightforward enough while keeping the code in place, but that's just my 2 cents. --=20 Thanks, Mina