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 E0C18C54FB3 for ; Mon, 26 May 2025 09:54:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 671876B0088; Mon, 26 May 2025 05:54:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5FAE46B008A; Mon, 26 May 2025 05:54:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4C2DE6B008C; Mon, 26 May 2025 05:54:42 -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 2B8D46B0088 for ; Mon, 26 May 2025 05:54:42 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id ACCF41206D3 for ; Mon, 26 May 2025 09:54:41 +0000 (UTC) X-FDA: 83484599562.19.ACC948B Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf21.hostedemail.com (Postfix) with ESMTP id 5FDC81C0007 for ; Mon, 26 May 2025 09:54:39 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=iPdzkATJ; spf=pass (imf21.hostedemail.com: domain of toke@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=toke@redhat.com; dmarc=pass (policy=quarantine) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1748253279; 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=vFPFRS/pNh9aaMGu0qxVimtT8rwg3b+yoUjFzFdx4GU=; b=gzRr/BGConH2GuqMbXdZFPba9IVIjYXuV9CbxqiBPmIa815McUAh3+hHpcSMG+P4Sdg5D0 GUdrICDOk7AwEOIsatGGcO7GSa8VMZkeHX64an1iZaVPNTL9VfIyHUsKnLb7q9dFXRs3QD hLXTzLdMyV/0PqWxAFmzo7TPnSHix8Y= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1748253279; a=rsa-sha256; cv=none; b=I91kwLXTNt6G9BAMhRqOeoQ9CgUl8m9cEsvrnl2rOEeEXPLQt9wri/yY7fSTPtedIqB2wv TYYO2uFnGmyXdpx0LLJfWnmLumv6mlX4ijtZvj3inNFHaGRYIl/S53vGHyaU/5jGJsVgFH BhEzokrHFg/JYwL191UmEvoEFok0nOs= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=iPdzkATJ; spf=pass (imf21.hostedemail.com: domain of toke@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=toke@redhat.com; dmarc=pass (policy=quarantine) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1748253278; h=from:from: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; bh=vFPFRS/pNh9aaMGu0qxVimtT8rwg3b+yoUjFzFdx4GU=; b=iPdzkATJibT7q0P9198CvUpsB6SugoikurIX8INyzoUVsq4kKLM8arfjxl9mn70ul7mKYa erbdiomk3XMYddJsDzwemai+2OAajqe1l3wLVntJSx6QcU3BW5tzfdM82wMkRU9xvDxFD3 whQW7ZV7RgbgaDMVty9/pUpUDlO0B4Y= Received: from mail-lf1-f69.google.com (mail-lf1-f69.google.com [209.85.167.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-594-XcJbaX4XNUqvt52mH1l-hg-1; Mon, 26 May 2025 05:54:37 -0400 X-MC-Unique: XcJbaX4XNUqvt52mH1l-hg-1 X-Mimecast-MFC-AGG-ID: XcJbaX4XNUqvt52mH1l-hg_1748253276 Received: by mail-lf1-f69.google.com with SMTP id 2adb3069b0e04-5520a19daaeso942154e87.3 for ; Mon, 26 May 2025 02:54:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748253276; x=1748858076; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rbkf5SXMEt07fFLjzJMCpshPrtgBoRho3TpNiZRvX78=; b=WV/0r8Xjt8iMRH+qtbkF29kmWfUne4iREKKFpMgynyUpQil5JIEdY82wmnesrnuMmx jNigrZk1+Fei22CJCtIWba7NXOu/WNsCWUtX/zHSA+FhDmGynlTxu0xKNCSZdK7mOCJt AFrl07lJVpPB4qsHVV+c2C+5Qo8V/V+4kOvc6L9Ejqv4X9gdvQN9IwRzk4PTRvow+Ix4 V7j/z5xKlECeHbFEmV1K0eoPdPoTJIMZkeKq9rwHRic3WMVq8VCvY/XoZ76vUgTNkV/K EHQfZ9ogXAjCCyvDCodjzm0LoXWE2Lt1tlyaRBEArSAvqyrCuLl3Z+7A4yHRmuggo5mc Lg9w== X-Forwarded-Encrypted: i=1; AJvYcCWjS9rX7EQ6PFqNH0aB1ifQPsPQ9vZrxyOe0089M0WSAipe93raQu2pKwEfs9VQfXCSUFchIJL+Pw==@kvack.org X-Gm-Message-State: AOJu0YzihK8l2fvVJB5dZF6pBwXUX1VzBI85U5LtOoGQAynYvD2anS45 K95PHxnOzLBSVAyac6Qw/YRzCXBcewlBVJbagVFlM1TyWUMxK5Ulh5sT8cbkmU6EtxwMrYVocHL pb2zjIlQkg9+oraes7CcwT+YaknUebOislLWE6xojRsrd3SpPtmu8 X-Gm-Gg: ASbGnctL6SMoq7QK1jqpF5AgtipQlOxOa4rX8F/5T6yqi94Yw50jiEKbMpSKpLbLncJ 1bg5LO5kvVAgCIFFzSU1B1bfBpRIMmdmHXFgoGgnMueJuc0x2q0gcf0lvKvA17Gv0odL07ga6o/ FBRHo2zS1cgQLxJoudor4/jmQGmPF7rjDvqv2ReRcBatz7tCIvvNBzfXgKr0IYtG9rZxgCc3kcK UASy9Ney9NNafbDPNU66tUugb0/PvbYUjsUgebEMtzzqD3Vb5tFe+Sj49Dv5qJXvNoRdhpxIiXC Q1anXl81 X-Received: by 2002:a05:6512:4150:b0:552:20e1:ee25 with SMTP id 2adb3069b0e04-55220e1ef6amr937481e87.55.1748253275968; Mon, 26 May 2025 02:54:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFkPECe1NVeXWiPUcDqM4DGhgBrZ5f5uYScFTI8314epzyCSBb2KXwKVqpiQCkibcuen2wvqA== X-Received: by 2002:a05:6512:4150:b0:552:20e1:ee25 with SMTP id 2adb3069b0e04-55220e1ef6amr937461e87.55.1748253275480; Mon, 26 May 2025 02:54:35 -0700 (PDT) Received: from alrua-x1.borgediget.toke.dk ([2a0c:4d80:42:443::2]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5532503cd79sm84170e87.207.2025.05.26.02.54.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 May 2025 02:54:34 -0700 (PDT) Received: by alrua-x1.borgediget.toke.dk (Postfix, from userid 1000) id BF6291AA3EFC; Mon, 26 May 2025 11:54:33 +0200 (CEST) From: Toke =?utf-8?Q?H=C3=B8iland-J=C3=B8rgensen?= To: Byungchul Park Cc: Mina Almasry , 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, davem@davemloft.net, john.fastabend@gmail.com, andrew+netdev@lunn.ch, asml.silence@gmail.com, tariqt@nvidia.com, edumazet@google.com, pabeni@redhat.com, saeedm@nvidia.com, leon@kernel.org, ast@kernel.org, daniel@iogearbox.net, david@redhat.com, lorenzo.stoakes@oracle.com, Liam.Howlett@oracle.com, vbabka@suse.cz, rppt@kernel.org, surenb@google.com, mhocko@suse.com, horms@kernel.org, linux-rdma@vger.kernel.org, bpf@vger.kernel.org, vishal.moola@gmail.com Subject: Re: [PATCH 12/18] page_pool: use netmem APIs to access page->pp_magic in page_pool_page_is_pp() In-Reply-To: <20250526094305.GA29080@system.software.com> References: <20250523032609.16334-1-byungchul@sk.com> <20250523032609.16334-13-byungchul@sk.com> <20250526022307.GA27145@system.software.com> <20250526023624.GB27145@system.software.com> <87o6vfahoh.fsf@toke.dk> <20250526094305.GA29080@system.software.com> X-Clacks-Overhead: GNU Terry Pratchett Date: Mon, 26 May 2025 11:54:33 +0200 Message-ID: <87ldqjae92.fsf@toke.dk> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 4Q_ji6Q_4UyV7bcOqqkhNKDcrUc0P_SKxfmYSrfka5I_1748253276 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 5FDC81C0007 X-Stat-Signature: gdetf3r67twnr55xxbdporq7pou5ec1k X-Rspam-User: X-HE-Tag: 1748253279-185799 X-HE-Meta: U2FsdGVkX19DNyNm8LxEeBDXW/TGC9c8KnFHIlUt/7eO7Q4AtFL77XMO2I2y2BRkluTi32m4NFays5ZyYysH4vCbN/CssM4R5vjKMWREWUKWspdsXda/qpKGuMZwIKq2Loai2auJomyg18to1JRpePaQZ85WHU1UofmIMLuZXheFhcsGhpFgf7k4mgrLoMq1e6pajvAZKB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tx1E0EdbYqXBot1dohkXW3RPdkFkaWoD8+dekW9rVgewcJ7f/OoJB/LZzUhh1NqCxc6NpcGD7+aNpdayx0OKBfXLF1OW1rFRDevKcbBSCrBm9usxtxZGeDss3MLXdjaPDRj3Wf+JbAJOFaW7xsTJV0Iy9+VQ/P33JWSCP+XQf/+ijVgswH/8RiL+6Ct08bKXU6Q4rEV3H/GoxVxYMGYtQnt6EE8GHdBUAgwybGlvHfzCfnLNs5+dfB9EVw0OhPatDE7WjlKANAlh1fCnHMlwjKR9FXaKqKBTYPJMsiH3UFbaHZEmJ5ZBonJqRJNoi2tfqVJur 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: Byungchul Park writes: > On Mon, May 26, 2025 at 10:40:30AM +0200, Toke H=C3=B8iland-J=C3=B8rgense= n wrote: >> Byungchul Park writes: >>=20 >> > On Mon, May 26, 2025 at 11:23:07AM +0900, Byungchul Park wrote: >> >> On Fri, May 23, 2025 at 10:21:17AM -0700, Mina Almasry wrote: >> >> > On Thu, May 22, 2025 at 8:26=E2=80=AFPM Byungchul Park wrote: >> >> > > >> >> > > To simplify struct page, the effort to seperate its own descripto= r from >> >> > > struct page is required and the work for page pool is on going. >> >> > > >> >> > > To achieve that, all the code should avoid accessing page pool me= mbers >> >> > > of struct page directly, but use safe APIs for the purpose. >> >> > > >> >> > > Use netmem_is_pp() instead of directly accessing page->pp_magic i= n >> >> > > page_pool_page_is_pp(). >> >> > > >> >> > > Signed-off-by: Byungchul Park >> >> > > --- >> >> > > include/linux/mm.h | 5 +---- >> >> > > net/core/page_pool.c | 5 +++++ >> >> > > 2 files changed, 6 insertions(+), 4 deletions(-) >> >> > > >> >> > > diff --git a/include/linux/mm.h b/include/linux/mm.h >> >> > > index 8dc012e84033..3f7c80fb73ce 100644 >> >> > > --- a/include/linux/mm.h >> >> > > +++ b/include/linux/mm.h >> >> > > @@ -4312,10 +4312,7 @@ int arch_lock_shadow_stack_status(struct t= ask_struct *t, unsigned long status); >> >> > > #define PP_MAGIC_MASK ~(PP_DMA_INDEX_MASK | 0x3UL) >> >> > > >> >> > > #ifdef CONFIG_PAGE_POOL >> >> > > -static inline bool page_pool_page_is_pp(struct page *page) >> >> > > -{ >> >> > > - return (page->pp_magic & PP_MAGIC_MASK) =3D=3D PP_SIGNATU= RE; >> >> > > -} >> >> >=20 >> >> > I vote for keeping this function as-is (do not convert it to netmem= ), >> >> > and instead modify it to access page->netmem_desc->pp_magic. >> >>=20 >> >> Once the page pool fields are removed from struct page, struct page w= ill >> >> have neither struct netmem_desc nor the fields.. >> >>=20 >> >> So it's unevitable to cast it to netmem_desc in order to refer to >> >> pp_magic. Again, pp_magic is no longer associated to struct page. >> > >> > Options that come across my mind are: >> > >> > 1. use lru field of struct page instead, with appropriate comment b= ut >> > looks so ugly. >> > 2. instead of a full word for the magic, use a bit of flags or use >> > the private field for that purpose. >> > 3. do not check magic number for page pool. >> > 4. more? >>=20 >> I'm not sure I understand Mina's concern about CPU cycles from casting. >> The casting is a compile-time thing, which shouldn't affect run-time > > I didn't mention it but yes. > >> performance as long as the check is kept as an inline function. So it's >> "just" a matter of exposing struct netmem_desc to mm.h so it can use it > > Then.. we should expose net_iov as well, but I'm afraid it looks weird. > Do you think it's okay? Well, it'll be ugly, I grant you that :) Hmm, so another idea could be to add the pp_magic field to the inner union that the lru field is in, and keep the page_pool_page_is_pp() as-is. Then add an assert for offsetof(struct page, pp_magic) =3D=3D offsetof(netmem_desc, pp_magic) on the netmem side, which can be removed once the two structs no longer shadow each other? That way you can still get rid of the embedded page_pool struct in struct page, and the pp_magic field will just be a transition thing until things are completely separated... -Toke