From patchwork Thu Mar 11 19:42:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matteo Croce X-Patchwork-Id: 12132797 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=unavailable 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 2FA5CC433E0 for ; Thu, 11 Mar 2021 19:45:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E121264F7D for ; Thu, 11 Mar 2021 19:45:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230363AbhCKTox (ORCPT ); Thu, 11 Mar 2021 14:44:53 -0500 Received: from mail-ed1-f45.google.com ([209.85.208.45]:33392 "EHLO mail-ed1-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229468AbhCKTop (ORCPT ); Thu, 11 Mar 2021 14:44:45 -0500 Received: by mail-ed1-f45.google.com with SMTP id w18so4604585edc.0; Thu, 11 Mar 2021 11:44:44 -0800 (PST) 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=DWBxv9mwIlByZiQqIZk+iqgg+9i0Rl2rKMKfAz4j0UU=; b=GbP4HPaED+vL9CBa9J2ICuHwbcMsawLurHACP8tPu97/U+BDANOv35jVRbtXEiVGEq pr0Zz2T+iyVkkJc/TElgbjdBRfw79fsPecEhTp2vSkx71qDZ8HprTQ2ahE7zs55da8GE mgLH8FFkhBKAom3j+bpbvNPNm/qflL3SYksYh1cZoAENj/BaZPVpi+1eqSWHd5DmJxc7 O3AWjPwYq+2cl/wq2NEqQZjL48YVm86GIDcWN0HkbdJhrROqbc0VPhZKt/INNkB5bXGb TLLqasFPtO7XcvFUd0FNQjdbKKNIl0rQKdbrqxcjKS4WneleDtQ8Xn9dyfjXOG7ezcOL OFmA== X-Gm-Message-State: AOAM532WTz+sjly3oyx66jHXSUaB1SiOYFsrLS8kjAc6WabdATK6uch1 9MTxZl/fdb4kHQ7cddopzRTwkGBbTyE= X-Google-Smtp-Source: ABdhPJz/PbHJ5l5YDixdyLXgqrrRs7TRJoBF869Rz1VS0P1XiSdvg24p0p9d0HEH4APEjaIlsjvCzg== X-Received: by 2002:a05:6402:1c86:: with SMTP id cy6mr10025404edb.276.1615491884378; Thu, 11 Mar 2021 11:44:44 -0800 (PST) Received: from msft-t490s.teknoraver.net (net-188-216-41-250.cust.vodafonedsl.it. [188.216.41.250]) by smtp.gmail.com with ESMTPSA id t16sm1875652edi.60.2021.03.11.11.44.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Mar 2021 11:44:43 -0800 (PST) From: Matteo Croce To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Jonathan Lemon , "David S. Miller" , Ilias Apalodimas , Jesper Dangaard Brouer , Lorenzo Bianconi , Saeed Mahameed Subject: [RFC net-next 2/6] mm: add a signature in struct page Date: Thu, 11 Mar 2021 20:42:52 +0100 Message-Id: <20210311194256.53706-3-mcroce@linux.microsoft.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210311194256.53706-1-mcroce@linux.microsoft.com> References: <20210311194256.53706-1-mcroce@linux.microsoft.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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 --- 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 0974ad501a47..67caade433e4 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -100,6 +100,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. */