From patchwork Wed Jan 11 04:22:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 13095978 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 C9A70C5479D for ; Wed, 11 Jan 2023 04:22:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F28BE8E0005; Tue, 10 Jan 2023 23:22:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F102F8E0003; Tue, 10 Jan 2023 23:22:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DD6D98E0002; Tue, 10 Jan 2023 23:22:13 -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 CF27D8E0001 for ; Tue, 10 Jan 2023 23:22:13 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 9C1D1A0651 for ; Wed, 11 Jan 2023 04:22:13 +0000 (UTC) X-FDA: 80341220946.24.A4BE38F Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf03.hostedemail.com (Postfix) with ESMTP id 32A7320002 for ; Wed, 11 Jan 2023 04:22:11 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=LU13WSn3; dmarc=none; spf=none (imf03.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org 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=QoaAG2kAgAPkNcCiK7t3f4EkfcuvVTfPdM/eyK8Bayk=; b=N6aOp1CE0wp/qhU2DRzFX4UsaK97XKmCiMt79y06YpS8B7vsOAfDZUAL7g/92xDfr6+6wO 3vw2IgFtvTeLc/cbMrpkIkMwlMSdpu72fojWjrQ6BS0KeRuilBvEIfJwBlpH2dHjb+7ls/ tbGKVC0X+rFdTSZ/zLFusk/yF8z2NHY= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=LU13WSn3; dmarc=none; spf=none (imf03.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673410932; a=rsa-sha256; cv=none; b=hf3p3DQIToOH0Q1iNHKUnJcRhoz9Pjh+vMXR4/Wdg5oTNnzFKN5+SQo2ouY4xyiazehtnK f38cfYrxNGNwkyq1jIyLaDFqAytNklDk7PrQ5fsPs154i7EsOYM/YzYpOHGuoj9yvewtPn wRpb/0e6cpjo6ZbDQuVtEU+bnc51d74= 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=QoaAG2kAgAPkNcCiK7t3f4EkfcuvVTfPdM/eyK8Bayk=; b=LU13WSn36J9OyqWY+IaUSE1Z1a Wievx5eQ/zQzEuLLnrGjXadW9SAJKWjA/DuQQCaUb3MVIhvqejVrFFFhudRXk4fXO2VNATzrniZA9 a0Sjzs/o5e7HT8brbzoy9sYz75dwKQtKY0M9RywnOjCKFqTpe2voPwqa61J9NGOLiBTFDikR82UIO 8lzQRpz4gCh1sA6sany3BfM5AZSwYjpoX7lUeRLHaVvuj3tVCE6olVaWGA/Hj/N0OG8NcUcjR8b4N +B5yIlhOzDqUlINl/7yiVNKasqCb57RkNbj59aBCO7UQNaRPgwRcbGiIPTax2VE1kKtCS8sdoaEWL IqPDGWXg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pFSd0-003nz7-A7; Wed, 11 Jan 2023 04:22:18 +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 23/26] net: Add support for netmem in skb_frag Date: Wed, 11 Jan 2023 04:22:11 +0000 Message-Id: <20230111042214.907030-24-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-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 32A7320002 X-Stat-Signature: 7ns3tz4585jbgfxcnj89qqmxedrp8qgg X-HE-Tag: 1673410931-681096 X-HE-Meta: U2FsdGVkX1++h/673pgoQHOHMlamhnVKaYZ9Nu+jOPEqcBhLLu71tIox8uEPyLjDRRAxCA8h/fctDoheoJ940a+hDSdg7BIfhm/DwLBgk4n0Zqhoe4vyYfeZjFxuLpXllfDwlg/TbCvzsPvRYb376vgHdeLW9eYvyE6WAWKaImWmRgN4UHPkfMXPdnR+IunNWfUBXReDu/E0btNXsruCTkpkLbpBUpnrzvKk6ydj2yMm6Z3wNBPzpQEXkIZ8/BnLIJtq8GJDsW0B6wYv4t/hZH14H2xO1xMA04S3v6GU6afdo+LzhXdJyYUrW76xFKVedbtMuX4bkP/VNsP5kByN3U3eniMirrk2jNX8DGC9xBeevhhZP3UZI4k2FYJWYxC/0UtaKxc7M4fGeNO3W3wyU4jDv2MOwzGKjtE9k1Z9d+JqGpG9ponZB/4EchUGrNsDy84kh6jBM78e+oqE23qX6Or833/9CZTsAnPaTgaOltfCPan1pt94DeRz6kP+PuuJkPYT4gRtPLQTU/t0dA/zIRHIAfvEnC4nUdnYfuFw2gPHOJBTHBu916S3HG85GAbsFkuFojnHxOn9tXQsPBzgGFQwAX4bTQK6uZdmqXkzWwNkgSXo3/KFl5PeMy0Cb5dEv6XAGAMiUMBD2h+2xYR/wc6PsOTKMY1Fk9wwR1yHs4i/BmSriyPxcK75Jq/GUejtuAzJQhsFrC45UkpueRb9Au8lcn64Vvb6onMh3g2H3MqigYd3zuwAuLUeh1V9Wx6cNjldCz4Bm3mNyjbDlqtsFgF8H2LPVgfZvXuN3b8hljPVg9A5IE6GUaXLXux/Vzy7vwPgUM3FKJ1lkYVdF/lqK5TT8mn3Kf5I5nLfThtD/j9ianL4wEVFKOut6C5f60C9sp1/hxcg2UdHbKSTEWb1CTp7k9tMs6TGNvIoFE6m4yiTA7pSOollkA== 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: Allow drivers to add netmem to skbs & retrieve them again. If the VM_BUG_ON triggers, we can add a call to compound_head() either in this function or in page_netmem(). Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Jesse Brandeburg --- include/linux/skbuff.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 4c8492401a10..4b04240385cc 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -3346,6 +3346,12 @@ static inline struct page *skb_frag_page(const skb_frag_t *frag) return frag->bv_page; } +static inline struct netmem *skb_frag_netmem(const skb_frag_t *frag) +{ + VM_BUG_ON_PAGE(PageTail(frag->bv_page), frag->bv_page); + return page_netmem(frag->bv_page); +} + /** * __skb_frag_ref - take an addition reference on a paged fragment. * @frag: the paged fragment @@ -3454,6 +3460,11 @@ static inline void __skb_frag_set_page(skb_frag_t *frag, struct page *page) frag->bv_page = page; } +static inline void __skb_frag_set_netmem(skb_frag_t *frag, struct netmem *nmem) +{ + __skb_frag_set_page(frag, netmem_page(nmem)); +} + /** * skb_frag_set_page - sets the page contained in a paged fragment of an skb * @skb: the buffer