Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp477745pxb; Sat, 10 Apr 2021 08:49:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+NlahkImQBrunKpQ31kyxCPOfTH3VYZQAtgSuv0Ck4pCqnkfGuTaxQnMjyPNb4XKxB9Lk X-Received: by 2002:a17:902:e843:b029:e7:3c04:8d70 with SMTP id t3-20020a170902e843b02900e73c048d70mr18150040plg.48.1618069775827; Sat, 10 Apr 2021 08:49:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618069775; cv=none; d=google.com; s=arc-20160816; b=dkBJHBWGmhYiYTvkDYIhCvx0tCcUGKvPLboAoPZ0t7outO3UgBMSlpTHUT8y28dkPs KCgeXUuPmleunO4Y9Iz4ekffGgZnY3XIHWk+EfOGaQi0MwwYNgP1YrZUbH5pz7WQZ0Gw up7QzNArB+tHGTZNPToyH1+MqBOejoIpUb9b1DftwHuzxvaZrFAA17avvX48819rUlqG g3zYC0a50aj1fFcxL3j6iV5fAguStZim3aLHdFVZIE23tmDj4yiQ8qMtOF1CrernsIMl hmqiv8gyT3f5Rr3CpEHbUQA6nSavgAkeJq8BBslQzh6IY0YwtVpbFQcyTzGrdtWB9VEi m47A== 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=91B1rcP8cMJQqrbDXcQN0ARnzQOA1OqZMuSrhvn5KWM=; b=Q4ibBZ9cAGNcxK+FScTHVYrb+D0Zk7+Gt1lrH3TxUv8OQhf4i+4fHi+iDVWS0PzJzw 3uHh1S2ISOfqsIAWq4WFtNXbCLIqdyycBoUA+Z5iwmTKoYF/TxCQZqMwCvyqsOQ9YYdL zDwnF9LNMXknGZQDIi4F14n4zpwVEIi3WQemFsIUEPe3IdTyUFhhKqfN0fO+h1gWofiU pXeWoPxWgmctJAeAXZFunu77s/Bm58GTGDoklE/ktrc013vVtyWbTIsdaZ6d1C8fImpw UEmoWQHw0JPLDSjod2IJapo7tB/AoG17u2KIqD0IuKjIXJQFSi4wvoyy9x2jijX7GKFo v7Ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=evTQPZqI; 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 17si7483653pgr.488.2021.04.10.08.49.23; Sat, 10 Apr 2021 08:49:35 -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=evTQPZqI; 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 S234738AbhDJPtI (ORCPT + 99 others); Sat, 10 Apr 2021 11:49:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234334AbhDJPtI (ORCPT ); Sat, 10 Apr 2021 11:49:08 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F4D0C06138A; Sat, 10 Apr 2021 08:48:53 -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=91B1rcP8cMJQqrbDXcQN0ARnzQOA1OqZMuSrhvn5KWM=; b=evTQPZqIi5C2RLsOo/Cnp8EvmB +uevWJugbBaSvzGC1a3HmfgpppZ6H1ka7pXORdatOgeVE3x3oXAbAseMJAUFRD7T4ieZ5i7iiKhlp s13tFWfw/Cw0h1OKIkHOpy0hV022PAiVzvvtxFLai9MMVguPFdLDq4j90+T/YAth83dSLczxTeuNW 2WU9FO6QmMXdyNeytzYOZHDNDUKGMJaWbvPFUxIgPtJXRTCKU1gjDOL5ajONo2fvEa5FSsVZ0rf/K M0ZWL1F0jSmahwlmebzn8v0M9ft1X/XAyYHxO5+HYitLqCGcQCzcmbfBB0K9PsGLHRcbZ62eFStHJ 5u/3GzcQ==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lVFqS-001rFg-3o; Sat, 10 Apr 2021 15:48:28 +0000 Date: Sat, 10 Apr 2021 16:48:24 +0100 From: Matthew Wilcox To: Matteo Croce Cc: netdev@vger.kernel.org, linux-mm@kvack.org, 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 , Ilias Apalodimas , 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 , Guoqing Jiang , Jonathan Lemon , Alexander Lobakin , Cong Wang , wenxu , Kevin Hao , Aleksandr Nogikh , Jakub Sitnicki , Marco Elver , Willem de Bruijn , Miaohe Lin , Yunsheng Lin , Guillaume Nault , linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, bpf@vger.kernel.org, Eric Dumazet , David Ahern , Lorenzo Bianconi , Saeed Mahameed , Andrew Lunn , Paolo Abeni Subject: Re: [PATCH net-next v3 2/5] mm: add a signature in struct page Message-ID: <20210410154824.GZ2531743@casper.infradead.org> References: <20210409223801.104657-1-mcroce@linux.microsoft.com> <20210409223801.104657-3-mcroce@linux.microsoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210409223801.104657-3-mcroce@linux.microsoft.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Apr 10, 2021 at 12:37:58AM +0200, Matteo Croce wrote: > This is needed by the page_pool to avoid recycling a page not allocated > via page_pool. Is the PageType mechanism more appropriate to your needs? It wouldn't be if you use page->_mapcount (ie mapping it to userspace). > Signed-off-by: Matteo Croce > --- > include/linux/mm_types.h | 1 + > include/net/page_pool.h | 2 ++ > net/core/page_pool.c | 4 ++++ > 3 files changed, 7 insertions(+) > > diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h > index 6613b26a8894..ef2d0d5f62e4 100644 > --- a/include/linux/mm_types.h > +++ b/include/linux/mm_types.h > @@ -101,6 +101,7 @@ struct page { > * 32-bit architectures. > */ > dma_addr_t dma_addr; > + unsigned long signature; > }; > struct { /* slab, slob and slub */ > union { > diff --git a/include/net/page_pool.h b/include/net/page_pool.h > index b5b195305346..b30405e84b5e 100644 > --- a/include/net/page_pool.h > +++ b/include/net/page_pool.h > @@ -63,6 +63,8 @@ > */ > #define PP_ALLOC_CACHE_SIZE 128 > #define PP_ALLOC_CACHE_REFILL 64 > +#define PP_SIGNATURE 0x20210303 > + > struct pp_alloc_cache { > u32 count; > void *cache[PP_ALLOC_CACHE_SIZE]; > diff --git a/net/core/page_pool.c b/net/core/page_pool.c > index ad8b0707af04..2ae9b554ef98 100644 > --- a/net/core/page_pool.c > +++ b/net/core/page_pool.c > @@ -232,6 +232,8 @@ static struct page *__page_pool_alloc_pages_slow(struct page_pool *pool, > page_pool_dma_sync_for_device(pool, page, pool->p.max_len); > > skip_dma_map: > + page->signature = PP_SIGNATURE; > + > /* Track how many pages are held 'in-flight' */ > pool->pages_state_hold_cnt++; > > @@ -302,6 +304,8 @@ void page_pool_release_page(struct page_pool *pool, struct page *page) > DMA_ATTR_SKIP_CPU_SYNC); > page->dma_addr = 0; > skip_dma_unmap: > + page->signature = 0; > + > /* This may be the last page returned, releasing the pool, so > * it is not safe to reference pool afterwards. > */ > -- > 2.30.2 >