From patchwork Tue Apr 11 16:08:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13207811 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 EDDF7C76196 for ; Tue, 11 Apr 2023 16:09:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 92504900004; Tue, 11 Apr 2023 12:09:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 88613900002; Tue, 11 Apr 2023 12:09:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6D7AA900004; Tue, 11 Apr 2023 12:09:33 -0400 (EDT) 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 5CCBE900002 for ; Tue, 11 Apr 2023 12:09:33 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 31CBA160E86 for ; Tue, 11 Apr 2023 16:09:33 +0000 (UTC) X-FDA: 80669595426.25.2967E58 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf08.hostedemail.com (Postfix) with ESMTP id 74E76160006 for ; Tue, 11 Apr 2023 16:09:31 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="gwP5/Y9P"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf08.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1681229371; 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=yN2nDE+ENFPKsoCAxX3Et3Pc/YScpeBgJ5SXmU8JiBg=; b=Q2yjRBIweLTGRfLVqAUGRxVSoZJP0G1+MsvuGB7hqwFfEfLlVgWBUTsWyyIu3B8GUeGbPq pqkUqV1SPTN5awx6Ljb/Yh8Ab66KakA/XzaKX+I49uXc0wzVQjdG7fButuGfjmW0JVmTcz OrOvBID0KgUFlbJbXJSTif6MuWnh/UA= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="gwP5/Y9P"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf08.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1681229371; a=rsa-sha256; cv=none; b=4MIXqxL9Et5vPB/yJQ3CURWpDsjS52gbZpWUMOooaTChEEcyY9PQyqEm4WF1jsh527MT1q i/JiGdYC/R3PwWFbdeL9ybl6W/fAjC83icrbLDjjwfmd1KoSe/LnwbzSDwTr78HjcNXQlT DgcwfBs9FffFzd9Gu24zk9fw9c2NKtg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681229370; 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=yN2nDE+ENFPKsoCAxX3Et3Pc/YScpeBgJ5SXmU8JiBg=; b=gwP5/Y9Pm0GmKlyAEIGhxQMpy7kZLjFcxKvgEet8iEh8dJOa6eKIC4p4YFufLCct+oYG3B Zv1931ZBWEpqW2PMc7A0TwSeKtOgp8pJOlsYz5lt9AyeWxoTnhJbgHmp/KK5E1WlEgWhdL ZS3MdD7rTiyiyM8wN09SLaP7u1jDJA4= 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-673-JgBL6_p-OsWYijzjp0KjTQ-1; Tue, 11 Apr 2023 12:09:27 -0400 X-MC-Unique: JgBL6_p-OsWYijzjp0KjTQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3E43A185A7AC; Tue, 11 Apr 2023 16:09:26 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2233A40BC797; Tue, 11 Apr 2023 16:09:24 +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 v6 05/18] net: Pass max frags into skb_append_pagefrags() Date: Tue, 11 Apr 2023 17:08:49 +0100 Message-Id: <20230411160902.4134381-6-dhowells@redhat.com> In-Reply-To: <20230411160902.4134381-1-dhowells@redhat.com> References: <20230411160902.4134381-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Rspamd-Queue-Id: 74E76160006 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: 81qfb5bu9repe6mohspgn44ffc453c6n X-HE-Tag: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Sk/SuUA5xvZDByIAIF+bNWhc/7P6Rnw7wcJMUOjtt4gjfFqg/T48+v5M6aSc10wjclKpp3qRG2aOrSdPgPF+iA4kqeCyZiHIvcJ+3MAta0W2TAtE8+7h4nSOy/by0hn+WfeSrBl9ACCM/oasDrHwhVJbuuQIGD1E8rKuHY66WOFV/Fgz46NMGKTtvzAUkRrWja/wourISk0X07ppwXR51WifRiIg+rjHqWNixf2uRczCKjn//B8gWLux8pLKN4PgI+mzG6Dx/O2gsbiEnYBAPtckSb6qdRDxgcVyq3q/xhmNH4AXhOsoJ4bj83Ft0PCUyrJP2pA6s3Yua0K4y7ug24Zhjj14d7Z8vM2ZsiAzdEvQbqURbDZvRPNyX/tE2LKnJv3441Id7WXakg+NWd/bqXR77RaOM+81lQ3fk9qcX03bE5J1zghkgArjxn37hm+V7pshYCsdEX10VInMf+l68LVZqXFjTBA9so= 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 82511b2f61ea..6e508274d2a5 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -1364,7 +1364,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 3d05ed64b606..d96175f58ca4 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -4132,13 +4132,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 22a90a9392eb..bd002222cf2d 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 fb31e8a4409e..ea45dcc80232 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; }