Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4755003pxj; Wed, 12 May 2021 12:29:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyG4SvjEO75P18izL2RLc4NsBqkvxO6rhWRZMXYSi0nbZqAo7KcuEFBxwy9xzbvPLqtBSzc X-Received: by 2002:a17:906:a20b:: with SMTP id r11mr39733950ejy.323.1620847776447; Wed, 12 May 2021 12:29:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620847776; cv=none; d=google.com; s=arc-20160816; b=0PoukLzhcT8gMH3gXCoEB+c7R2Fgw6zqK2/ebQl/urwceE6/rnr9I3tF7X4fbnYL3K GWc5lghEA53QfRQ9jmw1UaKbyagiQIZVvyRfcdCCwZjaMTgJNDfU7FZhzYlCkMS0vG0F 7QKOE1SL0WE7sMRIiiOV/TghboEvZeNzGGamERoyWl+kxZFi6GsEyyT6I5OUiIKtzBaE 5N9tM86Psty7briGGRbII3XKGtmoIptrUxmUZr383t4W1LhyLJuCnR6FjLCnYy5jtJT8 olbvRy4sLh+ijLruoV1JQ/N4c9Tx2e5sfe7JpCItz8ZgCGn7DLbRyYWfM4AkwpD0hXoU EqNA== 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=RLyFJOnJjfJNfSNCl5gvlLTZNd55peOaxfXJb9HMmN4=; b=fo3xEMltFa2yggAKUwKaQsrThv/JlARr+ChkJgjT0TKsuZAYPcwm4TjPRNolYiYNwR AutdZpcWGRKLlxkb/3HVvrigSzq9VHYHLeNFVZ0kqKWtvrKbSGkRNkyTnQ/+7ylIMVGt 6G3yYu54lACnX9entzTBcNJaPveKyGiBQkiRK020nY4/egOh+FLf/juPQUUVEB2ENtlp a+eq4TmfDw65LkMqmxHgB1Xvkz4HiTUJ1lBYrEAq6st7/Q2JDp/nq1YxPA0U5nkiPwXn 93B+D67nyjPS7p7+u/2qPaRbunB+Dd1GEoogP8Dn2/n+wRTchu2ebwP9n5bG71Hq7DG1 giGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=XD9fuf5N; 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 r3si734347ejs.480.2021.05.12.12.28.50; Wed, 12 May 2021 12:29:36 -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=XD9fuf5N; 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 S244920AbhELTVP (ORCPT + 99 others); Wed, 12 May 2021 15:21:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245222AbhELQwM (ORCPT ); Wed, 12 May 2021 12:52:12 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1053FC08C5E2; Wed, 12 May 2021 09:29:38 -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=RLyFJOnJjfJNfSNCl5gvlLTZNd55peOaxfXJb9HMmN4=; b=XD9fuf5NVBptzlMagMcg3fxYnG qid6hR1wjdfENmD7YKGyjj5dFHHDkTWxjEiXYcLJUFo/s+CfKw2OLm7DvkxBIjETY/CnKNCP9DHW8 S7buSfwX0Fg6wI65TnM+GZwyUur8AiWKNSdwppV7LD4CpmdxlN2tLNNtO49QE1fsRzuawWRNl5QAn RwF5dzinb4/J3QF9zhCgKRqdfGEnUQjuf2rbnlchAVVw+MrKq1gV0QYmqTmeQIZcxnv97eLolN0Ly a3+i54K3len2+vEJreo5MzvaxgCZvmeMegoWJAhKUgzr3PJIPmCC1mJfNz9yY9ez7ZP0rOFBntcEE Hq+ANgow==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lgrga-008W2Y-Nw; Wed, 12 May 2021 16:26:25 +0000 Date: Wed, 12 May 2021 17:26:12 +0100 From: Matthew Wilcox To: Eric Dumazet 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 , Yunsheng Lin , Guillaume Nault , open list , linux-rdma , bpf , 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 12, 2021 at 06:09:21PM +0200, Eric Dumazet wrote: > On Wed, May 12, 2021 at 6:03 PM 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; > > } > > > > 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]; > > }; > > struct { /* slab, slob and slub */ > > This would break compound_head() ? No, compound_head() only checks bit 0. If bit 0 is clear, then this is not a tail page.