From patchwork Wed Nov 30 22:08:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13060510 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 DE81CC636F8 for ; Wed, 30 Nov 2022 22:08:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9EE736B007B; Wed, 30 Nov 2022 17:08:07 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 78D516B0078; Wed, 30 Nov 2022 17:08:07 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 173BF6B007D; Wed, 30 Nov 2022 17:08:07 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id EB1986B0080 for ; Wed, 30 Nov 2022 17:08:06 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id B83201203D5 for ; Wed, 30 Nov 2022 22:08:06 +0000 (UTC) X-FDA: 80191497372.21.04D7A7A Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf29.hostedemail.com (Postfix) with ESMTP id 54F5312001D for ; Wed, 30 Nov 2022 22:08:06 +0000 (UTC) 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=0pEHOtsVyrt2uy64MIziwQ+z4DkQ3BQz3gapa10bEAk=; b=FV9m59ZLLmonxbZodQwy/1V+DG sp5RKJnRn2xVXD954BBVMq6nItUlAlmCP6Th9l1yDzP2o4//MgKL4DoUx9tcIWtTQ1nCtGZujwx52 zd2sNnr+CPeXINX1ahXYO+Bv3OCtT6oQqPVADwluv8wTylDLVODSLC76+1OCWSwcMSazlyQwHRm/1 Q6Y4A34fJvpcn0oryqFccot8+5coDn049YKQJ6mdMyaMeOoHAmJ2Nych4sR5o8LJBhxxC1eKDcGx2 DONEpcngxIePq61eTw+xfjGq8CeoxKVlWe9Mbu0uXORFcT38R7v/Zl4CXCFXblIPF68rIZ75aXcIb fCWa+p7g==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1p0VFP-00FLWw-30; Wed, 30 Nov 2022 22:08:07 +0000 From: "Matthew Wilcox (Oracle)" To: Jesper Dangaard Brouer , Ilias Apalodimas Cc: "Matthew Wilcox (Oracle)" , netdev@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 23/24] net: Add support for netmem in skb_frag Date: Wed, 30 Nov 2022 22:08:02 +0000 Message-Id: <20221130220803.3657490-24-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20221130220803.3657490-1-willy@infradead.org> References: <20221130220803.3657490-1-willy@infradead.org> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1669846086; 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=0pEHOtsVyrt2uy64MIziwQ+z4DkQ3BQz3gapa10bEAk=; b=sUZ8RGYsETuBjVWpaD9QdY1ItRns8EtG2w8V3fniukimCYI94PMlENkKbrXwPAAB2eSQuO tzIXGvmv0O4qq1VD0bPZoxHHdq0HZ3rws8UmbxtGtgvegvlQGnSl1DG/5o/IyWBaonSADk NQUuTdBirr+gnz0feaEvd/wfGX/pnPE= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=FV9m59ZL; spf=none (imf29.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=1669846086; a=rsa-sha256; cv=none; b=WMlcvyGPONb4ZFuW9CK38P5N85jk09tB87+RWxRMGpebddLIsIO41JpB+4sR85shOCskd+ XZRFNEUuJSytHXKsFkdz+2zUOT6cUFSSzaNc6Shx7uAn6xPS1S+XND++MFyHnN3/LOZiPK j5UwRU4UXnVLJrEbrnQFfRi0iBypYXM= X-Stat-Signature: kwgegs8ure69c4sw9ahf3qqyh5xinxtf X-Rspamd-Queue-Id: 54F5312001D Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=FV9m59ZL; spf=none (imf29.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none X-Rspamd-Server: rspam06 X-Rspam-User: X-HE-Tag: 1669846086-288887 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) --- include/linux/skbuff.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 4e464a27adaf..dabfb392ca01 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -3345,6 +3345,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 @@ -3453,6 +3459,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