Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5042175pxj; Wed, 12 May 2021 20:27:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwlszLDNmT3nWs66GpoEAetIwZGLT6wbMk7nR2NfXlUPf47EcFVhXaRAeGsUMDEmrXX6/QU X-Received: by 2002:a50:ff13:: with SMTP id a19mr47244294edu.300.1620876434942; Wed, 12 May 2021 20:27:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620876434; cv=none; d=google.com; s=arc-20160816; b=KpQu2MtbaUqBXr70wVLSfaNz1Vp/HsZKT1gCbXAELDzxr442mxFp80qgNZN7YGyxPU na+3RqJ07E2E63qzVoFCRVS5thPLjjkM6Dg0bRcxW4muV/xmenTimNmWlhh4W6rHPbOo BRyYvcTu6RhFpJd7BhfSFgkEpYoRH88PeTGArQd8xAcpK1YGf4FQZhNMx0U0ZKB9e6If uEjSWZF6ADB2fsCmdaPwUnhGrBBsXrXAWlrbAjzOhojmXhR3ToUsXfuQgAhAXPP5mRGJ BVa6EgEGLNRXdET2s2RAqRB9peFpGhg93ovgi50h7wmbRtyWpRI4b8ai3VErGQ2m/iA3 atxw== 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=mmuDDvCIhofeZ7PRrZfsdPTuEK6V5/T8cWMWYkxJJjU=; b=FhvXavx+BVVBe6FM50IOwFAUHNJ6e88m1PIwr/v/15aAeM0kRrRFlfK8QT/pLfcNJW 5n+ODYYAVXY3SHY1MtOXSTsjQO6cpSXrGwCSIS9FRbuZD59XT79dWU6RN9MNXzmMRuco J+0uOZIxl6TYkA49n1V/nsNQEz41Ces9wdSOXaQwkOYWjOBl2vU9xKUNf/2iEnd/3xON kCfkH033Q4TuVXiY1WISy2Gxo4iwCAh/bDP3RRpgoI08FYChEl5quAv2b/UTUm2ipUox EwZegsZ2mG0fzHCTenCCLcMyIEYwZ+W1tflHruNWeMrYQFQKFddR5d/qiGjZ4liyTRDG lpDw== 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 v23si1573878edy.13.2021.05.12.20.26.33; Wed, 12 May 2021 20:27:14 -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 S231153AbhEMD0m (ORCPT + 99 others); Wed, 12 May 2021 23:26:42 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:5105 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230247AbhEMD0k (ORCPT ); Wed, 12 May 2021 23:26:40 -0400 Received: from dggeml758-chm.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4FgcRg0mnMzYhMM; Thu, 13 May 2021 11:22:55 +0800 (CST) Received: from dggpemm500005.china.huawei.com (7.185.36.74) by dggeml758-chm.china.huawei.com (10.1.199.159) 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 11:25:23 +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 11:25:23 +0800 Subject: Re: [PATCH net-next v4 1/4] mm: add a signature in struct page To: Matthew Wilcox 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 , , 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> <3f9a0fb0-9cb9-686d-e89b-ea589d88ab58@huawei.com> From: Yunsheng Lin Message-ID: <8f815871-e384-3e65-56a8-39e379dea4ce@huawei.com> Date: Thu, 13 May 2021 11:25:22 +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/13 10:35, Matthew Wilcox wrote: > 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. Thanks for clarifying. > > 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. page_private() using in skb_copy_ubufs() does indeed seem ok here. the page_private() is used on the page which is freshly allocated from alloc_page(). Sorry for the confusion. > > . >