From patchwork Mon May 22 12:11:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13250295 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 A89B2C77B73 for ; Mon, 22 May 2023 12:11:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4324D900004; Mon, 22 May 2023 08:11:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3B9E8900002; Mon, 22 May 2023 08:11:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 16ED9900004; Mon, 22 May 2023 08:11:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id EFB1B900002 for ; Mon, 22 May 2023 08:11:43 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id B86FDADB30 for ; Mon, 22 May 2023 12:11:43 +0000 (UTC) X-FDA: 80817776886.15.4826DD2 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf20.hostedemail.com (Postfix) with ESMTP id D478C1C000B for ; Mon, 22 May 2023 12:11:41 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="fBY/C8Hp"; spf=pass (imf20.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684757501; 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=dMBJPtbzh4IjFjJ1HeY2h7yLKLc/0VkfcRg1OdFJq1c=; b=wKDEj9/Mra4hHhncihWdW6d8P3DmA4m8zytqdNIYoDIVZsJd2ISo2eOrbvCLVKAZlb8QrJ a9HBCWl9z4StRWouFDcUtnS+TSWfMwB2mToIaF/YtqEclr17KYR3yZU/GMEKrwgJ7a1v+x BVoyE83++ldlXhGQGhJvcbi4ZcAeN4U= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="fBY/C8Hp"; spf=pass (imf20.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684757501; a=rsa-sha256; cv=none; b=VOLgjHrjtyIxn+BdZgG3WExBxEuHXWyOuyu4iVKRrn8lYpjNvQvliyMyLvGt8DOQUl4giU L8m3OVgibpktfXOeBfHHE1g/4N90marmlmc/gBvIoE65p+kMju5d64PMsyTNvf2HwE7Aws 3JADryXPtdUkZ50B8ZFg0SGWTLSJo20= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684757501; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dMBJPtbzh4IjFjJ1HeY2h7yLKLc/0VkfcRg1OdFJq1c=; b=fBY/C8HpOJeKnd5SWjguBlniacaIEyMUrRRiYZ5FMqGcVN0vwSOPPrTNt4clFp8K0BE9if HOx4KSGpybXeKylY4zzpUXJS2wv22VlC1A2za25IJVrB9cvQyg9EoNRYNmwB+qzdfzqew2 2AdlM3m/ewe86QV1pWRlg3Hs7BeXCKI= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-652-UlqM_PkRPIidB5yyeKr35w-1; Mon, 22 May 2023 08:11:37 -0400 X-MC-Unique: UlqM_PkRPIidB5yyeKr35w-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D8CBB3800E87; Mon, 22 May 2023 12:11:36 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.39.192.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5FD694F2DC5; Mon, 22 May 2023 12:11:34 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , Al Viro , Christoph Hellwig , Jens Axboe , Jeff Layton , Christian Brauner , Chuck Lever III , Linus Torvalds , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH net-next v10 02/16] net: Pass max frags into skb_append_pagefrags() Date: Mon, 22 May 2023 13:11:11 +0100 Message-Id: <20230522121125.2595254-3-dhowells@redhat.com> In-Reply-To: <20230522121125.2595254-1-dhowells@redhat.com> References: <20230522121125.2595254-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Rspamd-Queue-Id: D478C1C000B X-Rspam-User: X-Stat-Signature: 55pj6pyb1oan8g1mpdt9bay1k4pnouud X-Rspamd-Server: rspam01 X-HE-Tag: 1684757501-757049 X-HE-Meta: U2FsdGVkX1/u2dNOby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UL6lbxc46hTreWcpW3cFtGja9aT4bwGQ5lTKGyz4VHAzOCRQPpjT+GORGpgk2yU2uNEzahHKreCgz7jBFnb9D0G/nUp7hyIcsqHsynpjJitWu0Wpyx9qj3UcL1Jk7ZW0b031A5q8+4zUymxdVh5zIK+wUV/m4mHa/NM2Sdytuw9XqjzBAUCmsChcalEYDZBnR9oX/5NS7T5igLJOJhmwJtmMsV19Fc0bbVXIVJBOsqT42s4bXy6GiRaCRQpTUG/na7x+7TeWBcKd4l/pzQgCPQn9NoYBr6TUJgQPz+6RE90kjO52XudZQ0thvJXKCADJnG2E5wvbvLhpjFNJJCdzBtnRuCmL7TWBvYO+sZwS0g0HTMmRbbuslU2nn8YqKbGwwFOJA8oEqU05l5VNAHrPSihncaWlt0kGcDl36TD/iJIyyZR6VsJAFECfhY 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: Pass the maximum number of fragments into skb_append_pagefrags() rather than using MAX_SKB_FRAGS so that it can be used from code that wants to specify sysctl_max_skb_frags. Signed-off-by: David Howells cc: Eric Dumazet cc: "David S. Miller" cc: David Ahern cc: Jakub Kicinski cc: Paolo Abeni cc: Jens Axboe cc: Matthew Wilcox cc: netdev@vger.kernel.org --- include/linux/skbuff.h | 2 +- net/core/skbuff.c | 4 ++-- net/ipv4/ip_output.c | 3 ++- net/unix/af_unix.c | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 8cff3d817131..15011408c47c 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -1383,7 +1383,7 @@ static inline int skb_pad(struct sk_buff *skb, int pad) #define dev_kfree_skb(a) consume_skb(a) int skb_append_pagefrags(struct sk_buff *skb, struct page *page, - int offset, size_t size); + int offset, size_t size, size_t max_frags); struct skb_seq_state { __u32 lower_offset; diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 6724a84ebb09..7f53dcb26ad3 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -4188,13 +4188,13 @@ unsigned int skb_find_text(struct sk_buff *skb, unsigned int from, EXPORT_SYMBOL(skb_find_text); int skb_append_pagefrags(struct sk_buff *skb, struct page *page, - int offset, size_t size) + int offset, size_t size, size_t max_frags) { int i = skb_shinfo(skb)->nr_frags; if (skb_can_coalesce(skb, i, page, offset)) { skb_frag_size_add(&skb_shinfo(skb)->frags[i - 1], size); - } else if (i < MAX_SKB_FRAGS) { + } else if (i < max_frags) { skb_zcopy_downgrade_managed(skb); get_page(page); skb_fill_page_desc_noacc(skb, i, page, offset, size); diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c index 61892268e8a6..52fc840898d8 100644 --- a/net/ipv4/ip_output.c +++ b/net/ipv4/ip_output.c @@ -1450,7 +1450,8 @@ ssize_t ip_append_page(struct sock *sk, struct flowi4 *fl4, struct page *page, if (len > size) len = size; - if (skb_append_pagefrags(skb, page, offset, len)) { + if (skb_append_pagefrags(skb, page, offset, len, + MAX_SKB_FRAGS)) { err = -EMSGSIZE; goto error; } diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index cc695c9f09ec..dd55506b4632 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -2349,7 +2349,7 @@ static ssize_t unix_stream_sendpage(struct socket *socket, struct page *page, newskb = NULL; } - if (skb_append_pagefrags(skb, page, offset, size)) { + if (skb_append_pagefrags(skb, page, offset, size, MAX_SKB_FRAGS)) { tail = skb; goto alloc_skb; }