From patchwork Wed Jan 11 04:22:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13095986 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4BE2C46467 for ; Wed, 11 Jan 2023 04:22:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 81CEA8E000A; Tue, 10 Jan 2023 23:22:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E999E900006; Tue, 10 Jan 2023 23:22:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C50028E000A; Tue, 10 Jan 2023 23:22:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 409D98E0002 for ; Tue, 10 Jan 2023 23:22:14 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 1C89D160306 for ; Wed, 11 Jan 2023 04:22:14 +0000 (UTC) X-FDA: 80341220988.21.36CD513 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf25.hostedemail.com (Postfix) with ESMTP id 89EA3A0006 for ; Wed, 11 Jan 2023 04:22:11 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=apyePiHK; spf=none (imf25.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1673410932; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=OBSzJ4w2B3aAKm7QVu3HQC5r9WPsQ9tzpI4Tb+ORw1s=; b=ebnsdrGJrqX8BUm6rlVmLFkmUKWaBvEyfMlflprjCPDi/91qul++bJHYPYBvLGdq11SGae uBGgj+HWg12jB7hI8b4bkYzBk+pzhsgw5MWai5MhHghr9cNQ+B1ddGD+dgUXC1L7hVEoYE EH0bpUqyBQliLblDjYlX1gjel4/YC44= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=apyePiHK; spf=none (imf25.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673410932; a=rsa-sha256; cv=none; b=P4dQTqaP/euXPmW305OkuAjCfociEUodiK8109KFMFu64HKZv1fsJYC/rGZSEr/e+w2k0v Fb1cZGMLWqceNXtsAv0fcN/ygpOXDQMCZw2wsOCeZ9UdrfJZ69TP0ubtEgXAa5Ejzke+gy 7243pWLCQ4vKPxfKdTmvP9vUh8Pkvhg= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=OBSzJ4w2B3aAKm7QVu3HQC5r9WPsQ9tzpI4Tb+ORw1s=; b=apyePiHKvq7zkmyHZHbTbkIw08 zviH/7IF8Gu1CbA8dLQus5zZBliFQeGyNSnZrXlbNolxI7/5e62h+9aMzcG7EsPpOX7JHHjc0NVGd PaeT2MKZ9IuVQZFV/KChBa4pRZUvBuL0OM4XFJoo2ali4CNO+yeohlS8ctbVEexcA68hcyzU1xUM2 QxeVzRC5R+t70nhfwwxT3pikwvstwykKVGItH9qC5WrXYfLrNsCrEGxgdUc56E3JrB/TVoSCW5UEU LT/f6JregHr6grPzcjNbj3smDAs+cp9shiepYEzghoacuOWVbicHqfSU20TErjXAE5zyekug1FmPn FlyTpmfw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pFScz-003nyc-Lx; Wed, 11 Jan 2023 04:22:17 +0000 From: "Matthew Wilcox (Oracle)" To: Jesper Dangaard Brouer , Ilias Apalodimas Cc: "Matthew Wilcox (Oracle)" , netdev@vger.kernel.org, linux-mm@kvack.org, Shakeel Butt , Jesse Brandeburg Subject: [PATCH v3 18/26] page_pool: Allow page_pool_recycle_direct() to take a netmem or a page Date: Wed, 11 Jan 2023 04:22:06 +0000 Message-Id: <20230111042214.907030-19-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230111042214.907030-1-willy@infradead.org> References: <20230111042214.907030-1-willy@infradead.org> MIME-Version: 1.0 X-Stat-Signature: s9zk4fg9hqj8r3je5noijgc31i4qaa13 X-Rspam-User: X-Rspamd-Queue-Id: 89EA3A0006 X-Rspamd-Server: rspam06 X-HE-Tag: 1673410931-753233 X-HE-Meta: U2FsdGVkX18vdG4S+yuUCiE1sJAY+QnMcEHW7uZH8IVTGzMU40/GuGdR1JkICbaCiPkue5EPwRb1XoVC/pqZjv7LDJs+oRrFNDvDx8ia3Ei7Qw1cfZZrOqVdn53t/jVOV+BMJJJ58pV+p/NuGLAEENU17fGMiSeuDiSHbjkrHUTgniLronTX+awBjnnaDtugpzQjDqzgo2rpPrbuCrOLqgCvU3QfCKE/A26+FxdsGW/ziZOsAtWYRyCwdx3xmzJXiyWmyy0VxilorexJli4qgex+hkTljtVd21GSPSKAHvwGWhlkPHJNRzux+AYsk6yDlviw8VWPXrxQznXCpl2YbvMMS9IlTyn2EB4870Wkgf9V/22fF7pPhrpo16YJsw5w0mhnprt9LDU5rD8+Hi8eMIVbR8G4MxmqTscbO6/TjzDyKOIZ5tvBBsHSy560WY49dJiYi4N1CbGEFyBCU0ozowAr8DQ7WzEyKvdPHeia4Ql3ShNijahd75zDwjwkyw/tYiNCnhYC7CPriJsnKn+wcxlZFCzAcwXRlKQim6hu+EjzFiJJlu8xJoosPn31hwL1iwY22bv0KlNTFMpDSTOq5oDR/vbjfN1GkewzKhTYlxA2iAQ7x6wcUtI5wdw/zxBS7lmdofwxn6Pz7L2QQKIMkHIDbiXFdRKC3x6PKf3La+J12CHyvGyztZK1WiBWWwiiaIUG5D3CvEdOQIjhTBvsMYkVNV2RzCUWjl5lFt5KwWNBq2oT1Z7MkE86p6iFVXXgHyABxP9supUBaToMKAhw7LThVZTXV4kpFBZnVrQdHMPCcwO+lttOpf6KFTBNRuKE9nOS9LO9XJRj+DBb4g7Xsn9QA4346vJWb1wxaYM0hKar1JaZ08no/vVaC2M/g+uj0vhraZV33yDEsaI/vJjbYT/gXTu7OLRG1xdRUK2fxQ2NvPXzhZtGng== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: With no better name for a variant of page_pool_recycle_direct() which takes a netmem instead of a page, use _Generic() to allow it to take either a page or a netmem argument. It's a bit ugly, but maybe not the worst alternative? Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Jesse Brandeburg Acked-by: Jesper Dangaard Brouer --- include/net/page_pool.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/include/net/page_pool.h b/include/net/page_pool.h index e205eaed21a5..64ac397dcd9f 100644 --- a/include/net/page_pool.h +++ b/include/net/page_pool.h @@ -482,12 +482,22 @@ static inline void page_pool_put_full_page(struct page_pool *pool, } /* Same as above but the caller must guarantee safe context. e.g NAPI */ -static inline void page_pool_recycle_direct(struct page_pool *pool, +static inline void __page_pool_recycle_direct(struct page_pool *pool, + struct netmem *nmem) +{ + page_pool_put_full_netmem(pool, nmem, true); +} + +static inline void __page_pool_recycle_page_direct(struct page_pool *pool, struct page *page) { - page_pool_put_full_page(pool, page, true); + page_pool_put_full_netmem(pool, page_netmem(page), true); } +#define page_pool_recycle_direct(pool, mem) _Generic((mem), \ + struct netmem *: __page_pool_recycle_direct(pool, (struct netmem *)mem), \ + struct page *: __page_pool_recycle_page_direct(pool, (struct page *)mem)) + #define PAGE_POOL_DMA_USE_PP_FRAG_COUNT \ (sizeof(dma_addr_t) > sizeof(unsigned long))