Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp495768pxb; Sat, 10 Apr 2021 09:19:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxlt+WSArOElSsj2Fv5KyWKsZQ//XAHx/5tX3pUeKnnfjLG+HUiHaDfFmQKzSoW4Nh44bBk X-Received: by 2002:a17:90b:4718:: with SMTP id jc24mr5627584pjb.210.1618071560681; Sat, 10 Apr 2021 09:19:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618071560; cv=none; d=google.com; s=arc-20160816; b=uARrgDbFXeZfCkAKy5JBfYSZbQOXNEaJBQ0U9sHv07dvjTGvim6QSVSOadT7ZrugvH oRcFClv4Z5jh5wuEW0gpq9AhpGCaMyoL9o90k2yhB0pJVHMVWGt42+HXboqdhvyq7zXm ku+RRiuaLsArpr9D6aTaB9AUHGUmupHMyPGRRBECAh2Pz3Tleacf+wYGJhmmy/Hb13ar p01lSKWs2DjxQ1BZA8iB7t9kivoBb7dTK7lvU/LMaflSikkcNGpuC+CVjzIexpftvObl 6vjz5c+p2WTiX47dQ8u4JJXacigK2KRVOnTQfy/SCL7AZyssfGAruiHElMmBpXy3mO0g H+Xg== 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=ZtZHBLTCs7MZ+oNP0mY9TjGEU/md/IA3GJQkuj80sew=; b=iQGzLhfglDVl7/SkiHiveF2pLVjXQq3TcCXT2SHiWHH3t6IRiEjRLaQgLNBaSaiNR/ ssmph0KoaUwne47eDBqWyi+fofYwGojOkR82fD91O6ITDiKfDahIOtooGij1CZLr0j3S yV6bHDAwzbyVtyZCPJeQ4mpbBAxX6idYnb6m4ziRDcsxhHLqk37XpyGlVizUzP0rICdl /fPxhPerSMU97IurLBtQlDPaxX4h357cPZALb2TdyrsY6PNTJhNNHM1Uuf/FABZLSNEg gPWuWPLpHBuNbxlIIAxZxJqqQBwxbQtzBrG01NuW+7FuXaNgVxjPlO7zds2sH0g7ukfY tSzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Bp3G7rXd; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h4si6930401pgk.363.2021.04.10.09.19.08; Sat, 10 Apr 2021 09:19: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=@linaro.org header.s=google header.b=Bp3G7rXd; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234865AbhDJQRM (ORCPT + 99 others); Sat, 10 Apr 2021 12:17:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234832AbhDJQRJ (ORCPT ); Sat, 10 Apr 2021 12:17:09 -0400 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D77FEC06138B for ; Sat, 10 Apr 2021 09:16:52 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id n11-20020a05600c4f8bb029010e5cf86347so6506583wmq.1 for ; Sat, 10 Apr 2021 09:16:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=ZtZHBLTCs7MZ+oNP0mY9TjGEU/md/IA3GJQkuj80sew=; b=Bp3G7rXdj30nXahmCb0DX42/GpQq1NqVzRF3U8dpNmLoLFw08YqVW0WmTFlQz+n48O M2zywKwO2O5xxvb1z3UGKVFtAEDcrkDu8fWhD3WoVLSrFWHESGd3gWEfXxADH05sAM7O wGaMz+7TbhLVVvc8C90tpPkoqpXDs0nzasfuK/ZtQfCl+zxDbsrTM93E9yzxqn2iXTco YX2lZWxg+TldvU18p6YAWW/e3bw7NAvlwm3SHKK367vEwZzH9gKvwPrTcsdXyWMDg6qr de5eOntFj7fjAPKLWzRfU+Z9V+yxdliPGzjBwyEc/fmcBy+1nxuTJ0czZ3m4q/pHEgr9 KwFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ZtZHBLTCs7MZ+oNP0mY9TjGEU/md/IA3GJQkuj80sew=; b=KeS2+bZAKmJNcizxDCwLxgFhvlIMJT85KCGp9hvcU+/9uTPyKtCK9KwfdLVUEwPyTe TwHFJcyBSDeUMTj8vlLJQn18pc5aAicQAhNS6L1WJs4u70JLTuINrqBg8cJ55te5+Nbx O1skx+3d+9VSWEzPz0WzBcsJtJyKNa/kLjCZ0R5zUgZOrBKoaAEh6vgMx/dqI72Wnnqh 3xIRKmDUgjpQeH10DjQZsVzMoDgKaw28hBIqIzVATbZmaDZJqKzMNiU5dkmaTGgbfUi8 foDiO7P+KMPk4wDYKMFqGcgLA9/Bvs3moP6HrijnWJeX0/LGFYqKbkZ1yFp5p7nT9B3c 0coA== X-Gm-Message-State: AOAM532XMPDjZBDw3jJCDLmJt/74wxmNAg5vkU3JGrzP6n49f69Cted/ TPt6qJBRw8mq6TzMMN+m50JTIg== X-Received: by 2002:a05:600c:3641:: with SMTP id y1mr13991903wmq.65.1618071411457; Sat, 10 Apr 2021 09:16:51 -0700 (PDT) Received: from enceladus (ppp-94-65-225-75.home.otenet.gr. [94.65.225.75]) by smtp.gmail.com with ESMTPSA id m26sm8126680wmg.17.2021.04.10.09.16.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Apr 2021 09:16:50 -0700 (PDT) Date: Sat, 10 Apr 2021 19:16:45 +0300 From: Ilias Apalodimas To: Matthew Wilcox Cc: Matteo Croce , 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 , 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: References: <20210409223801.104657-1-mcroce@linux.microsoft.com> <20210409223801.104657-3-mcroce@linux.microsoft.com> <20210410154824.GZ2531743@casper.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210410154824.GZ2531743@casper.infradead.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Matthew On Sat, Apr 10, 2021 at 04:48:24PM +0100, Matthew Wilcox wrote: > 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). Interesting! Please keep in mind this was written ~2018 and was stale on my branches for quite some time. So back then I did try to use PageType, but had not free bits. Looking at it again though, it's cleaned up. So yes I think this can be much much cleaner. Should we go and define a new PG_pagepool? Thanks! /Ilias > > > 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 > >