From patchwork Thu May 18 11:34:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13246563 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 68B3CC77B7D for ; Thu, 18 May 2023 11:35:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 079D990000B; Thu, 18 May 2023 07:35:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 028C7900003; Thu, 18 May 2023 07:35:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E32EF90000B; Thu, 18 May 2023 07:35:21 -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 D620C900003 for ; Thu, 18 May 2023 07:35:21 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id B6293C0792 for ; Thu, 18 May 2023 11:35:21 +0000 (UTC) X-FDA: 80803170042.20.C578EB7 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf11.hostedemail.com (Postfix) with ESMTP id DBBF740012 for ; Thu, 18 May 2023 11:35:19 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="OaTwg/8N"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf11.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=1684409719; 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=Oms7mbQShTpY01zvjwYgDwHWlSZDYU/BDFTf+CWwguM=; b=f9jt4yuz5flfBa1vNuFvF0MHkP+MDAZrAsUY/P10cdqTkZjPAVCP4cJxsLw8acSaj/E1Pg t7LvBe5N6/4jo+IP9gmXekxmnxHtjgFchfevN0p5/jSFtRK59Pc3TNNb1zxSieFyIeoBph /1lYMMwx2e7avLUOYkmsNkAh35yphCY= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="OaTwg/8N"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf11.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=1684409719; a=rsa-sha256; cv=none; b=o0QQTgknSqegr0vJtdpyHasOskal0fYdalNdeS8Y/Ta7NhKhK0TKjs6prQvHsD4Z+FVaP8 Ag2gtnBAjSBZ9VjfRG33rk7gQ2B9sEXAkWl6bwtnJ962FB/UpsJgaKZly9nWTywFegYcfh Xcf0gHkgl6OyczkqloqXvhevWErMshU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684409718; 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=Oms7mbQShTpY01zvjwYgDwHWlSZDYU/BDFTf+CWwguM=; b=OaTwg/8N3CjytwKTtML90kMQBqjhUGI6T3UVofqrezkkBQkR6NqqGNEIoOk1hw2OLqiGoe W19iBVyHsaqB2wxqpzx1ibykZttzhai8p0AqRirwqlAvGZE41HMy8rhBcVxeQgJRX9EYan 0xKuCdhC4sq4hi+QkaDgC0VFMjAKsTk= 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-61-ELmJWgkyMLiJ2SkyRnHWsQ-1; Thu, 18 May 2023 07:35:13 -0400 X-MC-Unique: ELmJWgkyMLiJ2SkyRnHWsQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9157910146FC; Thu, 18 May 2023 11:35:12 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id AB5E214171C0; Thu, 18 May 2023 11:35:06 +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 v8 02/16] net: Pass max frags into skb_append_pagefrags() Date: Thu, 18 May 2023 12:34:39 +0100 Message-Id: <20230518113453.1350757-3-dhowells@redhat.com> In-Reply-To: <20230518113453.1350757-1-dhowells@redhat.com> References: <20230518113453.1350757-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Stat-Signature: nshtwogaxjsgopkfsemqoqysuwtce33a X-Rspam-User: X-Rspamd-Queue-Id: DBBF740012 X-Rspamd-Server: rspam07 X-HE-Tag: 1684409719-906254 X-HE-Meta: U2FsdGVkX1+EiAjjPpFXm1uRSAJWeZeSt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j3CEl7BGTAiGdwhhWoh9QP8dz8shSL5AXi/665hJzXJutiiounuvCKNufmJgUIizLpQNcOhKpkQVOPfXQvvc/u5tfJhSjxKl93Tht02TIbKEX+amMyxACHG65Bi5TmPSD9jAw1agSAA+Ufxnoita29d50r9AcWO9q8ibHGKjgFTHHcWocg1p0CWtPgPpjIBhNCf/S5kU7oV1MkPreVkc42+nPluqrq9pOu/CUE7SBdS0J6wKEVt+374Cpffl9i19UWy2W3rf845ddyUSdYbYOQPxBt/xrKuIIdehJNMhfxKgSUMHOr7e7dCmf2pDsUGOlmytKbyF8Lbf7AUQ1H+wrUYRc9XkVCgh7ubRuJXoXeLpzLyDb12ufWiRL9TxPvFpWmq+c764tHvbqxLUV6kqv0xncVb6pQ0bbj 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 00e8c435fa1a..4c0ad48e38ca 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; }