Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5019560pxj; Wed, 12 May 2021 19:39:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwNUOUbAFArJVDT++y3N816/+qrntRxWeBCx44Oz/COQstmRLo0KtVHIlEp6W+bqYb1XUcc X-Received: by 2002:a05:6e02:20ce:: with SMTP id 14mr33805898ilq.102.1620873560712; Wed, 12 May 2021 19:39:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620873560; cv=none; d=google.com; s=arc-20160816; b=vUAii0HaQvRlBarY1jjsCMaiy2voSuk9ZrLZoeDsmcGpAchz4G3yxzR6lJpz5xpmKx qKBO/mImXEIpSZb9MMWqz5WdFRxQtUf7pNBqjkEnEydoSfNXZXQlOQSC395ilNJ/nsVy crYpt3FzVnVExMrzkYOFWxAHqg9JAqA8QTajw6mcxtW5hRMj5gShkrhnid6C1REEcnSx cch9RXUaGS9+7v0Kw9l+HSSZWVI9hCZJGwy3Io54cbKg3qMUq9BKpiHOfgzC4YF2Eccg JtkEGgiLpPLvbT0c5iwSuozTHGcGn/4GrR1cPPNUTGbPFhdbUtekjdq51Eu3o2r+hthJ iwag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=TenrWiIkYtVAh+YSG9ppJcEvQ+ICO0xNa6eESJHAhgA=; b=WmqKz+0Mia0/JnuG14EsBzN2EpMPNm80Mq+0/vqbsKuNV9LB7eZtlgfkJYBhm17y4H nSmkBLnbsPjHkbR43kXTdTcv+typXMo5OpcKwArrEC+qAEv5TggIDDrYD5y0YNOKUs7a vQi+bwPQYyaJ83MRlPs60H8wUP6qFiN4Vdq/MoNn7pCIUMHNmDaTjynobwbFP6nnxs5A nAUrwjnOaeC0XPo8d/MdsKUVnt8s86JK6GxJkM7kst24GAKcLlhBzIqnXwLJUSJDLhjg Rksc88NRrzPVJJ9GlZGfHpM+o1GoTuOwh5K3592gJxPqkMIWLM9NTtnKxVMYwZXGVZEy Dd3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=oY3n65Pb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b3si1665493ilj.20.2021.05.12.19.39.06; Wed, 12 May 2021 19:39:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=oY3n65Pb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230384AbhEMCir (ORCPT + 99 others); Wed, 12 May 2021 22:38:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230326AbhEMCio (ORCPT ); Wed, 12 May 2021 22:38:44 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3C14C061574; Wed, 12 May 2021 19:37:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=TenrWiIkYtVAh+YSG9ppJcEvQ+ICO0xNa6eESJHAhgA=; b=oY3n65PbfkVv41I70t6lqq9DW7 Nc49YFeX1YsxjnKc0EHtgpu4GUOsOwCB4Bh/AhPUTFuUZe5ZZ23q++8CBxNxQ/SJwzyxVqsccpHxl Vss0GOdtaPNnC5HQvhuiBrMv/ZyXU1Cn1UCgS1RqKmE4JumRPEArf0t8OfD01+5KetSMt25D9C6So gkURYhk+BRL3RNHclDOJbCSiqhC6yp82vfs6onbn8EfZFgPcmpcpSnwSUPKfKZkQvS54ISzuWSkvP 2nyFXSKgI+RE0q+lu9vHxXIzurzEOYVFSDhGIWg/1Ld4oWEChi48USDfO7D135gwPtJNdpOAO4tTK O1V2RKqg==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lh1Bw-0097Bt-GN; Thu, 13 May 2021 02:35:24 +0000 Date: Thu, 13 May 2021 03:35:12 +0100 From: Matthew Wilcox To: Yunsheng Lin Cc: Ilias Apalodimas , Matteo Croce , Networking , Linux-MM , Ayush Sawal , Vinay Kumar Yadav , Rohit Maheshwari , "David S. Miller" , Jakub Kicinski , Thomas Petazzoni , Marcin Wojtas , Russell King , Mirko Lindner , Stephen Hemminger , Tariq Toukan , Jesper Dangaard Brouer , Alexei Starovoitov , Daniel Borkmann , John Fastabend , Boris Pismenny , Arnd Bergmann , Andrew Morton , "Peter Zijlstra (Intel)" , Vlastimil Babka , Yu Zhao , Will Deacon , Michel Lespinasse , Fenghua Yu , Roman Gushchin , Hugh Dickins , Peter Xu , Jason Gunthorpe , Jonathan Lemon , Alexander Lobakin , Cong Wang , wenxu , Kevin Hao , Jakub Sitnicki , Marco Elver , Willem de Bruijn , Miaohe Lin , Guillaume Nault , open list , linux-rdma@vger.kernel.org, bpf , Eric Dumazet , David Ahern , Lorenzo Bianconi , Saeed Mahameed , Andrew Lunn , Paolo Abeni , Sven Auhagen Subject: Re: [PATCH net-next v4 1/4] mm: add a signature in struct page Message-ID: References: <20210511133118.15012-1-mcroce@linux.microsoft.com> <20210511133118.15012-2-mcroce@linux.microsoft.com> <3f9a0fb0-9cb9-686d-e89b-ea589d88ab58@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3f9a0fb0-9cb9-686d-e89b-ea589d88ab58@huawei.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 13, 2021 at 10:15:26AM +0800, Yunsheng Lin wrote: > On 2021/5/12 23:57, Matthew Wilcox wrote: > > You'll need something like this because of the current use of > > page->index to mean "pfmemalloc". > > > > @@ -1682,12 +1684,12 @@ static inline bool page_is_pfmemalloc(const struct page *page) > > */ > > static inline void set_page_pfmemalloc(struct page *page) > > { > > - page->index = -1UL; > > + page->compound_head = 2; > > Is there any reason why not use "page->compound_head |= 2"? as > corresponding to the "page->compound_head & 2" in the above > page_is_pfmemalloc()? > > Also, this may mean we need to make sure to pass head page or > base page to set_page_pfmemalloc() if using > "page->compound_head = 2", because it clears the bit 0 and head > page ptr for tail page too, right? I think what you're missing here is that this page is freshly allocated. This is information being passed from the page allocator to any user who cares to look at it. By definition, it's set on the head/base page, and there is nothing else present in the page->compound_head. Doing an OR is more expensive than just setting it to 2. I'm not really sure why set/clear page_pfmemalloc are defined in mm.h. They should probably be in mm/page_alloc.c where nobody else would ever think that they could or should be calling them. > > struct { /* page_pool used by netstack */ > > - /** > > - * @dma_addr: might require a 64-bit value on > > - * 32-bit architectures. > > - */ > > + unsigned long pp_magic; > > + struct page_pool *pp; > > + unsigned long _pp_mapping_pad; > > unsigned long dma_addr[2]; > > It seems the dma_addr[1] aliases with page->private, and > page_private() is used in skb_copy_ubufs()? > > It seems we can avoid using page_private() in skb_copy_ubufs() > by using a dynamic allocated array to store the page ptr? This is why I hate it when people use page_private() instead of documenting what they're doing in struct page. There is no way to know (as an outsider to networking) whether the page in skb_copy_ubufs() comes from page_pool. I looked at it, and thought it didn't: page = alloc_page(gfp_mask); but if you say those pages can come from page_pool, I believe you.