From patchwork Thu May 18 13:06:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13246751 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 0B05CC7EE22 for ; Thu, 18 May 2023 13:08:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 675DA900005; Thu, 18 May 2023 09:08:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 624CF900003; Thu, 18 May 2023 09:08:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4ED25900005; Thu, 18 May 2023 09:08:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 3B4E4900003 for ; Thu, 18 May 2023 09:08:05 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id B816940854 for ; Thu, 18 May 2023 13:08:04 +0000 (UTC) X-FDA: 80803403688.18.C858155 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf18.hostedemail.com (Postfix) with ESMTP id 1E07C1C00B1 for ; Thu, 18 May 2023 13:07:36 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Hx88Nxda; spf=pass (imf18.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.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=1684415257; 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=JMGUgrBHHr2QLtHsSrbZ7HRTmtrdq4le75g2XYAZGim+TJCOUFLwWyCWbwCECFZbbKb8uJ SvUQb8gOFZ97KmBpx613blnX6KimIwOgcFAGXmcGAbDyQCPv4w/Eek4gd+xDzJaQvj9dJ9 3gx9uWmMzpNGJ20PywoGt2Ms08c+Xzo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684415257; a=rsa-sha256; cv=none; b=ddiBFewtDkXD/NQz6rhavDldi/DkD9NOCw/8p6gaIuP/QQ9rm7fOIYwtGDJ7HXB5uJl2xD tds1ZCZWaUhQj/rshbGslc1kfP46THYsLf3VlZ9DBsqtq8WMquooRMc+QvvvSSXgZGcTd7 t02x1YyJ2ci56HR01aOSs1Bcz1nq400= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Hx88Nxda; spf=pass (imf18.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684415256; 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=Hx88NxdaD04TwGu/y130Lm+6O8HY8kfNc02NPnQvbEP/KCcMuzj77mUTqQlQ49oiW9Zkci 2uIgijDFsegjAi0jSTEUB+84/K+92hpIA3jtgLcMMpJyITh82CulHW3efgxavJbo21RakD s/AwHEdvGqYXuTiaAz8AD9fpgc7p7L4= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-659-VyatmphiPrqaOCvVPK9LmQ-1; Thu, 18 May 2023 09:07:29 -0400 X-MC-Unique: VyatmphiPrqaOCvVPK9LmQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D8A64185A7A4; Thu, 18 May 2023 13:07:28 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3AAD02026DFD; Thu, 18 May 2023 13:07:25 +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 v9 02/16] net: Pass max frags into skb_append_pagefrags() Date: Thu, 18 May 2023 14:06:59 +0100 Message-Id: <20230518130713.1515729-3-dhowells@redhat.com> In-Reply-To: <20230518130713.1515729-1-dhowells@redhat.com> References: <20230518130713.1515729-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Rspamd-Queue-Id: 1E07C1C00B1 X-Stat-Signature: zu8f1f9q7xqeyyhdi5grmz6nofuz511e X-Rspam-User: X-Rspamd-Server: rspam09 X-HE-Tag: 1684415256-154934 X-HE-Meta: U2FsdGVkX18sr+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ugitZW9V9jjng1GcRe0+w9LKuW4P9WaLsEg4Y4Ke0gkSYIN9gCX7FJgC+EuxFcogdllKlYWD7yNb7gCrdJJ+mJw/YdRt6IYZFesxD86PgDQr+X2s8AeLEeGi9OjL1up2veaf2kXvdkABYi7XRUiXT6Wm/WVO7idClVNvNlGhDE1JjRo4KVNvVaGMAxIABcBJZvi64r5Vm2yMkP3AQ7evIZiqaqIsHK/3q2CyxGJ8q7aNWC9VpLpUq/GIdZjVoX7A9xDmbzIcRB/Fufb3iRl+MFp+uOOwL2rJY+trsZ1UnT6vLUEN7bkmGuqnbed5S8SCZartGCI6sUYZNB8XS8vz3unnkig9D7ZEn7DPoUewUV+E1khu+X+WChtc3pBhzQrUt6r1D9Q7jchwU5khC3RY2iTWpnliBi3iaDpfP7CI+ef2syTfZpoGDK7WOvGEa 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; }