Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5008979pxj; Wed, 12 May 2021 19:18:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDH2PWeWCBHwhpYugev+OWixXeNqBRgyWBhFVOO7r2HL2gLHq6+LrNZmskmDR3/SGSon8Z X-Received: by 2002:a02:c912:: with SMTP id t18mr35159350jao.100.1620872280431; Wed, 12 May 2021 19:18:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620872280; cv=none; d=google.com; s=arc-20160816; b=D8v8aRWFqvyCdJRUqAxotqWZWtw4Zeru2Zkdw4UFHUqfjqURLYetaz8nIPAR93+oPJ AXkILp6dNSp+Q9MH+YpNGlRMSq/wfV4hdxik80urY+d/pJJ9ZbC6sHSWDgVrMIJtixnb OxrBNqEdQVphUZHRIUnGfQT/cyKJzCbaafL544Ucz9Uy0jPEUuQLEftdtidnGWWXZhhv 2xg6MrGDdg/ESV3X2B9nk+f/Ob/EfwjaE0M5Jb/ZgR+Y0psy80MAI7lM5RfF6Qg37BlQ Hf4Q/cZn+LON9FuG1zpbnyqc62pqd7o/hNXKXsUbc45L9o2OA6jP72zTtPNoFpcQO4dr IBMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=qFplS+0wnzhceFHSQZKa90TNhRMONlJe/D5KP++PdJI=; b=RM9vkBnWzHvMenXEMbmn/i9gZUMKzVA5SFskih8J6uf4HpWeLmuzNh7r2SCTPmSJBl BmAyJRV1d4Ai4eHIARxx4fHCspMRvRaIJUJ98hOElqOOFXcjt2rFpqijKHbWgAr/O4A7 3CEQ4Tz0R9Wbgtgjph/31+W8BKzyo+zKzpFLNkkhALLQ+VR95qL12yrEuS9KtmFDErav nnJkqRSZGAQOahe8rucuEElQXHd0CSWwKQLivMWtUmS42jJGd0sBd8JRXIBA1GgV4Urw OYUYPU62KeygadV8skmb66tgCgsmEAMBMfzs6dsYbYeDcU+TUqSI6qotzR3VRSLqEWLW c1JA== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m20si2338623jat.70.2021.05.12.19.17.48; Wed, 12 May 2021 19:18:00 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230259AbhEMCQn (ORCPT + 99 others); Wed, 12 May 2021 22:16:43 -0400 Received: from szxga08-in.huawei.com ([45.249.212.255]:2305 "EHLO szxga08-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229630AbhEMCQm (ORCPT ); Wed, 12 May 2021 22:16:42 -0400 Received: from dggeml718-chm.china.huawei.com (unknown [172.30.72.55]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4FgZrx48RSz19PSm; Thu, 13 May 2021 10:11:13 +0800 (CST) Received: from dggpemm500005.china.huawei.com (7.185.36.74) by dggeml718-chm.china.huawei.com (10.3.17.129) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Thu, 13 May 2021 10:15:27 +0800 Received: from [127.0.0.1] (10.69.30.204) by dggpemm500005.china.huawei.com (7.185.36.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2176.2; Thu, 13 May 2021 10:15:27 +0800 Subject: Re: [PATCH net-next v4 1/4] mm: add a signature in struct page To: Matthew Wilcox , Ilias Apalodimas CC: 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 , , bpf , Eric Dumazet , David Ahern , Lorenzo Bianconi , Saeed Mahameed , Andrew Lunn , Paolo Abeni , Sven Auhagen References: <20210511133118.15012-1-mcroce@linux.microsoft.com> <20210511133118.15012-2-mcroce@linux.microsoft.com> From: Yunsheng Lin Message-ID: <3f9a0fb0-9cb9-686d-e89b-ea589d88ab58@huawei.com> Date: Thu, 13 May 2021 10:15:26 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.69.30.204] X-ClientProxiedBy: dggeme716-chm.china.huawei.com (10.1.199.112) To dggpemm500005.china.huawei.com (7.185.36.74) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/5/12 23:57, Matthew Wilcox wrote: > On Tue, May 11, 2021 at 05:25:36PM +0300, Ilias Apalodimas wrote: >> Nope not at all, either would work. we'll switch to that > > You'll need something like this because of the current use of > page->index to mean "pfmemalloc". > >>From ecd6d912056a21bbe55d997c01f96b0b8b9fbc31 Mon Sep 17 00:00:00 2001 > From: "Matthew Wilcox (Oracle)" > Date: Fri, 16 Apr 2021 18:12:33 -0400 > Subject: [PATCH] mm: Indicate pfmemalloc pages in compound_head > > The net page_pool wants to use a magic value to identify page pool pages. > The best place to put it is in the first word where it can be clearly a > non-pointer value. That means shifting dma_addr up to alias with ->index, > which means we need to find another way to indicate page_is_pfmemalloc(). > Since page_pool doesn't want to set its magic value on pages which are > pfmemalloc, we can use bit 1 of compound_head to indicate that the page > came from the memory reserves. > > Signed-off-by: Matthew Wilcox (Oracle) > --- > include/linux/mm.h | 12 +++++++----- > include/linux/mm_types.h | 7 +++---- > 2 files changed, 10 insertions(+), 9 deletions(-) > > diff --git a/include/linux/mm.h b/include/linux/mm.h > index bd21864449bf..4f9b2007efad 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -1670,10 +1670,12 @@ struct address_space *page_mapping(struct page *page); > static inline bool page_is_pfmemalloc(const struct page *page) > { > /* > - * Page index cannot be this large so this must be > - * a pfmemalloc page. > + * This is not a tail page; compound_head of a head page is unused > + * at return from the page allocator, and will be overwritten > + * by callers who do not care whether the page came from the > + * reserves. > */ > - return page->index == -1UL; > + return page->compound_head & 2; > } > > /* > @@ -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? > } > > static inline void clear_page_pfmemalloc(struct page *page) > { > - page->index = 0; > + page->compound_head = 0; > } > > /* > diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h > index 5aacc1c10a45..1352e278939b 100644 > --- a/include/linux/mm_types.h > +++ b/include/linux/mm_types.h > @@ -96,10 +96,9 @@ struct page { > unsigned long private; > }; > 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? > }; > struct { /* slab, slob and slub */ >