From patchwork Tue May 11 13:31:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matteo Croce X-Patchwork-Id: 12250979 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4FFA6C433ED for ; Tue, 11 May 2021 13:32:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1ACA161621 for ; Tue, 11 May 2021 13:32:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231379AbhEKNdt (ORCPT ); Tue, 11 May 2021 09:33:49 -0400 Received: from mail-ed1-f41.google.com ([209.85.208.41]:35479 "EHLO mail-ed1-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231329AbhEKNdX (ORCPT ); Tue, 11 May 2021 09:33:23 -0400 Received: by mail-ed1-f41.google.com with SMTP id di13so22888235edb.2; Tue, 11 May 2021 06:32:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SA9lohQYxhGLdlQ+KBA3mdh85O1OGBRy/S/batCNgmQ=; b=KJcqAO5oBfJEuoFhE/CiYlX3wsNkD8PMHS8C5SxAzHontQWvBQpUeHrfDxgTMSbbDM CIyujnobiqMCxfzKswtmpfAnkCkYEqgg1PPOSXKqbuIwpd4NPqEeb0nebvHJfnjK/+5I 0Q07xqhaDjSrFfyJ0NYkImpSyidicEGTqK6CKwTDsk790+4+0n8aUxO5XngvqXx44Z43 4q6C9V7Gnx9F990ywijqq4w+fVqXEDlmh3fHABEgUSrZvzQGh3wGxpecXyRXaOhvKWip Qi2UwW8cMFQVko1RytikUaOwQRNDhzK4OPqwbt3YGb6F4NYoNp9ul95+lkelR3n/Wvhd B63A== X-Gm-Message-State: AOAM530+dVFCJp2IXta1Bw0ZnkpV3Z8r4vxUR8zcxM581Rh9Li4Qwxez bbl4+2cj0wq++V1IDxtW2GL97asKBqOJLgdC X-Google-Smtp-Source: ABdhPJxx3fKxANo5sv/PCWfn142ozELfU67r+XZZvcGfUaXMNo9pyYtX4mXtzM+4roaGwdm2L6cSpw== X-Received: by 2002:a05:6402:8d3:: with SMTP id d19mr36146321edz.302.1620739932378; Tue, 11 May 2021 06:32:12 -0700 (PDT) Received: from msft-t490s.teknoraver.net (net-5-94-253-60.cust.vodafonedsl.it. [5.94.253.60]) by smtp.gmail.com with ESMTPSA id b12sm14577136eds.23.2021.05.11.06.32.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 May 2021 06:32:11 -0700 (PDT) From: Matteo Croce To: netdev@vger.kernel.org, linux-mm@kvack.org Cc: 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 , Jonathan Lemon , Alexander Lobakin , Cong Wang , wenxu , Kevin Hao , 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, Matthew Wilcox , Eric Dumazet , David Ahern , Lorenzo Bianconi , Saeed Mahameed , Andrew Lunn , Paolo Abeni , Sven Auhagen Subject: [PATCH net-next v4 1/4] mm: add a signature in struct page Date: Tue, 11 May 2021 15:31:15 +0200 Message-Id: <20210511133118.15012-2-mcroce@linux.microsoft.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511133118.15012-1-mcroce@linux.microsoft.com> References: <20210511133118.15012-1-mcroce@linux.microsoft.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Matteo Croce This is needed by the page_pool to avoid recycling a page not allocated via page_pool. Signed-off-by: Matteo Croce Signed-off-by: Matthew Wilcox (Oracle) --- 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 5aacc1c10a45..77c04210e474 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -101,6 +101,7 @@ struct page { * 32-bit architectures. */ unsigned long dma_addr[2]; + unsigned long signature; }; struct { /* slab, slob and slub */ union { diff --git a/include/net/page_pool.h b/include/net/page_pool.h index b4b6de909c93..9814e36becc1 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; struct page *cache[PP_ALLOC_CACHE_SIZE]; diff --git a/net/core/page_pool.c b/net/core/page_pool.c index 3c4c4c7a0402..2e5e2b8c3a02 100644 --- a/net/core/page_pool.c +++ b/net/core/page_pool.c @@ -221,6 +221,8 @@ static struct page *__page_pool_alloc_page_order(struct page_pool *pool, return NULL; } + page->signature = PP_SIGNATURE; + /* Track how many pages are held 'in-flight' */ pool->pages_state_hold_cnt++; trace_page_pool_state_hold(pool, page, pool->pages_state_hold_cnt); @@ -341,6 +343,8 @@ void page_pool_release_page(struct page_pool *pool, struct page *page) DMA_ATTR_SKIP_CPU_SYNC); page_pool_set_dma_addr(page, 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. */