From patchwork Fri Jun 16 16:12:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13282933 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 B06D3EB64D7 for ; Fri, 16 Jun 2023 16:13:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DF54F8E0002; Fri, 16 Jun 2023 12:13:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DA3C98E0001; Fri, 16 Jun 2023 12:13:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C43F08E0002; Fri, 16 Jun 2023 12:13:16 -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 B46F68E0001 for ; Fri, 16 Jun 2023 12:13:16 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 7E6E380637 for ; Fri, 16 Jun 2023 16:13:16 +0000 (UTC) X-FDA: 80909105592.03.558B69E Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf03.hostedemail.com (Postfix) with ESMTP id AAA5E20017 for ; Fri, 16 Jun 2023 16:13:14 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="XBMHL/bm"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf03.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=1686931994; 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=QLiOARcSP/G9NfcLRlp5hvrHkmLQeF8H+vWuq3j9CzM=; b=c+pTreSuDwQofhD7IvP7S+LmPAWilK1Ok58NVVx4mggjZD9BH4AjvNa5OZEYveReoJkSO2 eh7MoWPGsEwi0c0/frXH2xWNRhENXELGjzW+gMtAXTnUErQAWxYiRkgTNSWXgibamJsWrS sWjoEnrsrZ1AdFk1PMGexBEANcVjjPE= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="XBMHL/bm"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf03.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=1686931994; a=rsa-sha256; cv=none; b=YsJH/spV9T/O0l8UCYkIJZBhNgYXzMdBl94r9Vs9rVzCkhm5ukQYY/IcCeo8TrbnGvo3jL aVBc1eqDKhlLhVYbHd2zXaMYXmSyra/CmUS4elZShNGvgHsitG1sBfD+0mn0DSGtXynn9u +Qwub0r6PNVhr9VhlCUyBX0ryJRAQtA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686931994; 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=QLiOARcSP/G9NfcLRlp5hvrHkmLQeF8H+vWuq3j9CzM=; b=XBMHL/bmK3JPbKUakPdgxOnH1nr1HOI6hw6L3O1Rdb20IwZNDb/2Xv2Ek2TWTiB7Sqvxxs fq/6PTsZCYh9+a6Z0MRySNWpdH8pTlfHD1ALQyQFWl/Uo7cH3CvwE2gG0asadYqFepBdtn 84qIjY8tJnOuMi5s0cLYZOjwuZywDWU= 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-463-UkTLdvphMoig0DrcTgcXEg-1; Fri, 16 Jun 2023 12:13:10 -0400 X-MC-Unique: UkTLdvphMoig0DrcTgcXEg-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 ECA63185A78B; Fri, 16 Jun 2023 16:13:09 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id D38ED2026D49; Fri, 16 Jun 2023 16:13:07 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Alexander Duyck , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , Jens Axboe , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Menglong Dong Subject: [PATCH net-next 01/17] net: Copy slab data for sendmsg(MSG_SPLICE_PAGES) Date: Fri, 16 Jun 2023 17:12:44 +0100 Message-ID: <20230616161301.622169-2-dhowells@redhat.com> In-Reply-To: <20230616161301.622169-1-dhowells@redhat.com> References: <20230616161301.622169-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: AAA5E20017 X-Stat-Signature: azzyf6xtrjsu1uznz3a1738akk373c6k X-HE-Tag: 1686931994-667556 X-HE-Meta: U2FsdGVkX1+aUUze4jLm6P5ShiyNGSSkHyT3nfkhZLwdn695g0Z9F9VG4ROXMhnGF5bq0QYVvU1Fw81zuUIjJU6iomhAE0jcEuQRlV73Maz/9X3GiPWDc06AB4kMnAfurlE6uXwJQAPbNDl3pSyavzZLQypF5ZRRwXxpvsePfzftcLf934yy4Qz/PhuSIihtU7M+iiMZgegqFIdQhXcH4INRmZZBDJJbRFvNB99MaaH0OwSwxWxd5YpyMtT7+nm7Tx0unTPqfPghsoc2HdkUCfrJY69W+L7WZLDVVUNXNte4ltW7SUixSa85gnsnazyD1mr+XjU30dZvicVDlIb2uJh81XZsnwmFKQom1speQxhKnIYm7Q9L0uyb9Nyo7JKqVBpsqenl//5WHnp4dHXBCVm9y9qWRrPK7Jzzcoj12vuT4jE2jNEMwXPvch0mr1ZY2gvNWQn+TwbcwZu6/0TIexf0KX+GqL2f1hNtumEtrBGZsBRfQ36CP/xSikscaUtcQz4HKMEVMPeQ6NF1iTBQJ7p6mzecQfWkcJqcVwydJOfS3g/HUeerYU+yAd7Cur/Mbp7jGGRbUlda5VBWmspv8QjmiZqQG8DShaV37x8eb5mkuf9EOkVSsfNT9+RvPTtoFMLfBsmgrApY3fpNEfoEKfY421b3qx2TsUtHSlL8lvjsHEeBfN3hXT/gMs2hKC9Zft7NKCKc0WSKDR7YGUbQ4tAx1smdMDTPfeY29FqRZ8AaYWCQkSa+fMg5skw5yY7pYm1jTKRv/9fcueloTNMty/WV0QyqaakFKnVZ9DGUEaHEB2dvwRGhH3aXDwWIys7Dx7cEyQjf4EJzIZzZqbS3BqagUlgXdl6yREaGry3I+bvJYot1XEnpUFS4KU5GbxfLAGulszkS/fVy8fKEM+yTRrSAuUWRyf+bgm3BCITj0CokdBF2W8HvXIWXPrlRWVP2HeTchiDSaQJ+kl9HrWA 7JthK+QB c8Gl74obqZUwerO4rfWzG9BdRhtz2kMBkiRy8r4uNRPm5Y8WuMYnY9Db1MJioHmyDqnzK6RDYpMgpkOTLQFHcBXZzm6x/P6GjigywQOAFJq+RpAfq4Onz8qpQ27GmAmq8Gj3awVqV2i/7IzxLoSJFvskCW6r1l/t6qrdHYq8gFI4TOFIv+clWzpJU7cPGe7vYgGgTvBLBcy5pgWzH/mDAUscq8udyBn+9mYKVYjnbgTU+T9MF3zB2hIKVv6gUJrsQzJS+ffa5+n8UpOywkl94HExtor9L4Uwr4oF69y90PEWcWpInuyocc85xLqaAN8xmFKtLVQc/NOWtUrobNDXN+9bbpRge/P/R2d14M6jb+ma87+qPwm16h1egmSkJ9xLKJ3QwozwueGjqjToYZulqSjowvDEoE/BrMNNtEwr8+oAImCFO2hjeGLBDvW9p5YRs67mHoFrdtxMnQdkk/E/edOpKI8qdrwH8czZgscgpo2QCkpS9BsWYlVOu03x9169TWVJjhvo6USgPCc38cU4OAV89wCDLP5BeHjNY5ibQPt0H2jPLodmpYFprv3NogaciPwvDjystvln9FPM= 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: If sendmsg() is passed MSG_SPLICE_PAGES and is given a buffer that contains some data that's resident in the slab, copy it rather than returning EIO. This can be made use of by a number of drivers in the kernel, including: iwarp, ceph/rds, dlm, nvme, ocfs2, drdb. It could also be used by iscsi, rxrpc, sunrpc, cifs and probably others. skb_splice_from_iter() is given it's own fragment allocator as page_frag_alloc_align() can't be used because it does no locking to prevent parallel callers from racing. alloc_skb_frag() uses a separate folio for each cpu and locks to the cpu whilst allocating, reenabling cpu migration around folio allocation. This could allocate a whole page instead for each fragment to be copied, as alloc_skb_with_frags() would do instead, but that would waste a lot of space (most of the fragments look like they're going to be small). This allows an entire message that consists of, say, a protocol header or two, a number of pages of data and a protocol footer to be sent using a single call to sock_sendmsg(). The callers could be made to copy the data into fragments before calling sendmsg(), but that then penalises them if MSG_SPLICE_PAGES gets ignored. Signed-off-by: David Howells cc: Alexander Duyck cc: Eric Dumazet cc: "David S. Miller" cc: David Ahern cc: Jakub Kicinski cc: Paolo Abeni cc: Jens Axboe cc: Matthew Wilcox cc: Menglong Dong cc: netdev@vger.kernel.org --- include/linux/skbuff.h | 5 ++ net/core/skbuff.c | 172 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 174 insertions(+), 3 deletions(-) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 91ed66952580..0ba776cd9be8 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -5037,6 +5037,11 @@ static inline void skb_mark_for_recycle(struct sk_buff *skb) #endif } +void *alloc_skb_frag(size_t fragsz, gfp_t gfp); +void *copy_skb_frag(const void *s, size_t len, gfp_t gfp); +ssize_t skb_splice_from_iter(struct sk_buff *skb, struct iov_iter *iter, + ssize_t maxsize, gfp_t gfp); + ssize_t skb_splice_from_iter(struct sk_buff *skb, struct iov_iter *iter, ssize_t maxsize, gfp_t gfp); diff --git a/net/core/skbuff.c b/net/core/skbuff.c index fee2b1c105fe..9bd8d6bf6c21 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -6755,6 +6755,146 @@ nodefer: __kfree_skb(skb); smp_call_function_single_async(cpu, &sd->defer_csd); } +struct skb_splice_frag_cache { + struct folio *folio; + void *virt; + unsigned int offset; + /* we maintain a pagecount bias, so that we dont dirty cache line + * containing page->_refcount every time we allocate a fragment. + */ + unsigned int pagecnt_bias; + bool pfmemalloc; +}; + +static DEFINE_PER_CPU(struct skb_splice_frag_cache, skb_splice_frag_cache); + +/** + * alloc_skb_frag - Allocate a page fragment for using in a socket + * @fragsz: The size of fragment required + * @gfp: Allocation flags + */ +void *alloc_skb_frag(size_t fragsz, gfp_t gfp) +{ + struct skb_splice_frag_cache *cache; + struct folio *folio, *spare = NULL; + size_t offset, fsize; + void *p; + + if (WARN_ON_ONCE(fragsz == 0)) + fragsz = 1; + + cache = get_cpu_ptr(&skb_splice_frag_cache); +reload: + folio = cache->folio; + offset = cache->offset; +try_again: + if (fragsz > offset) + goto insufficient_space; + + /* Make the allocation. */ + cache->pagecnt_bias--; + offset = ALIGN_DOWN(offset - fragsz, SMP_CACHE_BYTES); + cache->offset = offset; + p = cache->virt + offset; + put_cpu_ptr(skb_splice_frag_cache); + if (spare) + folio_put(spare); + return p; + +insufficient_space: + /* See if we can refurbish the current folio. */ + if (!folio || !folio_ref_sub_and_test(folio, cache->pagecnt_bias)) + goto get_new_folio; + if (unlikely(cache->pfmemalloc)) { + __folio_put(folio); + goto get_new_folio; + } + + fsize = folio_size(folio); + if (unlikely(fragsz > fsize)) + goto frag_too_big; + + /* OK, page count is 0, we can safely set it */ + folio_set_count(folio, PAGE_FRAG_CACHE_MAX_SIZE + 1); + + /* Reset page count bias and offset to start of new frag */ + cache->pagecnt_bias = PAGE_FRAG_CACHE_MAX_SIZE + 1; + offset = fsize; + goto try_again; + +get_new_folio: + if (!spare) { + cache->folio = NULL; + put_cpu_ptr(&skb_splice_frag_cache); + +#if PAGE_SIZE < PAGE_FRAG_CACHE_MAX_SIZE + spare = folio_alloc(gfp | __GFP_NOWARN | __GFP_NORETRY | + __GFP_NOMEMALLOC, + PAGE_FRAG_CACHE_MAX_ORDER); + if (!spare) +#endif + spare = folio_alloc(gfp, 0); + if (!spare) + return NULL; + + cache = get_cpu_ptr(&skb_splice_frag_cache); + /* We may now be on a different cpu and/or someone else may + * have refilled it + */ + cache->pfmemalloc = folio_is_pfmemalloc(spare); + if (cache->folio) + goto reload; + } + + cache->folio = spare; + cache->virt = folio_address(spare); + folio = spare; + spare = NULL; + + /* Even if we own the page, we do not use atomic_set(). This would + * break get_page_unless_zero() users. + */ + folio_ref_add(folio, PAGE_FRAG_CACHE_MAX_SIZE); + + /* Reset page count bias and offset to start of new frag */ + cache->pagecnt_bias = PAGE_FRAG_CACHE_MAX_SIZE + 1; + offset = folio_size(folio); + goto try_again; + +frag_too_big: + /* + * The caller is trying to allocate a fragment with fragsz > PAGE_SIZE + * but the cache isn't big enough to satisfy the request, this may + * happen in low memory conditions. We don't release the cache page + * because it could make memory pressure worse so we simply return NULL + * here. + */ + cache->offset = offset; + put_cpu_ptr(&skb_splice_frag_cache); + if (spare) + folio_put(spare); + return NULL; +} +EXPORT_SYMBOL(alloc_skb_frag); + +/** + * copy_skb_frag - Copy data into a page fragment. + * @s: The data to copy + * @len: The size of the data + * @gfp: Allocation flags + */ +void *copy_skb_frag(const void *s, size_t len, gfp_t gfp) +{ + void *p; + + p = alloc_skb_frag(len, gfp); + if (!p) + return NULL; + + return memcpy(p, s, len); +} +EXPORT_SYMBOL(copy_skb_frag); + static void skb_splice_csum_page(struct sk_buff *skb, struct page *page, size_t offset, size_t len) { @@ -6808,17 +6948,43 @@ ssize_t skb_splice_from_iter(struct sk_buff *skb, struct iov_iter *iter, break; } + if (space == 0 && + !skb_can_coalesce(skb, skb_shinfo(skb)->nr_frags, + pages[0], off)) { + iov_iter_revert(iter, len); + break; + } + i = 0; do { struct page *page = pages[i++]; size_t part = min_t(size_t, PAGE_SIZE - off, len); - - ret = -EIO; - if (WARN_ON_ONCE(!sendpage_ok(page))) + bool put = false; + + if (PageSlab(page)) { + const void *p; + void *q; + + p = kmap_local_page(page); + q = copy_skb_frag(p + off, part, gfp); + kunmap_local(p); + if (!q) { + iov_iter_revert(iter, len); + ret = -ENOMEM; + goto out; + } + page = virt_to_page(q); + off = offset_in_page(q); + put = true; + } else if (WARN_ON_ONCE(!sendpage_ok(page))) { + ret = -EIO; goto out; + } ret = skb_append_pagefrags(skb, page, off, part, frag_limit); + if (put) + put_page(page); if (ret < 0) { iov_iter_revert(iter, len); goto out; From patchwork Fri Jun 16 16:12:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13282934 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 379C2EB64DB for ; Fri, 16 Jun 2023 16:13:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B349F8E0003; Fri, 16 Jun 2023 12:13:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AE51C8E0001; Fri, 16 Jun 2023 12:13:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 95EB58E0003; Fri, 16 Jun 2023 12:13:18 -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 80E188E0001 for ; Fri, 16 Jun 2023 12:13:18 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 5B1F080C95 for ; Fri, 16 Jun 2023 16:13:18 +0000 (UTC) X-FDA: 80909105676.12.F222447 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf28.hostedemail.com (Postfix) with ESMTP id 9A3FEC0020 for ; Fri, 16 Jun 2023 16:13:16 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=SqRc0xAk; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf28.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=1686931996; 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=hLyIcwmfB2andhOIerohYp47fZMshUve8T8pZZkzjqE=; b=Dmv5hIhMzZ5gyfdJ/tC+59Q/hZcN/MpU4IxbKljl3ZqB3uQ8f7MOm6/IkqFSx2CmqOsDWk 4LZcBrf9Kl6L5x4wqtpO4UpttfHZRJf1FdfE+ljv0MsgDhSgD4tBsjCPMOovHIESJqjYn0 zMELuhzuAk9/U5jp7pjrQODFzUBT/0w= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=SqRc0xAk; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf28.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=1686931996; a=rsa-sha256; cv=none; b=dUooI7ukHCuFIveSoGfSvH4vbg7FdL8auOtZxQk7yUPks+Z5LoudWJbz7id7dw4GI1dVhG 1sTcVZlmgogF+0sof6yuelwzrdoZx5OO8HttuXp4P5eviJRkOXqzcg+yAS2fol5r2bVf1p amlGwFq0bYJ6GW/GzoBmALzymVKvjLY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686931996; 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=hLyIcwmfB2andhOIerohYp47fZMshUve8T8pZZkzjqE=; b=SqRc0xAkUlhq9G2rT5xv79wqKiIwkOYsAMLveCNm+dUR+tswExpEAcPwrFthJJ6aArUGKE LUu67nRlQ2lEK+KQOwAwzyApcSEpymD3LJUgwmxKhvepRpWTnL22/3kLIPwFmRue9Sjcyk H+xJlKHkovFG+5JGJFfqwcs+OMcPO2c= 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-237-DuKHWMn7Mna8lkq6yhfy6g-1; Fri, 16 Jun 2023 12:13:14 -0400 X-MC-Unique: DuKHWMn7Mna8lkq6yhfy6g-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 C97C43C025B4; Fri, 16 Jun 2023 16:13:13 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id 913B348FB01; Fri, 16 Jun 2023 16:13:10 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Alexander Duyck , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , Jens Axboe , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Menglong Dong Subject: [PATCH net-next 02/17] net: Display info about MSG_SPLICE_PAGES memory handling in proc Date: Fri, 16 Jun 2023 17:12:45 +0100 Message-ID: <20230616161301.622169-3-dhowells@redhat.com> In-Reply-To: <20230616161301.622169-1-dhowells@redhat.com> References: <20230616161301.622169-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Rspamd-Queue-Id: 9A3FEC0020 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 9nixfsepdgd8qashikmj48n4y6qtnjbm X-HE-Tag: 1686931996-874925 X-HE-Meta: U2FsdGVkX1/7iupxSXGsxavj1az1tORcRi9q/tDrNB0Pswcw+cKZHP16ZH6UBJT2bcgagwR728WGvZ2Rn1i9ljbSbz97yP3/AbUGyCrtu/s5SCf4NotcRl37hcaCYnOwgym3rjmnSW9pz/savq1mRJ5f+bqibg9N3/2dk/1hX7HnORU3Zz6kil/7oYh5c7eowPLUdwV0hzlPE3ja/v9OwgL2tbWZ79Q+c3EKBWGnUGlVWW3Pep6gyW46m9Pzpm9QwBrO67lL5lfAmK3K7ou37Rf8xNeiro7BWlvQwhQvdanEijWV/FKgAl+71tMJ9c9hhSUu+tnRgHsdUX3CP22ywU8OE6sZYsbBzT4EAU+pvO1dwId6iuweLnO3Hr3sbhLfSRKyz5zQDOeTZfVIdOq4M6MBVg8tZksemihkpauJmeNoEhwjPPqUJomRnCwmDegU3fwciXVqqYVuvCKmy8jkvG96c/EFD0cpGwaicocAtLYXtht8bO2mb4OFIgV6hoko6WGdwb2qyZ3mHmgIFr3mfJO/B2ZZuTSGXA5DabX97zJ4f6L8R/AlPUPwQiAmeJvQi7r9tXmyrV5yESc6xEk7crSlvm/tZACHY4tegZ2dP4+hlX1yWTkAEmcGxR19wfOD7M2jKlrchR24uZFhv9SMLicdWRihArERl1QdxgabSJxmfyVvVGYMJRXDKeFK8TzdXjYHTynUQwD/HwqDPKiT8gHkr7xrUm2t4vUfaPBlbvrS/TqlC/xTcppc6h5pjL89n+r9E5GlQeibgN2OEVoWmeXABM0aHFNm2hIkc0HNA2fdQB1DFd648i3hXRq47Z8lYGbCQhN9zGHOrq16EYa7oWn+FiLtFJDfcp1tIZA7yJvSTQa00QQpGqGoMvkmRnCOCrk5DkAPHZ2Fz5DiVLxshiw7i/5JJdwgeKRkRY3AfNoaDQEfLiHBdEfVmFckiuRI4D+RjGALYf5Gk7nvpFP gVk1wAoZ k81lh1kdaeK83Be0YiQq2LjHk7pSggX4Fr+un1rA9Vv8+0BqVkv7D4HmLMfSzP7qqzefKAgx7FO+esoAwwdy0JFPFES+XxMZGvUnUw1CcjSjj9sB7PmrC8AgzGSKItWokZmtXwAwG739Xv4XE+/D5H0WY2GbTT+5afwBUYgWerNhMQAj+hMUU14Uq46K9paOd/n0ctj588zPERqmvsOIl5KxQZRCIt+6lLCRZy1w+yIqCU9NMhy+G92BMBjNe7iBSAwr3rRpwUXzejqriVd6aDyIp5MLediQIBLUx0nHubrEMw17/+p3As5M4WhwhzxWlXU1BpPYxViyii0Je6e/E0ywa2ui9qr0Mdipj2ZqTdNE/bQGVF+KUdA0rAL2FP9b9yVrWOXQJ219Yz7uCbVzY21Sic5NLtzoe506qy/kplC7nBQMb42sfQUHk5BIaQdy3IEE5WN3qSD/B/D0LOI5FPwusi9/MguglNDZoBJ69ic8q3/YhA/Sdricc5bLbUjXJbF0Hwg5IeaPvjEKWlrePGq0jcYI6HdjX07KsiX1/V5wcAdnHY6nheAohY8PrlRRAk/oAqIPbLeJ2z/I= 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: Display information about the memory handling MSG_SPLICE_PAGES does to copy slabbed data into page fragments. For each CPU that has a cached folio, it displays the folio pfn, the offset pointer within the folio and the size of the folio. It also displays the number of pages refurbished and the number of pages replaced. Signed-off-by: David Howells cc: Alexander Duyck cc: Eric Dumazet cc: "David S. Miller" cc: David Ahern cc: Jakub Kicinski cc: Paolo Abeni cc: Jens Axboe cc: Matthew Wilcox cc: Menglong Dong cc: netdev@vger.kernel.org --- net/core/skbuff.c | 42 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 9bd8d6bf6c21..c388a73e5d4e 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -83,6 +83,7 @@ #include #include #include +#include #include "dev.h" #include "sock_destructor.h" @@ -6758,6 +6759,7 @@ nodefer: __kfree_skb(skb); struct skb_splice_frag_cache { struct folio *folio; void *virt; + unsigned int fsize; unsigned int offset; /* we maintain a pagecount bias, so that we dont dirty cache line * containing page->_refcount every time we allocate a fragment. @@ -6767,6 +6769,26 @@ struct skb_splice_frag_cache { }; static DEFINE_PER_CPU(struct skb_splice_frag_cache, skb_splice_frag_cache); +static atomic_t skb_splice_frag_replaced, skb_splice_frag_refurbished; + +static int skb_splice_show(struct seq_file *m, void *data) +{ + int cpu; + + seq_printf(m, "refurb=%u repl=%u\n", + atomic_read(&skb_splice_frag_refurbished), + atomic_read(&skb_splice_frag_replaced)); + + for_each_possible_cpu(cpu) { + const struct skb_splice_frag_cache *cache = + per_cpu_ptr(&skb_splice_frag_cache, cpu); + + seq_printf(m, "[%u] %lx %u/%u\n", + cpu, folio_pfn(cache->folio), + cache->offset, cache->fsize); + } + return 0; +} /** * alloc_skb_frag - Allocate a page fragment for using in a socket @@ -6803,17 +6825,21 @@ void *alloc_skb_frag(size_t fragsz, gfp_t gfp) insufficient_space: /* See if we can refurbish the current folio. */ - if (!folio || !folio_ref_sub_and_test(folio, cache->pagecnt_bias)) + if (!folio) goto get_new_folio; + if (!folio_ref_sub_and_test(folio, cache->pagecnt_bias)) + goto replace_folio; if (unlikely(cache->pfmemalloc)) { __folio_put(folio); - goto get_new_folio; + goto replace_folio; } fsize = folio_size(folio); if (unlikely(fragsz > fsize)) goto frag_too_big; + atomic_inc(&skb_splice_frag_refurbished); + /* OK, page count is 0, we can safely set it */ folio_set_count(folio, PAGE_FRAG_CACHE_MAX_SIZE + 1); @@ -6822,6 +6848,8 @@ void *alloc_skb_frag(size_t fragsz, gfp_t gfp) offset = fsize; goto try_again; +replace_folio: + atomic_inc(&skb_splice_frag_replaced); get_new_folio: if (!spare) { cache->folio = NULL; @@ -6848,6 +6876,7 @@ void *alloc_skb_frag(size_t fragsz, gfp_t gfp) cache->folio = spare; cache->virt = folio_address(spare); + cache->fsize = folio_size(spare); folio = spare; spare = NULL; @@ -6858,7 +6887,7 @@ void *alloc_skb_frag(size_t fragsz, gfp_t gfp) /* Reset page count bias and offset to start of new frag */ cache->pagecnt_bias = PAGE_FRAG_CACHE_MAX_SIZE + 1; - offset = folio_size(folio); + offset = cache->fsize; goto try_again; frag_too_big: @@ -7008,3 +7037,10 @@ ssize_t skb_splice_from_iter(struct sk_buff *skb, struct iov_iter *iter, return spliced ?: ret; } EXPORT_SYMBOL(skb_splice_from_iter); + +static int skb_splice_init(void) +{ + proc_create_single("pagefrags", S_IFREG | 0444, NULL, &skb_splice_show); + return 0; +} +late_initcall(skb_splice_init); From patchwork Fri Jun 16 16:12:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13282935 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 87F6EEB64D8 for ; Fri, 16 Jun 2023 16:13:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0ACB38E0005; Fri, 16 Jun 2023 12:13:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 05E388E0001; Fri, 16 Jun 2023 12:13:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E40B28E0005; Fri, 16 Jun 2023 12:13:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id D3AF28E0001 for ; Fri, 16 Jun 2023 12:13:27 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 92341AFAF7 for ; Fri, 16 Jun 2023 16:13:27 +0000 (UTC) X-FDA: 80909106054.24.C400530 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf15.hostedemail.com (Postfix) with ESMTP id C1516A001C for ; Fri, 16 Jun 2023 16:13:25 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=B0rgnApD; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf15.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.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=1686932005; 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=/uSTCkptTsC4xYTqgPPYvFLo6KQm6ldgKXcPsN3l6RA=; b=hXL68QtLSXyf+vbKvQYP/bakWmFTwNkZH/QZ7KHhv1tYA0MNRgIGnKjuLT7yEhoJTw2zDL SMWpaoiHih6G8Q5vHgCQQhRJmecCzt2NC4bwpZvgjzB5RxXs5moiphug1FyVWtyN2CeYcL TXp3glPPK3bxXXYrCBJzNs972KF6riQ= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=B0rgnApD; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf15.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686932005; a=rsa-sha256; cv=none; b=Xzt1jvEUjaRaXJtPh9Q55YgBvVRKkhe5fJ2Rys2QmjGFLqwLFf8EfBlzQgJplxfOtVXHG2 HfcB5sxZ4WUtKnyQZsj/ger8/CJ9fj5ADTCyLud6BLjiLfk5EFPMNeHBqlH3kNXqmWASk5 AF3pm7TxgVPdbm8i8qd6GXT2WYO9yAc= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686932005; 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=/uSTCkptTsC4xYTqgPPYvFLo6KQm6ldgKXcPsN3l6RA=; b=B0rgnApDyXTqbnitek+RPf3vz1FYgqkMbKkb2FoA3cBFnkqHY5VbHC56C/N9hnp63bPEWk e7Knm11ban66PmSB5234G4y0ShMQVKbIK2O47XcAEkEii7fBkexpLotTi5nwEdrjCPh3k8 Ye1za5H/WO6SzqGWrbuX1G/UFntMyaM= 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-114-0Z8wEYp2Nm2gZ4mNz8jpMA-1; Fri, 16 Jun 2023 12:13:19 -0400 X-MC-Unique: 0Z8wEYp2Nm2gZ4mNz8jpMA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 55C361C05ABF; Fri, 16 Jun 2023 16:13:18 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9325540CF8F6; Fri, 16 Jun 2023 16:13:14 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Alexander Duyck , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , Jens Axboe , linux-mm@kvack.org, linux-kernel@vger.kernel.org, John Fastabend , Jakub Sitnicki , Karsten Graul , Wenjia Zhang , Jan Karcher , "D. Wythe" , Tony Lu , Wen Gu , Boris Pismenny , Steffen Klassert , Herbert Xu , bpf@vger.kernel.org, linux-s390@vger.kernel.org Subject: [PATCH net-next 03/17] tcp_bpf, smc, tls, espintcp: Reduce MSG_SENDPAGE_NOTLAST usage Date: Fri, 16 Jun 2023 17:12:46 +0100 Message-ID: <20230616161301.622169-4-dhowells@redhat.com> In-Reply-To: <20230616161301.622169-1-dhowells@redhat.com> References: <20230616161301.622169-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Rspamd-Queue-Id: C1516A001C X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: 81ad6wwsoierridqt6tsta8rr35bemtc X-HE-Tag: 1686932005-269226 X-HE-Meta: U2FsdGVkX1/Yy8cdeb+zBge/9SwkW4jssyE4e5GGJP3sY05glPqLnL3aDGbMMntebPl8cixhRdFE2LQVcyVy85vXn8k7hZ8ZXFMLuxBtEEBklaRNPL5XY4cCt9bpHFM2qjuD2uFL6kUfRrQ2wsdzxRWqsh/haiJrem6+poIbVr7gae/3rKVz4wJftLATY/+7M5+9aHk5p2mWHb7UAqBkGDgIqjcFfydlkXl/1765Ipeu63XGcZKHrB0ILGPiexiYqVS8zSsBUAAC9eDwh8WAw4ihxmiWT1o3fAFwU20XqncE9N8yix2E4p1bGXqCc9o8NuXrmXi35nSob1Xgn2AMQmRwxp/LrWpyjjnY1BCDUKvphWx/9vlkT5P1HI8FAlT1abbANrFKTy7Zt0IHi0kTHZOCj8851ZCAouUVs6Z9lIkXj1uqG2f2pX4OYVQkmFrOESewr3ZDiIp+NSJ6jUt9gi5F1ZvZKKAaTbz+9XJMrz8N4VuEjKV6Y8hwQx435DdlR5jPesX66SmJXxLDKjYWGQTOIT+c/qLiCrRf8g4ZIYxUIlNY6Q7AjyxQ+f9h8etvea8/EZvZntSEKI1QHQOscfVrmU5xYqLa7Ir3g9ewcRWicHAUsgBV9QcOC+yXgP1ZVZeZ1rm44jEkooHSVmX6EtyNFkY6B8mGN9hiHDve26wbq8RDXnecyKhOOHYPy0GbuE4uHLD0mgey1WnS+ImwB6Andc38wZrqC+IH5hPODL9fzJzxbRGkbUJoVGvzlJHedq+qMgDqq/drfcgGbO/7d0FWGtBfKqLV4hhLxVM4z3OGFSoxHjgVMq8KSA9z2gj1Gim/bKwdhZNYey6oiEzl/HTdRnQM4YwaFNTnzU6moOg6CqvRSayzNUQcBhs1aNbT5CL3X5KrOHV1P8zygA2yv9yN0Cgnsrbvppb9mOIhTkouxIQdj32ks3Z49isD5ljcv5c5qOd3zaOKMicPVpV f7GlZwjw uWzPRQaOAoGWnriRsgmDw0RYAsVbYG9lrfev14R+wEcu9rj+LOOv38qODgMCijdiS3g7e9agnhd+evBte//rrL4cAigvX48KePXPwHHbDwtVHztiHcuRq+OftQc9BP+UtcMeNVNumbNGwnSJP5bljv2yF6kN5JSvGeJqhRUJ2WqqlggEIdUGIhuqamTLSEqV2z7GU3BnzEPyK5dw8XE0TvgU3xMMBGAuo56MQii9IXhrX28dZQy3r9qvVTnSUFmKufSCoqttpHruftLjXbpeHpcocDTfma81Pi6bltL6g7VPg22HvJIs4Kzr6ughpuc/3upxlYR7GagjwGfFalZnAPfBMQyJbGR+NIgjmMbRuBUDscU3MmcZv80P+w6323BbpJDq3Dn/q5vu5JxszEaUTEBx6JaHWNJkY0+a6Sk2S8d39Fu/roMM7gh7APng1FBMO74YSfM/meE5EDyllCQDspei791cmu6CTnFw8dCRAsXGScxPuVxsGyC7ti9hbIZv81CLYGz/i+0JtiZUnz2umJvvEIg9+lfoWlKStrHA+9vqdqpaXMLUmvOH7+tJA/daCwQqKHN0UE1SqgZ8RAHOA6xQ26p0Kqr8ATisqGzW3JUKELTsIXsxcARyniEZxAV0TTKpGeNrAH2d5EDICnQfveSi6YhOFHvC4J/w5 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: As MSG_SENDPAGE_NOTLAST is being phased out along with sendpage(), don't use it further in than the sendpage methods, but rather translate it to MSG_MORE and use that instead. Signed-off-by: David Howells cc: John Fastabend cc: Jakub Sitnicki cc: Eric Dumazet cc: "David S. Miller" cc: David Ahern cc: Jakub Kicinski cc: Paolo Abeni cc: Karsten Graul cc: Wenjia Zhang cc: Jan Karcher cc: "D. Wythe" cc: Tony Lu cc: Wen Gu cc: Boris Pismenny cc: Steffen Klassert cc: Herbert Xu cc: netdev@vger.kernel.org cc: bpf@vger.kernel.org cc: linux-s390@vger.kernel.org --- net/ipv4/tcp_bpf.c | 3 --- net/smc/smc_tx.c | 6 ++++-- net/tls/tls_device.c | 4 ++-- net/xfrm/espintcp.c | 10 ++++++---- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/net/ipv4/tcp_bpf.c b/net/ipv4/tcp_bpf.c index 5a84053ac62b..adcba77b0c50 100644 --- a/net/ipv4/tcp_bpf.c +++ b/net/ipv4/tcp_bpf.c @@ -111,9 +111,6 @@ static int tcp_bpf_push(struct sock *sk, struct sk_msg *msg, u32 apply_bytes, if (has_tx_ulp) msghdr.msg_flags |= MSG_SENDPAGE_NOPOLICY; - if (flags & MSG_SENDPAGE_NOTLAST) - msghdr.msg_flags |= MSG_MORE; - bvec_set_page(&bvec, page, size, off); iov_iter_bvec(&msghdr.msg_iter, ITER_SOURCE, &bvec, 1, size); ret = tcp_sendmsg_locked(sk, &msghdr, size); diff --git a/net/smc/smc_tx.c b/net/smc/smc_tx.c index 45128443f1f1..9b9e0a190734 100644 --- a/net/smc/smc_tx.c +++ b/net/smc/smc_tx.c @@ -168,8 +168,7 @@ static bool smc_tx_should_cork(struct smc_sock *smc, struct msghdr *msg) * should known how/when to uncork it. */ if ((msg->msg_flags & MSG_MORE || - smc_tx_is_corked(smc) || - msg->msg_flags & MSG_SENDPAGE_NOTLAST) && + smc_tx_is_corked(smc)) && atomic_read(&conn->sndbuf_space)) return true; @@ -306,6 +305,9 @@ int smc_tx_sendpage(struct smc_sock *smc, struct page *page, int offset, struct kvec iov; int rc; + if (flags & MSG_SENDPAGE_NOTLAST) + msg.msg_flags |= MSG_MORE; + iov.iov_base = kaddr + offset; iov.iov_len = size; iov_iter_kvec(&msg.msg_iter, ITER_SOURCE, &iov, 1, size); diff --git a/net/tls/tls_device.c b/net/tls/tls_device.c index b82770f68807..975299d7213b 100644 --- a/net/tls/tls_device.c +++ b/net/tls/tls_device.c @@ -449,7 +449,7 @@ static int tls_push_data(struct sock *sk, return -sk->sk_err; flags |= MSG_SENDPAGE_DECRYPTED; - tls_push_record_flags = flags | MSG_SENDPAGE_NOTLAST; + tls_push_record_flags = flags | MSG_MORE; timeo = sock_sndtimeo(sk, flags & MSG_DONTWAIT); if (tls_is_partially_sent_record(tls_ctx)) { @@ -532,7 +532,7 @@ static int tls_push_data(struct sock *sk, if (!size) { last_record: tls_push_record_flags = flags; - if (flags & (MSG_SENDPAGE_NOTLAST | MSG_MORE)) { + if (flags & MSG_MORE) { more = true; break; } diff --git a/net/xfrm/espintcp.c b/net/xfrm/espintcp.c index 3504925babdb..d3b3f9e720b3 100644 --- a/net/xfrm/espintcp.c +++ b/net/xfrm/espintcp.c @@ -205,13 +205,15 @@ static int espintcp_sendskb_locked(struct sock *sk, struct espintcp_msg *emsg, static int espintcp_sendskmsg_locked(struct sock *sk, struct espintcp_msg *emsg, int flags) { - struct msghdr msghdr = { .msg_flags = flags | MSG_SPLICE_PAGES, }; + struct msghdr msghdr = { + .msg_flags = flags | MSG_SPLICE_PAGES | MSG_MORE, + }; struct sk_msg *skmsg = &emsg->skmsg; + bool more = flags & MSG_MORE; struct scatterlist *sg; int done = 0; int ret; - msghdr.msg_flags |= MSG_SENDPAGE_NOTLAST; sg = &skmsg->sg.data[skmsg->sg.start]; do { struct bio_vec bvec; @@ -221,8 +223,8 @@ static int espintcp_sendskmsg_locked(struct sock *sk, emsg->offset = 0; - if (sg_is_last(sg)) - msghdr.msg_flags &= ~MSG_SENDPAGE_NOTLAST; + if (sg_is_last(sg) && !more) + msghdr.msg_flags &= ~MSG_MORE; p = sg_page(sg); retry: From patchwork Fri Jun 16 16:12:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13282936 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 37379EB64DA for ; Fri, 16 Jun 2023 16:13:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7179D8E0006; Fri, 16 Jun 2023 12:13:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 69E858E0001; Fri, 16 Jun 2023 12:13:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 53F038E0006; Fri, 16 Jun 2023 12:13:28 -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 44FEB8E0001 for ; Fri, 16 Jun 2023 12:13:28 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 0BE22120997 for ; Fri, 16 Jun 2023 16:13:28 +0000 (UTC) X-FDA: 80909106096.19.7FFDB6E Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf12.hostedemail.com (Postfix) with ESMTP id 20BD540020 for ; Fri, 16 Jun 2023 16:13:25 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Eqnfubgn; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf12.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.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=1686932006; 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=8Z8TKpGSoATJg8YUA+uQGeeIQegdpSxiJL3PqPYeaz4=; b=uCPiPivScjANTXERbmpGDRxSkfqhoXoiJ9tlfQCHmPTZ8rtZBjpC0c5K2opAtVAAjVj1o+ rVD14Qc3gNXZwdsGSR5y6vOw8czrpwt3yD0bHETLNg79fWafryE7nvegbgUbFBfYFEwEf3 jUQ++SUOxFmH7ilyi0k4oeDnKZwbBcA= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Eqnfubgn; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf12.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686932006; a=rsa-sha256; cv=none; b=lVG0Bi1wcvrQGvdIRsyfMXqb7huVKUHDjRpr0XgOKS4MnQChfjC+5DxVjZ4GEga58SAkNO 37QDUMwlqH9zZX9DDqbev0UC8SYVonLmQpV/Z8UOAdfXZ1ydNTRGX9Z7XtseK/SDrPEitE lf94ZAFCcmXF73Yq106onLBZhjrhgAY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686932005; 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=8Z8TKpGSoATJg8YUA+uQGeeIQegdpSxiJL3PqPYeaz4=; b=EqnfubgnwXBzMIpS/2D1znmGvUoLA37dIycmqV4GtMMQN7Wmc/+07TxAU+26fNaIftXHGC h76X9hLfcPECWjbAVnVNaznOA0RwcPc9Et7GTxJWtI4qXeMIKhn9bEqTpCpRcJPxiQgKai Vn008+wcIEe3dwmVxzVqfNFb1H6fzF0= 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-606-aKODK8OJPz2V9oQLhMS4pg-1; Fri, 16 Jun 2023 12:13:21 -0400 X-MC-Unique: aKODK8OJPz2V9oQLhMS4pg-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 2016029AB3E8; Fri, 16 Jun 2023 16:13:21 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A1DE40D1B60; Fri, 16 Jun 2023 16:13:19 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Alexander Duyck , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , Jens Axboe , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Bernard Metzler , Tom Talpey , linux-rdma@vger.kernel.org Subject: [PATCH net-next 04/17] siw: Use sendmsg(MSG_SPLICE_PAGES) rather than sendpage to transmit Date: Fri, 16 Jun 2023 17:12:47 +0100 Message-ID: <20230616161301.622169-5-dhowells@redhat.com> In-Reply-To: <20230616161301.622169-1-dhowells@redhat.com> References: <20230616161301.622169-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Rspamd-Queue-Id: 20BD540020 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 8ghr6egdfxqtjt1hh6om7euw5qocx5dz X-HE-Tag: 1686932005-511039 X-HE-Meta: U2FsdGVkX19nSVa11dCyFYKy0mReUE/RLrH7MdGV089mD3kOfPuzDKiAqu7sq9C0ZOjjaOOXqU82iErFmAT9Tlkuj772NXXA+24EjQMkC7HbsozZUVE1QZ/tTyo9kmjJ1sKm1S4zxfkVENlpl0NtJd93nm7lYyLZ/CsvwGHdW43wBH8R3dmiZi2B1k96PQR8kBxggG3OEkUWwdwmBirwq820yL9dvVk9KqrbRv1v3qDXGq7v2B/AYSyu+aAIPo0sZlWUEEYD4QxUYBKPAaCHLVa+5h2T6CN6s6dusy1MMMyfu5fUcCTckHxWIJedmC/e3t6FaoMVTcXvoT9Q4aLxLSHgJfcBJUwpjQPuoF324QS8ZPcdglLaUJ/aEGnse+J06y+RN1SYoSbc4B1X54kyfFOGJxQ1MBgNMSstIacNjFdDBNft4iynXHB8VSIyQ+T53J3znrt7cctwaPt/+uhxzk7IR+/lib/9t9XFSyxDA8fK2mq2opsIfGs/BFqS6ggBNlVEA4l+O3dd17ek3OWTEDmi4zebsYOHZGo1dN+I4D2s45ybhjH5JoOiTRfNbsO+yokgO3xemYpF8rXuWd6UWS2TjQoopuOKreQpfiuDggSGp6WMP9lywoNJ0WAen2obey46jpZY9Y3DY8lwQYX/93E3iASbhpVA0/HRY1d7ff7TKOaIzGLoZloQ5urpZw+cehRepnu7NS9BNQW2yvDmxVidvYTYRjAbUv1TZ5t4FyIYhUoIK22/rFmMbTqno3Y1nhwoO3Js+pZuKa5Z8l0Rw0TShsn1sLgLxhiGIsk14kYqmSmfbsmJI1oHVKHXrP+++1u1qiz+A/torcb/0K5HFgFOduoLvf08qpwBRklf/B3BPYV8LOMEg8fMtChu43oCRckpRCIXg5qajHpnFxq60Rq2CbXn6pDl2enKxY0EXoScqbhJQsRihJE5B1TlpSP+DbShyZEXTKjfwrJKU8b uOxw0A5j iASWFN4Rx+2LbNFGmU8Fq3ltZjjDoclXKO1fgHVXUROfAUCiuptnpormsS+/rL7GtK1dZgg1hVLA/qaHBjQeCAvUHH1AVNH18Wez8SkXGpFyeIzbpQ5Lzyq8GuZ9xlI6DFcGPaEYyZ8dTQogrd1y7xOIEt/5QUOXLYaoddViUfnVB3KPaBbb/Ykr8i9erosi0bjLgykAtB80LI8CCmNt5SZ70UZ/wBkijb3vf8Iq2USiUu4eyLpAv7K586xi7u0RD76XNHHKJUj8sqvbA13ibBI/NIv2g51o8JmwoM36+LER/lLQJ5VEaJ5ukMolwMR0U4pH58zmmkEY/vjs5+IeY9EAUGMm7NRzwkhm0FfqOeNgNY3XMWvdbb9kMYJ7x1osLBJjGVwLe8JxrLtu1zfmorOofzFxKwflEnBm9t8cWQBCVg5qcUxcGcGbYiISvC4ckwZ0RTdzDiWMGYKrjC4IcXyKOdT1IfaiyU/PlXA6ZbmG1ExYv0fwq+erAW/VI2FcHSCe1g0QN65wW+3+RhMQg3U6VF9Rd0Xno90mmCA5Fmxe5EhzvSWJLoEGuorPri2l5bxpXqc9s4KtF5K4= 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: When transmitting data, call down into TCP using a single sendmsg with MSG_SPLICE_PAGES to indicate that content should be spliced rather than performing several sendmsg and sendpage calls to transmit header, data pages and trailer. To make this work, the data is assembled in a bio_vec array and attached to a BVEC-type iterator. The header and trailer (if present) are copied into page fragments that can be freed with put_page(). Signed-off-by: David Howells cc: Bernard Metzler cc: Tom Talpey cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: Jens Axboe cc: Matthew Wilcox cc: linux-rdma@vger.kernel.org cc: netdev@vger.kernel.org --- drivers/infiniband/sw/siw/siw_qp_tx.c | 230 ++++---------------------- 1 file changed, 35 insertions(+), 195 deletions(-) diff --git a/drivers/infiniband/sw/siw/siw_qp_tx.c b/drivers/infiniband/sw/siw/siw_qp_tx.c index ffb16beb6c30..a15b3fedf484 100644 --- a/drivers/infiniband/sw/siw/siw_qp_tx.c +++ b/drivers/infiniband/sw/siw/siw_qp_tx.c @@ -311,114 +311,8 @@ static int siw_tx_ctrl(struct siw_iwarp_tx *c_tx, struct socket *s, return rv; } -/* - * 0copy TCP transmit interface: Use MSG_SPLICE_PAGES. - * - * Using sendpage to push page by page appears to be less efficient - * than using sendmsg, even if data are copied. - * - * A general performance limitation might be the extra four bytes - * trailer checksum segment to be pushed after user data. - */ -static int siw_tcp_sendpages(struct socket *s, struct page **page, int offset, - size_t size) -{ - struct bio_vec bvec; - struct msghdr msg = { - .msg_flags = (MSG_MORE | MSG_DONTWAIT | MSG_SENDPAGE_NOTLAST | - MSG_SPLICE_PAGES), - }; - struct sock *sk = s->sk; - int i = 0, rv = 0, sent = 0; - - while (size) { - size_t bytes = min_t(size_t, PAGE_SIZE - offset, size); - - if (size + offset <= PAGE_SIZE) - msg.msg_flags &= ~MSG_SENDPAGE_NOTLAST; - - tcp_rate_check_app_limited(sk); - bvec_set_page(&bvec, page[i], bytes, offset); - iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bvec, 1, size); - -try_page_again: - lock_sock(sk); - rv = tcp_sendmsg_locked(sk, &msg, size); - release_sock(sk); - - if (rv > 0) { - size -= rv; - sent += rv; - if (rv != bytes) { - offset += rv; - bytes -= rv; - goto try_page_again; - } - offset = 0; - } else { - if (rv == -EAGAIN || rv == 0) - break; - return rv; - } - i++; - } - return sent; -} - -/* - * siw_0copy_tx() - * - * Pushes list of pages to TCP socket. If pages from multiple - * SGE's, all referenced pages of each SGE are pushed in one - * shot. - */ -static int siw_0copy_tx(struct socket *s, struct page **page, - struct siw_sge *sge, unsigned int offset, - unsigned int size) -{ - int i = 0, sent = 0, rv; - int sge_bytes = min(sge->length - offset, size); - - offset = (sge->laddr + offset) & ~PAGE_MASK; - - while (sent != size) { - rv = siw_tcp_sendpages(s, &page[i], offset, sge_bytes); - if (rv >= 0) { - sent += rv; - if (size == sent || sge_bytes > rv) - break; - - i += PAGE_ALIGN(sge_bytes + offset) >> PAGE_SHIFT; - sge++; - sge_bytes = min(sge->length, size - sent); - offset = sge->laddr & ~PAGE_MASK; - } else { - sent = rv; - break; - } - } - return sent; -} - #define MAX_TRAILER (MPA_CRC_SIZE + 4) -static void siw_unmap_pages(struct kvec *iov, unsigned long kmap_mask, int len) -{ - int i; - - /* - * Work backwards through the array to honor the kmap_local_page() - * ordering requirements. - */ - for (i = (len-1); i >= 0; i--) { - if (kmap_mask & BIT(i)) { - unsigned long addr = (unsigned long)iov[i].iov_base; - - kunmap_local((void *)(addr & PAGE_MASK)); - } - } -} - /* * siw_tx_hdt() tries to push a complete packet to TCP where all * packet fragments are referenced by the elements of one iovec. @@ -438,30 +332,21 @@ static int siw_tx_hdt(struct siw_iwarp_tx *c_tx, struct socket *s) { struct siw_wqe *wqe = &c_tx->wqe_active; struct siw_sge *sge = &wqe->sqe.sge[c_tx->sge_idx]; - struct kvec iov[MAX_ARRAY]; - struct page *page_array[MAX_ARRAY]; + struct bio_vec bvec[MAX_ARRAY]; struct msghdr msg = { .msg_flags = MSG_DONTWAIT | MSG_EOR }; + void *trl; int seg = 0, do_crc = c_tx->do_crc, is_kva = 0, rv; unsigned int data_len = c_tx->bytes_unsent, hdr_len = 0, trl_len = 0, sge_off = c_tx->sge_off, sge_idx = c_tx->sge_idx, pbl_idx = c_tx->pbl_idx; - unsigned long kmap_mask = 0L; if (c_tx->state == SIW_SEND_HDR) { - if (c_tx->use_sendpage) { - rv = siw_tx_ctrl(c_tx, s, MSG_DONTWAIT | MSG_MORE); - if (rv) - goto done; + void *hdr = &c_tx->pkt.ctrl + c_tx->ctrl_sent; - c_tx->state = SIW_SEND_DATA; - } else { - iov[0].iov_base = - (char *)&c_tx->pkt.ctrl + c_tx->ctrl_sent; - iov[0].iov_len = hdr_len = - c_tx->ctrl_len - c_tx->ctrl_sent; - seg = 1; - } + hdr_len = c_tx->ctrl_len - c_tx->ctrl_sent; + bvec_set_virt(&bvec[0], hdr, hdr_len); + seg = 1; } wqe->processed += data_len; @@ -477,28 +362,9 @@ static int siw_tx_hdt(struct siw_iwarp_tx *c_tx, struct socket *s) } else { is_kva = 1; } - if (is_kva && !c_tx->use_sendpage) { - /* - * tx from kernel virtual address: either inline data - * or memory region with assigned kernel buffer - */ - iov[seg].iov_base = - ib_virt_dma_to_ptr(sge->laddr + sge_off); - iov[seg].iov_len = sge_len; - - if (do_crc) - crypto_shash_update(c_tx->mpa_crc_hd, - iov[seg].iov_base, - sge_len); - sge_off += sge_len; - data_len -= sge_len; - seg++; - goto sge_done; - } while (sge_len) { size_t plen = min((int)PAGE_SIZE - fp_off, sge_len); - void *kaddr; if (!is_kva) { struct page *p; @@ -511,33 +377,12 @@ static int siw_tx_hdt(struct siw_iwarp_tx *c_tx, struct socket *s) p = siw_get_upage(mem->umem, sge->laddr + sge_off); if (unlikely(!p)) { - siw_unmap_pages(iov, kmap_mask, seg); wqe->processed -= c_tx->bytes_unsent; rv = -EFAULT; goto done_crc; } - page_array[seg] = p; - - if (!c_tx->use_sendpage) { - void *kaddr = kmap_local_page(p); - - /* Remember for later kunmap() */ - kmap_mask |= BIT(seg); - iov[seg].iov_base = kaddr + fp_off; - iov[seg].iov_len = plen; - - if (do_crc) - crypto_shash_update( - c_tx->mpa_crc_hd, - iov[seg].iov_base, - plen); - } else if (do_crc) { - kaddr = kmap_local_page(p); - crypto_shash_update(c_tx->mpa_crc_hd, - kaddr + fp_off, - plen); - kunmap_local(kaddr); - } + + bvec_set_page(&bvec[seg], p, plen, fp_off); } else { /* * Cast to an uintptr_t to preserve all 64 bits @@ -545,12 +390,16 @@ static int siw_tx_hdt(struct siw_iwarp_tx *c_tx, struct socket *s) */ u64 va = sge->laddr + sge_off; - page_array[seg] = ib_virt_dma_to_page(va); - if (do_crc) - crypto_shash_update( - c_tx->mpa_crc_hd, - ib_virt_dma_to_ptr(va), - plen); + bvec_set_virt(&bvec[seg], ib_virt_dma_to_ptr(va), plen); + } + + if (do_crc) { + void *kaddr = + kmap_local_page(bvec[seg].bv_page); + crypto_shash_update(c_tx->mpa_crc_hd, + kaddr + bvec[seg].bv_offset, + bvec[seg].bv_len); + kunmap_local(kaddr); } sge_len -= plen; @@ -560,13 +409,12 @@ static int siw_tx_hdt(struct siw_iwarp_tx *c_tx, struct socket *s) if (++seg >= (int)MAX_ARRAY) { siw_dbg_qp(tx_qp(c_tx), "to many fragments\n"); - siw_unmap_pages(iov, kmap_mask, seg-1); wqe->processed -= c_tx->bytes_unsent; rv = -EMSGSIZE; goto done_crc; } } -sge_done: + /* Update SGE variables at end of SGE */ if (sge_off == sge->length && (data_len != 0 || wqe->processed < wqe->bytes)) { @@ -575,15 +423,8 @@ static int siw_tx_hdt(struct siw_iwarp_tx *c_tx, struct socket *s) sge_off = 0; } } - /* trailer */ - if (likely(c_tx->state != SIW_SEND_TRAILER)) { - iov[seg].iov_base = &c_tx->trailer.pad[4 - c_tx->pad]; - iov[seg].iov_len = trl_len = MAX_TRAILER - (4 - c_tx->pad); - } else { - iov[seg].iov_base = &c_tx->trailer.pad[c_tx->ctrl_sent]; - iov[seg].iov_len = trl_len = MAX_TRAILER - c_tx->ctrl_sent; - } + /* Set the CRC in the trailer */ if (c_tx->pad) { *(u32 *)c_tx->trailer.pad = 0; if (do_crc) @@ -596,23 +437,23 @@ static int siw_tx_hdt(struct siw_iwarp_tx *c_tx, struct socket *s) else if (do_crc) crypto_shash_final(c_tx->mpa_crc_hd, (u8 *)&c_tx->trailer.crc); - data_len = c_tx->bytes_unsent; - - if (c_tx->use_sendpage) { - rv = siw_0copy_tx(s, page_array, &wqe->sqe.sge[c_tx->sge_idx], - c_tx->sge_off, data_len); - if (rv == data_len) { - rv = kernel_sendmsg(s, &msg, &iov[seg], 1, trl_len); - if (rv > 0) - rv += data_len; - else - rv = data_len; - } + /* Copy the trailer and add it to the output list */ + if (likely(c_tx->state != SIW_SEND_TRAILER)) { + trl = &c_tx->trailer.pad[4 - c_tx->pad]; + trl_len = MAX_TRAILER - (4 - c_tx->pad); } else { - rv = kernel_sendmsg(s, &msg, iov, seg + 1, - hdr_len + data_len + trl_len); - siw_unmap_pages(iov, kmap_mask, seg); + trl = &c_tx->trailer.pad[c_tx->ctrl_sent]; + trl_len = MAX_TRAILER - c_tx->ctrl_sent; } + bvec_set_virt(&bvec[seg], trl, trl_len); + + data_len = c_tx->bytes_unsent; + + if (c_tx->use_sendpage) + msg.msg_flags |= MSG_SPLICE_PAGES; + iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, bvec, seg + 1, + hdr_len + data_len + trl_len); + rv = sock_sendmsg(s, &msg); if (rv < (int)hdr_len) { /* Not even complete hdr pushed or negative rv */ wqe->processed -= data_len; @@ -673,7 +514,6 @@ static int siw_tx_hdt(struct siw_iwarp_tx *c_tx, struct socket *s) } done_crc: c_tx->do_crc = 0; -done: return rv; } From patchwork Fri Jun 16 16:12:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13282937 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 31614EB64D7 for ; Fri, 16 Jun 2023 16:13:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C48988E0007; Fri, 16 Jun 2023 12:13:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BF7A38E0001; Fri, 16 Jun 2023 12:13:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A6FD58E0007; Fri, 16 Jun 2023 12:13:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 9518F8E0001 for ; Fri, 16 Jun 2023 12:13:31 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 24909120CF3 for ; Fri, 16 Jun 2023 16:13:31 +0000 (UTC) X-FDA: 80909106222.16.616504E Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf04.hostedemail.com (Postfix) with ESMTP id 433DF40010 for ; Fri, 16 Jun 2023 16:13:29 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=LpNd0KDr; spf=pass (imf04.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=1686932009; 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=1DmsLXNf6UEopicQGVGHzvB3R+Io/k4xNBk1zidfJPQ=; b=Q53KrWJRhKLk6k0IUG4gL88FTN/zAen2jPaT/f7gtdyfC71/udMuvq4m1khHcDesjSdQPp wqu5X+z2Ye4+E0nDiS42Tnv4R2Hfu+ns4vqC25sPLZnJcMTVMjiZV2cIlDLu2vSdKsqz/r BklrUMInQ5MQw9mMyMFnEUqTAzqSw8A= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686932009; a=rsa-sha256; cv=none; b=PxEkYbQtBMGSknqv2SXQSYi/zmpWD1xWocmpFgUCmlNusYtVQ5XVHmQdD1dJ6adzh8AAy3 fROnXpoOAMvRVtNoMonCbXGONYUpoC5ZJDNrxdX4xm13VSL5wBRRDaU/VVzDhi6RYUy1eS mMHs/FnELaMc7Y1L2Tr9oqWW+yGMcsQ= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=LpNd0KDr; spf=pass (imf04.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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686932008; 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=1DmsLXNf6UEopicQGVGHzvB3R+Io/k4xNBk1zidfJPQ=; b=LpNd0KDrEnGcB5qD4Hn+p9aL4KNHcVf3+pQiLD0qC6Q9Zwa287H778fDxYVKcGfjMmhYuM woil2FORuWBn6Fl8NNlFa1OfQvb1+qgQ+vKba8kXJQwsUdbjKAvS9TK26+VNrZiZjqPUeP PIatEpM1A6D5KvEBhMEoTsEyI+lBb6Y= 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-280-lvR3TEYCMuWBlcKwIOkPGg-1; Fri, 16 Jun 2023 12:13:25 -0400 X-MC-Unique: lvR3TEYCMuWBlcKwIOkPGg-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 70E1938041D5; Fri, 16 Jun 2023 16:13:24 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id BA8442026D49; Fri, 16 Jun 2023 16:13:21 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Alexander Duyck , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , Jens Axboe , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Ilya Dryomov , Xiubo Li , Jeff Layton , ceph-devel@vger.kernel.org Subject: [PATCH net-next 05/17] ceph: Use sendmsg(MSG_SPLICE_PAGES) rather than sendpage Date: Fri, 16 Jun 2023 17:12:48 +0100 Message-ID: <20230616161301.622169-6-dhowells@redhat.com> In-Reply-To: <20230616161301.622169-1-dhowells@redhat.com> References: <20230616161301.622169-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Rspamd-Queue-Id: 433DF40010 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 3o7d7ixqbss3eb7dd665t4bs9b9aph5w X-HE-Tag: 1686932009-639340 X-HE-Meta: U2FsdGVkX1+GwXaw555yW3C/quG0DxrM2f6lJPgrGh+b5jinxlmh6vlXmLlKHUDBEQUfZA4tYcCQYjRlihyn6Gwpz4rXh1lgOuQEp3H5voyuukQPTQxz9Wf83pi5EjFunNkoPyjpcSa9fdoGaHjsXl9aTvwr8D4DSy+9Jf6v/tu8hQ2b7prfJk57sLbta50lU1iT1yEYpaQzt86v1Svihj9anXM5pmfzTew7UWL7C0l1R7NCw3EiNAuWraA7H7X6hh2BXWY7nLf4JNvfukgzKqAPn/NVDNeIP2v/zCjRZA3Qxoi386IRrHf09IUxnt6C0vyQeeS0larVh3illgVwX9NwxZe8SPzxNoS1HcoKM0I6zl4NtcJoCM8XII36oixgut7GBJC3J4NdNHNMQiW6FRmYg9vR4/n8fNPseFdRU8rRCpdxnOsntGMYHpO/I+u8TpJ/cqS1ZMi0OUIHWBmUmfJneo8eYFKuqiWvokouo9oZZLrmrq/zEnk1YNCZySmnBi7trHeNW4yUZJyPzSM37L5b7a2jA6GMckTxEETXD1rkIiNKEh8dBLWuAWn7hmreqjyhRGG92KtQXmAgjYqfhXfqEyMUf9cT15IjlxkWBNe6YPwvn6B6mvfRCwuIwRdQd8kkl+EquYwhU2zacS+2e62CYOMXyRtF2SWvA2CSdUUS/nRRYxxkRlC2kbDfvSZ0f0oQsz4M0hAMJI9+IfKkbufPFB9YXVUL+dmy1Lm7/x/9vb+7MCudPDD3m+h3hEGQBDQ83e649qEYCtETMttklbyfO7SyS93PUjtE2fCymCs7sDlmSpgbhHQLvckOYk9lAjmWfSN8YR3+JWwl5lkfnwndfPEiiNJlmcqIAx5QtwEYHFM3URip7cv2YynWBHjHCHhD9dEevhB4i2GSdOVEVE5kZONNfI3Cw7/94Oy0HJaavA09a42rKlnQae9vyWJQLIxbapKI/kKYxne4PUG +R2pg9LZ lstXXPnqiQRNtWNcxExAqEeR5KeTs0IUIPRH2OI8A2OfjxosWkhc/Aw0l+KkdvxNyzJl/PgVIO/XnNk4knGsprznpLRtj0NywiHC3ifpYmFNZuMloWiDLoPxX9MjcgRHYoGVH8GIf2agVsd3YphoKHfJOuOk12P+8MqI9GVHlJerWfbz5cHR0Yvz3GiYgWpYRq9Ap1xOn4QiyfcYAGQvtl90ic5tDWwfR65FWW75pjRDc0FDDkf+/ScyHOY2j9QOGQVeutpXl3S3cvu8RtnxzXS81FP5Cm2fg3D4+H+CnmVwWEkbt+VrrlEQ1PihzAq1rV2n2CKuz0F0OjMbuoX6jcEMx8fzuSgiE2HtfHGj4qC8yHVTlD8XI3CwQ3O+v6/IomeL4bsvGiOaJh/cVXieqz88Xqtbx3o0UT8VamFlpD2mO1XsHZ4JoMQyxDYM8jQFt89DvbPlMK+ZLq9O3Upt9VYymzp0lTciqufCLSjCmeoTenrMwRlfpwkVm55ctiy7i8BGAXF7dW3BGozM= 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: Use sendmsg() and MSG_SPLICE_PAGES rather than sendpage in ceph when transmitting data. For the moment, this can only transmit one page at a time because of the architecture of net/ceph/, but if write_partial_message_data() can be given a bvec[] at a time by the iteration code, this would allow pages to be sent in a batch. Signed-off-by: David Howells cc: Ilya Dryomov cc: Xiubo Li cc: Jeff Layton cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: Jens Axboe cc: Matthew Wilcox cc: ceph-devel@vger.kernel.org cc: netdev@vger.kernel.org --- net/ceph/messenger_v1.c | 58 ++++++++++++++--------------------------- 1 file changed, 19 insertions(+), 39 deletions(-) diff --git a/net/ceph/messenger_v1.c b/net/ceph/messenger_v1.c index d664cb1593a7..f082e5c780a3 100644 --- a/net/ceph/messenger_v1.c +++ b/net/ceph/messenger_v1.c @@ -74,37 +74,6 @@ static int ceph_tcp_sendmsg(struct socket *sock, struct kvec *iov, return r; } -/* - * @more: either or both of MSG_MORE and MSG_SENDPAGE_NOTLAST - */ -static int ceph_tcp_sendpage(struct socket *sock, struct page *page, - int offset, size_t size, int more) -{ - ssize_t (*sendpage)(struct socket *sock, struct page *page, - int offset, size_t size, int flags); - int flags = MSG_DONTWAIT | MSG_NOSIGNAL | more; - int ret; - - /* - * sendpage cannot properly handle pages with page_count == 0, - * we need to fall back to sendmsg if that's the case. - * - * Same goes for slab pages: skb_can_coalesce() allows - * coalescing neighboring slab objects into a single frag which - * triggers one of hardened usercopy checks. - */ - if (sendpage_ok(page)) - sendpage = sock->ops->sendpage; - else - sendpage = sock_no_sendpage; - - ret = sendpage(sock, page, offset, size, flags); - if (ret == -EAGAIN) - ret = 0; - - return ret; -} - static void con_out_kvec_reset(struct ceph_connection *con) { BUG_ON(con->v1.out_skip); @@ -464,7 +433,6 @@ static int write_partial_message_data(struct ceph_connection *con) struct ceph_msg *msg = con->out_msg; struct ceph_msg_data_cursor *cursor = &msg->cursor; bool do_datacrc = !ceph_test_opt(from_msgr(con->msgr), NOCRC); - int more = MSG_MORE | MSG_SENDPAGE_NOTLAST; u32 crc; dout("%s %p msg %p\n", __func__, con, msg); @@ -482,6 +450,10 @@ static int write_partial_message_data(struct ceph_connection *con) */ crc = do_datacrc ? le32_to_cpu(msg->footer.data_crc) : 0; while (cursor->total_resid) { + struct bio_vec bvec; + struct msghdr msghdr = { + .msg_flags = MSG_SPLICE_PAGES, + }; struct page *page; size_t page_offset; size_t length; @@ -494,9 +466,12 @@ static int write_partial_message_data(struct ceph_connection *con) page = ceph_msg_data_next(cursor, &page_offset, &length); if (length == cursor->total_resid) - more = MSG_MORE; - ret = ceph_tcp_sendpage(con->sock, page, page_offset, length, - more); + msghdr.msg_flags |= MSG_MORE; + + bvec_set_page(&bvec, page, length, page_offset); + iov_iter_bvec(&msghdr.msg_iter, ITER_SOURCE, &bvec, 1, length); + + ret = sock_sendmsg(con->sock, &msghdr); if (ret <= 0) { if (do_datacrc) msg->footer.data_crc = cpu_to_le32(crc); @@ -526,7 +501,10 @@ static int write_partial_message_data(struct ceph_connection *con) */ static int write_partial_skip(struct ceph_connection *con) { - int more = MSG_MORE | MSG_SENDPAGE_NOTLAST; + struct bio_vec bvec; + struct msghdr msghdr = { + .msg_flags = MSG_SPLICE_PAGES | MSG_MORE, + }; int ret; dout("%s %p %d left\n", __func__, con, con->v1.out_skip); @@ -534,9 +512,11 @@ static int write_partial_skip(struct ceph_connection *con) size_t size = min(con->v1.out_skip, (int)PAGE_SIZE); if (size == con->v1.out_skip) - more = MSG_MORE; - ret = ceph_tcp_sendpage(con->sock, ceph_zero_page, 0, size, - more); + msghdr.msg_flags &= ~MSG_MORE; + bvec_set_page(&bvec, ZERO_PAGE(0), size, 0); + iov_iter_bvec(&msghdr.msg_iter, ITER_SOURCE, &bvec, 1, size); + + ret = sock_sendmsg(con->sock, &msghdr); if (ret <= 0) goto out; con->v1.out_skip -= ret; From patchwork Fri Jun 16 16:12: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: 13282938 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 E85E4EB64DA for ; Fri, 16 Jun 2023 16:13:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 40BBA8E0008; Fri, 16 Jun 2023 12:13:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 343EB8E0001; Fri, 16 Jun 2023 12:13:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 20CD88E0008; Fri, 16 Jun 2023 12:13:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 0BF7C8E0001 for ; Fri, 16 Jun 2023 12:13:33 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id DF4B81C8E1C for ; Fri, 16 Jun 2023 16:13:32 +0000 (UTC) X-FDA: 80909106264.27.A1BAC11 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf19.hostedemail.com (Postfix) with ESMTP id 355CC1A0002 for ; Fri, 16 Jun 2023 16:13:30 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=W68PFjCa; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf19.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=1686932011; 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=TGv8LJ3Gi12je7PTHEdWccb/3CDVbXvknzlPK5fmVXM=; b=hXKfLKvijvmqcIthJbzH+iZMDV12LbG7AVVWRIpppNQy1Xf2ng3X6w7aSXFR7Rd/iP51Ip 0xao1zaDxohGOvsPfTYxid63SmlHAeQqdkA3ZooWy9kHjtC+F5QBu5fiO/fVPAWrQrlsay O56QfHvBkCzzlC8pCSNLdAoesU0NwIA= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=W68PFjCa; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf19.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=1686932011; a=rsa-sha256; cv=none; b=HRutF3jdSaoL/8Jwn592KsspIjbHeqMQgPKGObuV1oxX0BBOaNfCheicvclysxQfFVXpQ5 lawk6FsZJNdoVoRQN5J9jLOR24OkLBDhptUM1FPV+RfUsfZwhdAJmK4Uikg/p3JDKHMdGJ G1yn/t26jXiPX+9xZR2zsBeWh2ffzS0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686932010; 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=TGv8LJ3Gi12je7PTHEdWccb/3CDVbXvknzlPK5fmVXM=; b=W68PFjCa7bbvzOIoQKO/3rz5Bz+PBRINlo3acIdLgmcPANtfTSfkhHo96yXFXWp8EBs55T Ibl27p9zCAyWITKRTn1PqjVf8eI41cK9+hWE4Kkz2LZcdWmDDSQ1akhrPn9JmI0sDrGwsK kLhk2FmlQ90OWuPKuUjL+U7qx0ZWoKQ= 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-437-w_GnGLXONkGBjC0UVI3bnQ-1; Fri, 16 Jun 2023 12:13:28 -0400 X-MC-Unique: w_GnGLXONkGBjC0UVI3bnQ-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 290A61C05AD4; Fri, 16 Jun 2023 16:13:27 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id 72F321410F01; Fri, 16 Jun 2023 16:13:25 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Alexander Duyck , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , Jens Axboe , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 06/17] net: Use sendmsg(MSG_SPLICE_PAGES) not sendpage in skb_send_sock() Date: Fri, 16 Jun 2023 17:12:49 +0100 Message-ID: <20230616161301.622169-7-dhowells@redhat.com> In-Reply-To: <20230616161301.622169-1-dhowells@redhat.com> References: <20230616161301.622169-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Rspam-User: X-Stat-Signature: knqo7pexoq5eoe5964peafzprqfibxfp X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 355CC1A0002 X-HE-Tag: 1686932010-636204 X-HE-Meta: U2FsdGVkX1+ciL7jEYhn+3hRjh4gzKUO9u5+9Vg3Xc/b2RfMM2qIq+xUy4jLnnS1Iz8CIA9j1DvxbzqhSJVznPgz8S3gPqScXS5y5HMJgc2nRn2o2dgNLNXOBFuLSOMPDZ59pWNaRTLGSdz4APc6C2clyaiOUurSNlxS/Z5Jr/G12q/Zj/xD44kfkqhg5QuE/2ekczrSN5OEzHjzdv/ctUK1JkNFgjZuAXIfmnsc9X662A/TRqUsrPkcBnBhR/V+sy84+F+Y0nWneGQB7P3f6BAM6urXuW4jXQHAotjmcJeY/mcXBKjffUhwfZJ925T5dWE3ph+mRar7XPgmWx+AO5zTzZwkrDt4BWHMEdfXm1x4Jm+hHdoLnEkfYV8lbIrZHVXr920InZhwPeakpV4SJQ5yo9rxSj1945CJHO/A3awWjqvt5wf/+Ll+M9hEJDv9wVzHgXuzKO5O1JqjbjiNKia7k7A+7M+55HJtRjFOYGixK40jy2oIlW16FAsT0yS2eRk3y1GHl7r9yD+cmcIyHEC4GN5V9il91czcCrd5cDiCNS1KWuXSV2SFxnFBH55xBK/puefl++DF5Q+GCixLJsAKUHQsHWya7HmH+q/o9BaW21SaYRApMThK8RD/5m/JYRCXD0MYYZaKzBGt4mJfQ2EAiP7WJif10EXeqckd17O2Wu6a69Jq6DMWaLqcoNaashhHaabM1P6o+fA7TkyR/JN53ihVP1Rdf8WF14w1yoIx+VUgL4lLUlpnSyHJXyq4RF7fBGBaZBr8BvbsYBP0H2xZjvEu+020P2waJ5NtCRcdxBvhNhs/Fv7ncG5Gpqx5KM3boPB+9oBbQoiObDcvtZC5RVcXY6S2GOk+aBnREJnHZEn7YrGcfoHvM6ToGSnhNY0JVdZzeetFsqj2+xBIOKuIBgvljha7JI/WsTaoqRP3kugIlFrmB/UOhD39X2NSZJ4Lt39I7nRo8gz10TV G8jUvYea L1IiatGDKaM4NYg+UXI13Xo7/a3XY6J/pCZYN34PX3+o/Oy7SWSQcPWTSmtUprnI2+XC+2kZ/azwvFDQB1SnW2GiK4gpZjn+6mc+XLS2LIp+gMASbSNgJ7U84Hz6HLT3PTe9YcRROlIpwYZyN8BmDtCW6mmp4ya8SxYxJocFiQ9hnJqqJSBBVnF6ViBa97DKDOqZB85gmcPlqLb92TQYWn7PO24JWR++8Vm0FgHtv671+CqzD7fERwaxloiCvYLjN4GKjwAiz55WhkOXWM7UiZD7ndW5kMtgbrKV5vb7htfoQHXR4dzpH2o9CcX3MpkikaayXwxcSMjxh8FomQqVyY7N1nUOX0Ek3BqTBHoRlvBQ65K0/OztLr/MlODv++61OKqCPtOTU+oeBiD3RvV5Ih8BPxRj3JI+1hWiYjAFyzcIKSauADVVQ8cy9N4A8NPrUQyzQXhoE/YMKJsP4ydGCgT8WUvvIfdgD4e/c3lh2yYwVcG0lsoLi7MasZw== 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: Use sendmsg() with MSG_SPLICE_PAGES rather than sendpage in skb_send_sock(). This causes pages to be spliced from the source iterator if possible. This allows ->sendpage() to be replaced by something that can handle multiple multipage folios in a single transaction. Note that this could perhaps be improved to fill out a bvec array with all the frags and then make a single sendmsg call, possibly sticking the header on the front also. Signed-off-by: David Howells cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: Jens Axboe cc: Matthew Wilcox cc: netdev@vger.kernel.org --- net/core/skbuff.c | 49 ++++++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/net/core/skbuff.c b/net/core/skbuff.c index c388a73e5d4e..e518bb57183a 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -2990,32 +2990,32 @@ int skb_splice_bits(struct sk_buff *skb, struct sock *sk, unsigned int offset, } EXPORT_SYMBOL_GPL(skb_splice_bits); -static int sendmsg_unlocked(struct sock *sk, struct msghdr *msg, - struct kvec *vec, size_t num, size_t size) +static int sendmsg_locked(struct sock *sk, struct msghdr *msg) { struct socket *sock = sk->sk_socket; + size_t size = msg_data_left(msg); if (!sock) return -EINVAL; - return kernel_sendmsg(sock, msg, vec, num, size); + + if (!sock->ops->sendmsg_locked) + return sock_no_sendmsg_locked(sk, msg, size); + + return sock->ops->sendmsg_locked(sk, msg, size); } -static int sendpage_unlocked(struct sock *sk, struct page *page, int offset, - size_t size, int flags) +static int sendmsg_unlocked(struct sock *sk, struct msghdr *msg) { struct socket *sock = sk->sk_socket; if (!sock) return -EINVAL; - return kernel_sendpage(sock, page, offset, size, flags); + return sock_sendmsg(sock, msg); } -typedef int (*sendmsg_func)(struct sock *sk, struct msghdr *msg, - struct kvec *vec, size_t num, size_t size); -typedef int (*sendpage_func)(struct sock *sk, struct page *page, int offset, - size_t size, int flags); +typedef int (*sendmsg_func)(struct sock *sk, struct msghdr *msg); static int __skb_send_sock(struct sock *sk, struct sk_buff *skb, int offset, - int len, sendmsg_func sendmsg, sendpage_func sendpage) + int len, sendmsg_func sendmsg) { unsigned int orig_len = len; struct sk_buff *head = skb; @@ -3035,8 +3035,9 @@ static int __skb_send_sock(struct sock *sk, struct sk_buff *skb, int offset, memset(&msg, 0, sizeof(msg)); msg.msg_flags = MSG_DONTWAIT; - ret = INDIRECT_CALL_2(sendmsg, kernel_sendmsg_locked, - sendmsg_unlocked, sk, &msg, &kv, 1, slen); + iov_iter_kvec(&msg.msg_iter, ITER_SOURCE, &kv, 1, slen); + ret = INDIRECT_CALL_2(sendmsg, sendmsg_locked, + sendmsg_unlocked, sk, &msg); if (ret <= 0) goto error; @@ -3067,11 +3068,17 @@ static int __skb_send_sock(struct sock *sk, struct sk_buff *skb, int offset, slen = min_t(size_t, len, skb_frag_size(frag) - offset); while (slen) { - ret = INDIRECT_CALL_2(sendpage, kernel_sendpage_locked, - sendpage_unlocked, sk, - skb_frag_page(frag), - skb_frag_off(frag) + offset, - slen, MSG_DONTWAIT); + struct bio_vec bvec; + struct msghdr msg = { + .msg_flags = MSG_SPLICE_PAGES | MSG_DONTWAIT, + }; + + bvec_set_page(&bvec, skb_frag_page(frag), slen, + skb_frag_off(frag) + offset); + iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bvec, 1, slen); + + ret = INDIRECT_CALL_2(sendmsg, sendmsg_locked, + sendmsg_unlocked, sk, &msg); if (ret <= 0) goto error; @@ -3108,16 +3115,14 @@ static int __skb_send_sock(struct sock *sk, struct sk_buff *skb, int offset, int skb_send_sock_locked(struct sock *sk, struct sk_buff *skb, int offset, int len) { - return __skb_send_sock(sk, skb, offset, len, kernel_sendmsg_locked, - kernel_sendpage_locked); + return __skb_send_sock(sk, skb, offset, len, sendmsg_locked); } EXPORT_SYMBOL_GPL(skb_send_sock_locked); /* Send skb data on a socket. Socket must be unlocked. */ int skb_send_sock(struct sock *sk, struct sk_buff *skb, int offset, int len) { - return __skb_send_sock(sk, skb, offset, len, sendmsg_unlocked, - sendpage_unlocked); + return __skb_send_sock(sk, skb, offset, len, sendmsg_unlocked); } /** From patchwork Fri Jun 16 16:12:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13282939 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 E52D0EB64D7 for ; Fri, 16 Jun 2023 16:13:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 73C908E0009; Fri, 16 Jun 2023 12:13:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6C5D88E0001; Fri, 16 Jun 2023 12:13:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 566EC8E0009; Fri, 16 Jun 2023 12:13:39 -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 42D9E8E0001 for ; Fri, 16 Jun 2023 12:13:39 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id D0FA640B5B for ; Fri, 16 Jun 2023 16:13:38 +0000 (UTC) X-FDA: 80909106516.23.BF50044 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf28.hostedemail.com (Postfix) with ESMTP id E4F7AC0002 for ; Fri, 16 Jun 2023 16:13:36 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="QOx9/x4S"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf28.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=1686932017; a=rsa-sha256; cv=none; b=vPf3hQFAaIv+JHMZWRaMa6TKw4ZHLskfYgb0tCsMXvwCG80jEfEUhVqU3c/jFc1/lGCs+b xjjvAMos8REjbAoO3b74zRVjnXNxLi+qiyFZIHJLJmSHOWLvUnyr609Jg1L+P5mL2JL6PL rkJGMjj7V3S5RiST9p8d/WO/4I5vlzQ= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="QOx9/x4S"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf28.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=1686932017; 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=fSQZQ6YboxRaXsiohOL5R9kf0uRRv2lhrE9A+pyCn4U=; b=BhGHEeS7u9rAM9WAg0UwmyB9nj/AHFYKMoZs/Ky0UioVRyB//zZmAc5MNBawxTwQOueown l4iZnZYa7sf8dm/fF8rsRlKiSXBRWOigdpE9f45n65BNxNjgClMPjM9h20mB3YrdS83LSs +OYjjwek+Eoig/Uid6PAFhPuKHTCPys= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686932016; 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=fSQZQ6YboxRaXsiohOL5R9kf0uRRv2lhrE9A+pyCn4U=; b=QOx9/x4S8JyFxPfvn4MW1bQ6IHWkxkXBRrTK0Dtrn4zxFGyV/jTsti0dk2670x+NIX7JI4 l7DVgZT35dXOAsQjmqiZT7LEPApRPBmRA1RLI6+hIxjbCeJhF3RH8Rrm0e/8rlwJTl9dQO FKAp8GGsBNigaY8oajsK+L6YpXB8Npg= 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-589-6q7z6BCsPgKZv0muxF5mVQ-1; Fri, 16 Jun 2023 12:13:31 -0400 X-MC-Unique: 6q7z6BCsPgKZv0muxF5mVQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 37C5B3C0E456; Fri, 16 Jun 2023 16:13:30 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id 14059C1604C; Fri, 16 Jun 2023 16:13:27 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Alexander Duyck , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , Jens Axboe , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Ilya Dryomov , Xiubo Li , Jeff Layton , ceph-devel@vger.kernel.org Subject: [PATCH net-next 07/17] ceph: Use sendmsg(MSG_SPLICE_PAGES) rather than sendpage() Date: Fri, 16 Jun 2023 17:12:50 +0100 Message-ID: <20230616161301.622169-8-dhowells@redhat.com> In-Reply-To: <20230616161301.622169-1-dhowells@redhat.com> References: <20230616161301.622169-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: E4F7AC0002 X-Stat-Signature: d9t3aerxpyr5pjn7asppopcakj6uoryu X-HE-Tag: 1686932016-245677 X-HE-Meta: U2FsdGVkX1+tWM2lMnD+e688w4jcl7XUxo/NwnALxctWCYqUkBuf9yYmWrs3/c9b6+KjdRCbR000vtWSoWbnpXDEQS7ULwsKWuvUMlnrjWPiB6ryO0tk8IWznEhMftlpygzxqUz/CHaovQkpll3QNs7S5tnB1ieYtXcPFihEIUDEJnOinsgOxX/OIxK8s+69lgmegQDsCL1dcGZ6mxbUclvZQ6kPUTX/mZhoqDynYjnA8M7v1aksJ7wfZQnxXaEnU2Sr0+6P7nqCBsFlMyVs586WkZ5Lsp59nQlLh+p9V9sjcBYn6GmBamZ7J5p0aJAwrtcCf09i1jhpPPlCiPNxdHtSIGCiNsEeX88R6cJcuRvM9iQy+eEzFLFfuLInWMiVOiIfeKV3SLN5YNVwpOKostaZJC5rAg30UJ808xnzMO3XRlXUFDMrrAS7yagx1X8U0b5kDIt1sEKrGybD7hq3M9AehG8bdinsPBmfuQJHIeNBUn6dmUpf4ICYLNz1oCryhKm8K74Qk/wsP3csFiiJqV2OT5/uuSP/qqOVOYr92narxSaLxqXeyQjAiV8I206x+oZax9csYA6HW4MN1H65hmXFGZ3AbZ8OwqWUghIYInTbZcnfGNlIVgu9MhI5xVO9SDjidfO6bzKrQqh6Ak4ANZsx0d1Z3VRs8aTXpLe60U/xIjXFH5tfP49rL0V2TIYHHPwR7a6w75+5cOLTHEQOkOSdskeTC8zalTCcQ0gVfBfr3vyrHKPAS2hzvnA8X4IR3HSRp828cmd7I9pTVAcoURm1V0OLEP4tWfsYYWFtCb2xCE4Kru/odpBOUuuLOjXL1kct3DsAbFF63egEK7Ie4pwmmTdTaItiH2YyyqODpU+6JMIvQwVid1+RdBbhO8FX4Dkc3GkEIGSkrDl19efuW5no47DrPdEydAaLyttOuivx/yTzEYwKPvKpMz8ecvc//WwG+rR0FVD9OeDGp7k ALi71AAR jMjxhuoNErB2sid5919D1fdhnDZBn7tjsluadnK1QzwuonmhrJuy0Uc/XGSNORT73inpwp9xq5nloUqtMljCdovHbh3v9UyXWjFG0DDkGL8Wb8pJLvWbvadAobRjHTTeKMJF8BtnubXAX1Pz5ebkD00jOBI6JFz++ud4YfMH1hGMvIvI2wJA32JZcgsPuNbgiwuPUI6Wah3eouD2Qg9bClraOzydc0fGCNic666no9IkES1f7DC021c9WWYwyNFiu9xS+zHXJJ4FLQ4ISODSJB2/ePrRjtGWbAtxgkQgesWXtzzQ2jt4UsrhpKv6r/uD+zKYfEm6CNYLCWAybe21FML0MEJ03qgznTbHmlWimkKHysteNNhOwEfOUcVhMfLYgj5Yh47Gdr5XSO3bh/1u/53C5n4Nsj5RAEWTEvs9+rwGXzcEWwrPVJocf2CVQV1+SjJtHExJLgs07Ke4CaJ2+GaAWY8HkmOWyuUVhiZaFYL9wg3cnM+G5ai2ewmleoHooBHkfO82VTePD1Sc= 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: Use sendmsg() and MSG_SPLICE_PAGES rather than sendpage in ceph when transmitting data. For the moment, this can only transmit one page at a time because of the architecture of net/ceph/, but if write_partial_message_data() can be given a bvec[] at a time by the iteration code, this would allow pages to be sent in a batch. Signed-off-by: David Howells cc: Ilya Dryomov cc: Xiubo Li cc: Jeff Layton cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: Jens Axboe cc: Matthew Wilcox cc: ceph-devel@vger.kernel.org cc: netdev@vger.kernel.org --- net/ceph/messenger_v2.c | 91 +++++++++-------------------------------- 1 file changed, 19 insertions(+), 72 deletions(-) diff --git a/net/ceph/messenger_v2.c b/net/ceph/messenger_v2.c index 301a991dc6a6..87ac97073e75 100644 --- a/net/ceph/messenger_v2.c +++ b/net/ceph/messenger_v2.c @@ -117,91 +117,38 @@ static int ceph_tcp_recv(struct ceph_connection *con) return ret; } -static int do_sendmsg(struct socket *sock, struct iov_iter *it) -{ - struct msghdr msg = { .msg_flags = CEPH_MSG_FLAGS }; - int ret; - - msg.msg_iter = *it; - while (iov_iter_count(it)) { - ret = sock_sendmsg(sock, &msg); - if (ret <= 0) { - if (ret == -EAGAIN) - ret = 0; - return ret; - } - - iov_iter_advance(it, ret); - } - - WARN_ON(msg_data_left(&msg)); - return 1; -} - -static int do_try_sendpage(struct socket *sock, struct iov_iter *it) -{ - struct msghdr msg = { .msg_flags = CEPH_MSG_FLAGS }; - struct bio_vec bv; - int ret; - - if (WARN_ON(!iov_iter_is_bvec(it))) - return -EINVAL; - - while (iov_iter_count(it)) { - /* iov_iter_iovec() for ITER_BVEC */ - bvec_set_page(&bv, it->bvec->bv_page, - min(iov_iter_count(it), - it->bvec->bv_len - it->iov_offset), - it->bvec->bv_offset + it->iov_offset); - - /* - * sendpage cannot properly handle pages with - * page_count == 0, we need to fall back to sendmsg if - * that's the case. - * - * Same goes for slab pages: skb_can_coalesce() allows - * coalescing neighboring slab objects into a single frag - * which triggers one of hardened usercopy checks. - */ - if (sendpage_ok(bv.bv_page)) { - ret = sock->ops->sendpage(sock, bv.bv_page, - bv.bv_offset, bv.bv_len, - CEPH_MSG_FLAGS); - } else { - iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bv, 1, bv.bv_len); - ret = sock_sendmsg(sock, &msg); - } - if (ret <= 0) { - if (ret == -EAGAIN) - ret = 0; - return ret; - } - - iov_iter_advance(it, ret); - } - - return 1; -} - /* * Write as much as possible. The socket is expected to be corked, - * so we don't bother with MSG_MORE/MSG_SENDPAGE_NOTLAST here. + * so we don't bother with MSG_MORE here. * * Return: - * 1 - done, nothing (else) to write + * >0 - done, nothing (else) to write * 0 - socket is full, need to wait * <0 - error */ static int ceph_tcp_send(struct ceph_connection *con) { + struct msghdr msg = { + .msg_iter = con->v2.out_iter, + .msg_flags = CEPH_MSG_FLAGS, + }; int ret; + if (WARN_ON(!iov_iter_is_bvec(&con->v2.out_iter))) + return -EINVAL; + + if (con->v2.out_iter_sendpage) + msg.msg_flags |= MSG_SPLICE_PAGES; + dout("%s con %p have %zu try_sendpage %d\n", __func__, con, iov_iter_count(&con->v2.out_iter), con->v2.out_iter_sendpage); - if (con->v2.out_iter_sendpage) - ret = do_try_sendpage(con->sock, &con->v2.out_iter); - else - ret = do_sendmsg(con->sock, &con->v2.out_iter); + + ret = sock_sendmsg(con->sock, &msg); + if (ret > 0) + iov_iter_advance(&con->v2.out_iter, ret); + else if (ret == -EAGAIN) + ret = 0; + dout("%s con %p ret %d left %zu\n", __func__, con, ret, iov_iter_count(&con->v2.out_iter)); return ret; From patchwork Fri Jun 16 16:12:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13282940 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 630A9EB64DA for ; Fri, 16 Jun 2023 16:13:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B5E888E000A; Fri, 16 Jun 2023 12:13:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AE4588E0001; Fri, 16 Jun 2023 12:13:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 914918E000B; Fri, 16 Jun 2023 12:13:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 754EE8E000A for ; Fri, 16 Jun 2023 12:13:39 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 3EF241A0CF2 for ; Fri, 16 Jun 2023 16:13:39 +0000 (UTC) X-FDA: 80909106558.19.956AB4B Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf12.hostedemail.com (Postfix) with ESMTP id 7A56A4000C for ; Fri, 16 Jun 2023 16:13:37 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=BtOL9WWI; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf12.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=1686932017; 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=Fr8R9cUCocDj4LYXtGmeXkCgA5OgO4hqxYPqdNjfTX8=; b=MTP2NvShedb9uWZZrTNOdhi1rcJ4CM7/XMdGX6bOjLsjSOwDEJLnCO/uDmJZcksQAdPNSw gh5rm46h4NDXC5fXzi9OEJSZde7/6QyFhGbEXBYN4ZzbXaG4cJbeEsjn0EfvXWCiSYxmPo Z/oinAZ5dbf2PfhBMKAZttqf2d5AcxQ= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=BtOL9WWI; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf12.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=1686932017; a=rsa-sha256; cv=none; b=EsZIHIDCYMc6SS1wIIzBZgOnj1GXeQukBDlNSzHr49EE7lmNjScxMSmnwxojFPbnlHOtQT H7IRCaUh6d4w3psBXjrap4ovTNBSwnqq09zHyZM+b03T6qsKKB3WHiY4tInNO2ds7Ydk8W Ck7TuZrdGo9XNAqq7AIRLC3MaxsiJ7g= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686932016; 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=Fr8R9cUCocDj4LYXtGmeXkCgA5OgO4hqxYPqdNjfTX8=; b=BtOL9WWIv7I4EkbNQtsc+VhJm8AdIdsSnO5nP8VNQRV2R+a4r1Zy8M1QW8QDz7nmMXKRp2 FrNrD6M7cpHTlqWbNHLCpj7fFpSqEp1qOtN9ZCNOQRBtMs+cfKEK1/pUZz1CQk6Z+Peg2F OPjHGLWAgwc7h6NgaJVBbdvE/vBsbH4= 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-627-m0GIPd8iMeWBnIZd0MxhlQ-1; Fri, 16 Jun 2023 12:13:33 -0400 X-MC-Unique: m0GIPd8iMeWBnIZd0MxhlQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CDEC81C05ABF; Fri, 16 Jun 2023 16:13:32 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id 054141121314; Fri, 16 Jun 2023 16:13:30 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Alexander Duyck , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , Jens Axboe , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Santosh Shilimkar , linux-rdma@vger.kernel.org, rds-devel@oss.oracle.com Subject: [PATCH net-next 08/17] rds: Use sendmsg(MSG_SPLICE_PAGES) rather than sendpage Date: Fri, 16 Jun 2023 17:12:51 +0100 Message-ID: <20230616161301.622169-9-dhowells@redhat.com> In-Reply-To: <20230616161301.622169-1-dhowells@redhat.com> References: <20230616161301.622169-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Rspam-User: X-Stat-Signature: 3kwmkobyoadu4wwjbnejr5e4yttz148x X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 7A56A4000C X-HE-Tag: 1686932017-143370 X-HE-Meta: U2FsdGVkX1/V0cD/8V4Qwjy5ROHQxmFA9EUZbvLW9u5StxYU5PoU4N/YBSf/W4sTmId0Vd6FtW0Un3X56jnaB59zwuX8wYvhfOuaOZHjO3zRXCEGEjolAZ3u0av7l5QbnRxtqPn/yKAxouLRzYbKXM5hhEaMnprpaY8rzs6OHUSiDzjabZy8/N/waM9+8uu6Hahak2QCdtD+aksKAFTu8n1zAiE0bVXm8REMwp6jE88b3jm9E0y69JcBqBFr6lWY1lbYDgYZwZT2Bfgq1Kwr35t53s6OJFIZMlyFnYIhlbZsdDZxq5MuMHqtt7Wn5txt7BZ7nY33cnUhI1pHfPTntqNeZ1TVud/Z/qdGe106TRUqPVtdI9Yqv0LmmxsEgGC8CT7G27Tez3V+W8z8MJ1t0nju6zRfWIBHHy5DbGxn6oIyKZQtp0rf6f+tuJtsy1Z2p/4w6KYd/s4DwPUU+abxc4jALVc+cmigFR6O2KLTzs2+JARLGxeOTxiO+Ufy0ROAUO7XuM5TwbQhUSfrGZnZPwEVzRE/rUfH0r5NJhpXkuyUY8xEJ5iTLuH1I7bNz4Q8oOSYWSljZGisdNjT2/Pt115lOzyO0IpYewYf9Jgr1g4/NoK+8QVyeuOo5//9mZz8VfucLTXKhAToQgnLlQ3YtaiZlOr2wSCfc6dhm4e5H23e4PweKqCbe1zMoHH0321Payv8nkv04eMBgWetY4ohBC5jccokynpt9akKeOwzJLOaZFEEEeIK3PG7/hDES251KXSVOSjsWRhoBBfGqq3hGI3G3Wc/LhjHLSTQkpsTazwEVZw8ld1nKMjiqmWSkIIrIVPJkj6455HgQrCJvs3urhClx/fJMCf5ULtfVwknHLHcjZqlXPzhK/tFIQPVjoHF2TrirDsGEgiEJAfb0ydskhX3nryCCPJbDli99FIYS02ZLuB1V+j0UQDUXj5d2a5nljEmpUlWGxzZXvA7dsH YH2X9Kgl LBB0uDY1HsvdxxscXTsvH+2pZdPaDitEeqTwYpCuOe9sFvGcKcq8Q+MC3bVbpAFzYw0yd/bpqNa+Sgf07OuU8SxNpU/VNz3zlt5QMhkNQIgLuyvBadrrtKe6r9wIA9qsjg6G3vLPkrrh166gzmQ6bUICWhITzG1O3+focJz97M2IjTCcpwHDI1uuf6RG8bRVlUqukzIP67vW0nikV4KVcjeOESOQf9gLLhfP9o2evWKG9FJ/HCK8eSik0HNvvE7zCh0WRtkq+jFcDHeQUgvkKb8tcbXnYSL1QCld6gQWE8fLNW5uCOIFMwD/JJ+1FvcQoq0nQ6GBIGRSyjGsWrXoiJ5R2wlygQ8qXlxnHJrwIBsfEg9VmwOfwpGHdJPl+tJ+tb8BJVaFChzDzXuHt3PaKB7k4LhqwQruvvS/WPvAnklh+exxfR8EtPVrpkxEii4jBy6htosqMdJ3tIUMd26Yi7S8AKF+T4rdLbS9uxbcG34l4ZWnH9hv5eVmlwftJAHMNUfECFLPLwffvups= 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: When transmitting data, call down into TCP using a single sendmsg with MSG_SPLICE_PAGES to indicate that content should be spliced rather than performing several sendmsg and sendpage calls to transmit header and data pages. To make this work, the data is assembled in a bio_vec array and attached to a BVEC-type iterator. The header are copied into memory acquired from zcopy_alloc() which just breaks a page up into small pieces that can be freed with put_page(). Signed-off-by: David Howells cc: Santosh Shilimkar cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: Jens Axboe cc: Matthew Wilcox cc: linux-rdma@vger.kernel.org cc: rds-devel@oss.oracle.com cc: netdev@vger.kernel.org --- net/rds/tcp_send.c | 74 +++++++++++++++++----------------------------- 1 file changed, 27 insertions(+), 47 deletions(-) diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c index 8c4d1d6e9249..550390d5ff2b 100644 --- a/net/rds/tcp_send.c +++ b/net/rds/tcp_send.c @@ -52,29 +52,23 @@ void rds_tcp_xmit_path_complete(struct rds_conn_path *cp) tcp_sock_set_cork(tc->t_sock->sk, false); } -/* the core send_sem serializes this with other xmit and shutdown */ -static int rds_tcp_sendmsg(struct socket *sock, void *data, unsigned int len) -{ - struct kvec vec = { - .iov_base = data, - .iov_len = len, - }; - struct msghdr msg = { - .msg_flags = MSG_DONTWAIT | MSG_NOSIGNAL, - }; - - return kernel_sendmsg(sock, &msg, &vec, 1, vec.iov_len); -} - /* the core send_sem serializes this with other xmit and shutdown */ int rds_tcp_xmit(struct rds_connection *conn, struct rds_message *rm, unsigned int hdr_off, unsigned int sg, unsigned int off) { struct rds_conn_path *cp = rm->m_inc.i_conn_path; struct rds_tcp_connection *tc = cp->cp_transport_data; + struct msghdr msg = { + .msg_flags = MSG_SPLICE_PAGES | MSG_DONTWAIT | MSG_NOSIGNAL, + }; + struct bio_vec *bvec; + unsigned int i, size = 0, ix = 0; int done = 0; - int ret = 0; - int more; + int ret = -ENOMEM; + + bvec = kmalloc_array(1 + sg, sizeof(struct bio_vec), GFP_KERNEL); + if (!bvec) + goto out; if (hdr_off == 0) { /* @@ -101,41 +95,26 @@ int rds_tcp_xmit(struct rds_connection *conn, struct rds_message *rm, /* see rds_tcp_write_space() */ set_bit(SOCK_NOSPACE, &tc->t_sock->sk->sk_socket->flags); - ret = rds_tcp_sendmsg(tc->t_sock, - (void *)&rm->m_inc.i_hdr + hdr_off, - sizeof(rm->m_inc.i_hdr) - hdr_off); - if (ret < 0) - goto out; - done += ret; - if (hdr_off + done != sizeof(struct rds_header)) - goto out; + bvec_set_virt(&bvec[ix], (void *)&rm->m_inc.i_hdr + hdr_off, + sizeof(rm->m_inc.i_hdr) - hdr_off); + size += bvec[ix].bv_len; + ix++; } - more = rm->data.op_nents > 1 ? (MSG_MORE | MSG_SENDPAGE_NOTLAST) : 0; - while (sg < rm->data.op_nents) { - int flags = MSG_DONTWAIT | MSG_NOSIGNAL | more; - - ret = tc->t_sock->ops->sendpage(tc->t_sock, - sg_page(&rm->data.op_sg[sg]), - rm->data.op_sg[sg].offset + off, - rm->data.op_sg[sg].length - off, - flags); - rdsdebug("tcp sendpage %p:%u:%u ret %d\n", (void *)sg_page(&rm->data.op_sg[sg]), - rm->data.op_sg[sg].offset + off, rm->data.op_sg[sg].length - off, - ret); - if (ret <= 0) - break; - - off += ret; - done += ret; - if (off == rm->data.op_sg[sg].length) { - off = 0; - sg++; - } - if (sg == rm->data.op_nents - 1) - more = 0; + for (i = sg; i < rm->data.op_nents; i++) { + bvec_set_page(&bvec[ix], + sg_page(&rm->data.op_sg[i]), + rm->data.op_sg[i].length - off, + rm->data.op_sg[i].offset + off); + off = 0; + size += bvec[ix].bv_len; + ix++; } + iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, bvec, ix, size); + ret = sock_sendmsg(tc->t_sock, &msg); + rdsdebug("tcp sendmsg-splice %u,%u ret %d\n", ix, size, ret); + out: if (ret <= 0) { /* write_space will hit after EAGAIN, all else fatal */ @@ -158,6 +137,7 @@ int rds_tcp_xmit(struct rds_connection *conn, struct rds_message *rm, } if (done == 0) done = ret; + kfree(bvec); return done; } From patchwork Fri Jun 16 16:12:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13282941 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 EE158EB64D8 for ; Fri, 16 Jun 2023 16:13:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 87D6B900002; Fri, 16 Jun 2023 12:13:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 789148E0001; Fri, 16 Jun 2023 12:13:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 651B9900002; Fri, 16 Jun 2023 12:13:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 55B0C8E0001 for ; Fri, 16 Jun 2023 12:13:43 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 24ADBC0CC3 for ; Fri, 16 Jun 2023 16:13:43 +0000 (UTC) X-FDA: 80909106726.08.DF5F1E3 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf04.hostedemail.com (Postfix) with ESMTP id 465C340007 for ; Fri, 16 Jun 2023 16:13:40 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=T0igldnw; spf=pass (imf04.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686932021; a=rsa-sha256; cv=none; b=OAwSL27UUoMznuw/0SUbN2NivspveVRai+l0ktQsktq0TuD03boILmIZ5s/gSDWPSFdCz3 z6AOLfKWOKJptv4hx1AJbqbwB1NbzKQW9alYHocs7tXeMe0A9sdZqIyR+TXkrrAvIfGPht +a85RKNz9eemjRk99bIST2K8xYz4ZRg= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=T0igldnw; spf=pass (imf04.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=1686932021; 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=CX0szcw738ZS8htZ0RxEmjBFgUMhbKSUPMuc1XxmplE=; b=V/nkwamxXxRLhLT/lnc0b1tLxR76tq0fuH2AF3sKVh9AY46K9IPrxJ7zepf0n8q55s/rTx 2OP8VX2j613y67c9XC9PscP3GOjVu9V1iamG0hWa6TJFXyK4Jxkhf9/3757XcgMVBiZiLI 0vdle8Z3J5EkNVSZeo8IcdX9jFF/4wk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686932020; 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=CX0szcw738ZS8htZ0RxEmjBFgUMhbKSUPMuc1XxmplE=; b=T0igldnwVU5O4dqeOJO+cgWjWePL8QBQWdqCG5AmQEWivP0frQg7DOrBcDmrvvhW2Wrvj9 Io5o74Ue8vCR9EMVSVrxmBjzlPgBKCL4CNlTKG79dozQfI3JJmcqtq1bc/J3f6vaqavDFj QR4F0SZchSzOvs/PLiHsLn3MuXIj6hU= 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-177-8EMyMs2DPWaeQu2vizf65w-1; Fri, 16 Jun 2023 12:13:37 -0400 X-MC-Unique: 8EMyMs2DPWaeQu2vizf65w-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8823129AB3E3; Fri, 16 Jun 2023 16:13:36 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id 76298422B0; Fri, 16 Jun 2023 16:13:33 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Alexander Duyck , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , Jens Axboe , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Christine Caulfield , David Teigland , cluster-devel@redhat.com Subject: [PATCH net-next 09/17] dlm: Use sendmsg(MSG_SPLICE_PAGES) rather than sendpage Date: Fri, 16 Jun 2023 17:12:52 +0100 Message-ID: <20230616161301.622169-10-dhowells@redhat.com> In-Reply-To: <20230616161301.622169-1-dhowells@redhat.com> References: <20230616161301.622169-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 465C340007 X-Stat-Signature: 4kn6w5mpzs3zpae3km9ubgya83mftbic X-Rspam-User: X-HE-Tag: 1686932020-706729 X-HE-Meta: U2FsdGVkX1+mH7DGIUuqzdnU/40fCu5TKZaOI/NjvXciQ32hgbg9u9nRAt4qmeaJLVIUjXUOB6nV1v69N1XAHCvZ1gjaSGbU3ot3bPSviYg0kkQslcCePeerIwYLknVR68R78o0Lkjy/9j3mGASQ6gHeu6OBqQxrdQz8rC5knWj0nt6XY+G3zv3lg9uhf2fTGpJts4T+4zvXjQGLfbLqhAsGwNsUJRJEthW/g8b3DVWoiSnIsBl6geS6vsFQA6IDNwD1TX5JbhLKkrpWLXeDtbBG8JKAeIEdoQYSW/NvaHTp5Ef6l3zZO/b7In+JBz/42WIHKHqaBFfLsaDA3KzLGmtHITyJM+0tR7/139+dTTOmbaxW2WxrewfjfLElzRCA5IKRIF5ddYrwoXmw8xYe9NFwKe1xOo+StJL3LqhtUgKNfm98lYZzgFCj5z+SJqz/pv2/oZKCyO3CP6FDYhP9TW67RzWzTNHTyHDywWhS5iTJ+iyGrJzWy7KnQSezbnRu+quDqs4Bz7ljfRVEytVk3GJX0kuOZ9L4NqRy9vo/495uIGHfcJBPkbL9fZxYUp7A/qQSef/fGXLnRbvHiXlFin4CLQcRnfb5gnHplhfKzeA7yHVkPxKFOAiownjUW9q8DKqbFL1aVpUlKptVVyZH8eGHKmWksslGgsOIPjqGo0FMtq/hYXnnv1NpwELIfuhZGHDCQXGg/d5Zon6Ork3og2A6je0zb6FRsh+v9pNpurrfk9/Lhmo3SzBO8Sl60dFRZzR+wXFijCDHCQHd2uJMxCHFilW1sgtrly+GE+Skqp5ijFRDS0GK1m7u+FVKfyWm/aTGlHO6JBF2jt8US0RQil9L7ehXG/t2gC9IPyZ9RktViCCELgd+TXtn/6/l34fmHqdn92p1E7AfRjBJtcDc+OT6zdId5vufPqzeKnnv1ycX2xy2s5ihq5KZFA6eBm+F8cMNdCbBSoP5KSQNIUe FOrJWJry pent+r39HJbaugBuqA4AfktNvQ5tzpx+q3CHePSp3wKZm3aBp4m5WZkke4WKGbwYUPjRRFJg7nrAKRzgQ51DnRxPueKb5EaOU5lMhpKEtpU+rWVNqcwd4Zo3X09Ldgyir2VEFajO5uy9C+LHJwX2TiwPQqwQSzvFuMeSyN2Zw6IJ/g4dXzpe2Vh6KWqTswgqkaklzxL/v40KuGxv1d9T9P//DYWYPderpEaKIRI3af6ZL6cKCm+kfDr5ihJHo9R2KOr/nA0jftxISgNRYL0RAOKtVrz/mNTDYBy4cR5mEj1Ei4WA+ZpNhv349xDSz5/iX/HJsQIvK+SiwTPISM3WPLBIvBO8EUXWbsWF6edH8iEC/m9dvun20FNAnoznKvG7IcwMQImf0Q3BrcArFAo3utAdg5L4Gvy96v76YVsbgb7Yq2hJnUuAUfEE84Z3n77AKRyiMzYdGyfcNC6QFEl1Px3ohSs6mKUG/K1b67frZbTw/d5dUPLYl9M3iBw== 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: When transmitting data, call down a layer using a single sendmsg with MSG_SPLICE_PAGES to indicate that content should be spliced rather using sendpage. This allows ->sendpage() to be replaced by something that can handle multiple multipage folios in a single transaction. Signed-off-by: David Howells cc: Christine Caulfield cc: David Teigland cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: Jens Axboe cc: Matthew Wilcox cc: cluster-devel@redhat.com cc: netdev@vger.kernel.org --- fs/dlm/lowcomms.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms.c index 3d3802c47b8b..5c12d8cdfc16 100644 --- a/fs/dlm/lowcomms.c +++ b/fs/dlm/lowcomms.c @@ -1395,8 +1395,11 @@ int dlm_lowcomms_resend_msg(struct dlm_msg *msg) /* Send a message */ static int send_to_sock(struct connection *con) { - const int msg_flags = MSG_DONTWAIT | MSG_NOSIGNAL; struct writequeue_entry *e; + struct bio_vec bvec; + struct msghdr msg = { + .msg_flags = MSG_SPLICE_PAGES | MSG_DONTWAIT | MSG_NOSIGNAL, + }; int len, offset, ret; spin_lock_bh(&con->writequeue_lock); @@ -1412,8 +1415,9 @@ static int send_to_sock(struct connection *con) WARN_ON_ONCE(len == 0 && e->users == 0); spin_unlock_bh(&con->writequeue_lock); - ret = kernel_sendpage(con->sock, e->page, offset, len, - msg_flags); + bvec_set_page(&bvec, e->page, len, offset); + iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bvec, 1, len); + ret = sock_sendmsg(con->sock, &msg); trace_dlm_send(con->nodeid, ret); if (ret == -EAGAIN || ret == 0) { lock_sock(con->sock->sk); From patchwork Fri Jun 16 16:12:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13282942 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 BE17FEB64D8 for ; Fri, 16 Jun 2023 16:13:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5DD8D940007; Fri, 16 Jun 2023 12:13:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5B5D38E0001; Fri, 16 Jun 2023 12:13:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 45577940007; Fri, 16 Jun 2023 12:13:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 342978E0001 for ; Fri, 16 Jun 2023 12:13:47 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 050F5A0B8E for ; Fri, 16 Jun 2023 16:13:46 +0000 (UTC) X-FDA: 80909106894.01.A876C2D Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf15.hostedemail.com (Postfix) with ESMTP id 21C9DA0022 for ; Fri, 16 Jun 2023 16:13:44 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=M7r9P8Pl; spf=pass (imf15.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=1686932025; 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=LjLAMzNfvZhacy7TMP165gYQvQOU+UG7wgtZUHPODnQ=; b=e9nT2t0Sves6spouiEhlG3lbDmbHxOVPw3RKtx3Qko7XjUshAKnyGi0/xnBGfsVdUskkvI BhbqigG7kksXZ0C8anRgGizrsqDnZboy29QhRyKfiHuSHHG/JkNOPd96JPqQHWOT9klx8J 926omEV779Cm7FlV54KWEgsL4fiVF+g= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686932025; a=rsa-sha256; cv=none; b=JD5Ldng73gMHuKh+Xj0vzTFJTIgx9hKLPh08whhDhYDYE/f6DSlKfU8WMplqjQTRzyFRqh UTvq9mczl6z9vwGEoBls5xXzC5DhknjyvVp331qzxgNqPxMO3RWHLGw9OesavWKWIctlcp kguh86K09sV72LpMqj4cDeVsmeok6m8= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=M7r9P8Pl; spf=pass (imf15.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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686932024; 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=LjLAMzNfvZhacy7TMP165gYQvQOU+UG7wgtZUHPODnQ=; b=M7r9P8Pl0kX29hGjikY81KkgEnkH3jJFfCeAD7qibSF+HB14YI86Q85rOez2JeTQ/bM+Ay uQwyaKA9YPqx8wivL+pnLhXqGYDgCkc/Kaa3EbxiDrsRxTtVEuHSevmEhYyfVfKVXSdWBc 8IEIjJhf1fMz5gBg5Je28MTUT8jVSzY= 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-602-ZlJJyylbON2KeVO0CVHemQ-1; Fri, 16 Jun 2023 12:13:40 -0400 X-MC-Unique: ZlJJyylbON2KeVO0CVHemQ-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 E694338041D5; Fri, 16 Jun 2023 16:13:39 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id B3E0A40D1B60; Fri, 16 Jun 2023 16:13:37 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Alexander Duyck , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , Jens Axboe , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , Chaitanya Kulkarni , linux-nvme@lists.infradead.org Subject: [PATCH net-next 10/17] nvme: Use sendmsg(MSG_SPLICE_PAGES) rather then sendpage Date: Fri, 16 Jun 2023 17:12:53 +0100 Message-ID: <20230616161301.622169-11-dhowells@redhat.com> In-Reply-To: <20230616161301.622169-1-dhowells@redhat.com> References: <20230616161301.622169-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Stat-Signature: i749r9yad9xcm9xhws3f1oia4ka9kwat X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 21C9DA0022 X-Rspam-User: X-HE-Tag: 1686932024-969646 X-HE-Meta: U2FsdGVkX19EtvILB2ELL4zqgWCSOVClIp9ze4WkEmxim1wK4x2Zoo/nr4H1Vm1tqsecOXCIqol59YIWalRgu5mmAzdAJSQ8a6sDVSeaWes5HuChnn/pvzCIghSTjuADx9YMsTgn5UjWNppX5rypjCeed79Tfobcmiq9kZ98U1oZoDB4F1CV8wt47/hsKM2+00jeuDqh6THOWCcR6AUamN5RNscbz3wNJAg/fqgFFV5sWjxPA1vwqvpXI9TbBYBj5puSIkX7s4B1Q9OtopF76Ee1bUUp808VLyl6z9YoTtzmW/+jjgXKzS7+dn4xVrOGU0kEvA+NCCYeMc2Di4iER5mLXCSZJhh8j9LFLTEFtiVPz6n25rkvOlQXuKEvodNZDym6YvJEcH6bm68Rfxt5P5PyXGgQYVZS+b07fdZ2ai6vBg+tF7hFWmn4p/IyY3iP9ZUNY6BkWI1pY6fItunToWYhsPMBezrFLTmiMYEiWNhjycs6+x7FjjzfU4V2i07Csn7GOM6HKLnzPuiD3f661GaLz6pSXwR2xha4545xoyL9Kgedsr0Rd0Bx+273ZkBPsT0vTd4/QEAPQHC/VR7wtrKfjmYOXKLrWunJuvKQa5697da4OqnKlQCOFHqwKQDzrNpd/6P3ZBoYKsauv7QbZJWyBhjTAlza5hbrwGFonsLcvdJtHs00hdslrnmKKpWtbtvGAUhetWPd/+Tn/VC7ZWqAMWNVE9m22Szi0OX3uv86MCDqO4pe8+IYEEJt2ERaUHkh826VWyICvGd+TBAkuQo5Hl0cDyUdGavUc/YPB9G5e8joS87SOf6d0MEYlxfc7BnR3uki7FfLz+TNlNPQhFuHjOlIzrTUumcSbYVAMd6X+LcAPNWuvmMcvOQr4WGNV40nUqfQ9DD8r2Fj6Hc0lQBjTEPikn2zu28DQUvh3rKwKUDnXc/Ff1B8iXMWtqTeTATqjI8LlTN9Be8SuSt cXQXY+4V SRo9pwVNgLcD9PQGY8JnP6OZpFV0KJ6lwo+UcmGjHCU7x/A8xgAY80lnAbXd7B2YOeDedkypuux5WtI1DFrftriJo7DMcBIofNvJA1sJBwtTW+zPn2WG3sHHYVtE3xmNDDNBrooo0G+Jp+GATGtTR8krfet68pwnEGSGCchoX3ps3BLPf6YF+ZERIZ9Zc/Bt1w36aKl2PavJG1lc4WMs7sbvgknO0T5MjJdy0OUIhsLNC43Xr4ydOe+v/SgWJH5SDN4cZTwm55dT8qd26I+p/1UxA1gGJuGBjO3oLkXVVja7lt+z0pFeuJ0bpoeH1r6DOhXI+eqp85bq4p6Lr7XkWS4+JTIkD1foTEDwoa4nnDiTOqRTw2cHvylFgigSbTuF/a3gMEEbj+4a5bauwLt4AsF3A4puBhJzWD31NEVqBynA6Ux09rw5qQ3e3NCUCjmLskBMF6gcxxlGqaAzoO+TMd4yXE9F8r9Z8VL96no6o6Ydvy8AwX3qR4DoU3SV6ya4O+zwnikiXBLYDLxNJCJjABIiMlVjBGy8chUMMIBb3fsnrLOaYwIrJlMwNr0WgQgWQ2lSOMGyp9YGem2Y= 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: When transmitting data, call down into TCP using a single sendmsg with MSG_SPLICE_PAGES to indicate that content should be spliced rather than performing several sendmsg and sendpage calls to transmit header, data pages and trailer. Signed-off-by: David Howells cc: Keith Busch cc: Jens Axboe cc: Christoph Hellwig cc: Sagi Grimberg cc: Chaitanya Kulkarni cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: Jens Axboe cc: Matthew Wilcox cc: linux-nvme@lists.infradead.org cc: netdev@vger.kernel.org --- drivers/nvme/host/tcp.c | 44 ++++++++++++++++++------------------- drivers/nvme/target/tcp.c | 46 ++++++++++++++++++++++++--------------- 2 files changed, 51 insertions(+), 39 deletions(-) diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c index bf0230442d57..947868c66ef4 100644 --- a/drivers/nvme/host/tcp.c +++ b/drivers/nvme/host/tcp.c @@ -997,25 +997,23 @@ static int nvme_tcp_try_send_data(struct nvme_tcp_request *req) u32 h2cdata_left = req->h2cdata_left; while (true) { + struct bio_vec bvec; + struct msghdr msg = { .msg_flags = MSG_DONTWAIT | MSG_SPLICE_PAGES, }; struct page *page = nvme_tcp_req_cur_page(req); size_t offset = nvme_tcp_req_cur_offset(req); size_t len = nvme_tcp_req_cur_length(req); bool last = nvme_tcp_pdu_last_send(req, len); int req_data_sent = req->data_sent; - int ret, flags = MSG_DONTWAIT; + int ret; if (last && !queue->data_digest && !nvme_tcp_queue_more(queue)) - flags |= MSG_EOR; + msg.msg_flags |= MSG_EOR; else - flags |= MSG_MORE | MSG_SENDPAGE_NOTLAST; + msg.msg_flags |= MSG_MORE; - if (sendpage_ok(page)) { - ret = kernel_sendpage(queue->sock, page, offset, len, - flags); - } else { - ret = sock_no_sendpage(queue->sock, page, offset, len, - flags); - } + bvec_set_page(&bvec, page, len, offset); + iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bvec, 1, len); + ret = sock_sendmsg(queue->sock, &msg); if (ret <= 0) return ret; @@ -1054,22 +1052,24 @@ static int nvme_tcp_try_send_cmd_pdu(struct nvme_tcp_request *req) { struct nvme_tcp_queue *queue = req->queue; struct nvme_tcp_cmd_pdu *pdu = nvme_tcp_req_cmd_pdu(req); + struct bio_vec bvec; + struct msghdr msg = { .msg_flags = MSG_DONTWAIT | MSG_SPLICE_PAGES, }; bool inline_data = nvme_tcp_has_inline_data(req); u8 hdgst = nvme_tcp_hdgst_len(queue); int len = sizeof(*pdu) + hdgst - req->offset; - int flags = MSG_DONTWAIT; int ret; if (inline_data || nvme_tcp_queue_more(queue)) - flags |= MSG_MORE | MSG_SENDPAGE_NOTLAST; + msg.msg_flags |= MSG_MORE; else - flags |= MSG_EOR; + msg.msg_flags |= MSG_EOR; if (queue->hdr_digest && !req->offset) nvme_tcp_hdgst(queue->snd_hash, pdu, sizeof(*pdu)); - ret = kernel_sendpage(queue->sock, virt_to_page(pdu), - offset_in_page(pdu) + req->offset, len, flags); + bvec_set_virt(&bvec, (void *)pdu + req->offset, len); + iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bvec, 1, len); + ret = sock_sendmsg(queue->sock, &msg); if (unlikely(ret <= 0)) return ret; @@ -1093,6 +1093,8 @@ static int nvme_tcp_try_send_data_pdu(struct nvme_tcp_request *req) { struct nvme_tcp_queue *queue = req->queue; struct nvme_tcp_data_pdu *pdu = nvme_tcp_req_data_pdu(req); + struct bio_vec bvec; + struct msghdr msg = { .msg_flags = MSG_DONTWAIT | MSG_MORE, }; u8 hdgst = nvme_tcp_hdgst_len(queue); int len = sizeof(*pdu) - req->offset + hdgst; int ret; @@ -1101,13 +1103,11 @@ static int nvme_tcp_try_send_data_pdu(struct nvme_tcp_request *req) nvme_tcp_hdgst(queue->snd_hash, pdu, sizeof(*pdu)); if (!req->h2cdata_left) - ret = kernel_sendpage(queue->sock, virt_to_page(pdu), - offset_in_page(pdu) + req->offset, len, - MSG_DONTWAIT | MSG_MORE | MSG_SENDPAGE_NOTLAST); - else - ret = sock_no_sendpage(queue->sock, virt_to_page(pdu), - offset_in_page(pdu) + req->offset, len, - MSG_DONTWAIT | MSG_MORE); + msg.msg_flags |= MSG_SPLICE_PAGES; + + bvec_set_virt(&bvec, (void *)pdu + req->offset, len); + iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bvec, 1, len); + ret = sock_sendmsg(queue->sock, &msg); if (unlikely(ret <= 0)) return ret; diff --git a/drivers/nvme/target/tcp.c b/drivers/nvme/target/tcp.c index ed98df72c76b..868aa4de2e4c 100644 --- a/drivers/nvme/target/tcp.c +++ b/drivers/nvme/target/tcp.c @@ -576,13 +576,17 @@ static void nvmet_tcp_execute_request(struct nvmet_tcp_cmd *cmd) static int nvmet_try_send_data_pdu(struct nvmet_tcp_cmd *cmd) { + struct msghdr msg = { + .msg_flags = MSG_DONTWAIT | MSG_MORE | MSG_SPLICE_PAGES, + }; + struct bio_vec bvec; u8 hdgst = nvmet_tcp_hdgst_len(cmd->queue); int left = sizeof(*cmd->data_pdu) - cmd->offset + hdgst; int ret; - ret = kernel_sendpage(cmd->queue->sock, virt_to_page(cmd->data_pdu), - offset_in_page(cmd->data_pdu) + cmd->offset, - left, MSG_DONTWAIT | MSG_MORE | MSG_SENDPAGE_NOTLAST); + bvec_set_virt(&bvec, (void *)cmd->data_pdu + cmd->offset, left); + iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bvec, 1, left); + ret = sock_sendmsg(cmd->queue->sock, &msg); if (ret <= 0) return ret; @@ -603,17 +607,21 @@ static int nvmet_try_send_data(struct nvmet_tcp_cmd *cmd, bool last_in_batch) int ret; while (cmd->cur_sg) { + struct msghdr msg = { + .msg_flags = MSG_DONTWAIT | MSG_SPLICE_PAGES, + }; struct page *page = sg_page(cmd->cur_sg); + struct bio_vec bvec; u32 left = cmd->cur_sg->length - cmd->offset; - int flags = MSG_DONTWAIT; if ((!last_in_batch && cmd->queue->send_list_len) || cmd->wbytes_done + left < cmd->req.transfer_len || queue->data_digest || !queue->nvme_sq.sqhd_disabled) - flags |= MSG_MORE | MSG_SENDPAGE_NOTLAST; + msg.msg_flags |= MSG_MORE; - ret = kernel_sendpage(cmd->queue->sock, page, cmd->offset, - left, flags); + bvec_set_page(&bvec, page, left, cmd->offset); + iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bvec, 1, left); + ret = sock_sendmsg(cmd->queue->sock, &msg); if (ret <= 0) return ret; @@ -649,18 +657,20 @@ static int nvmet_try_send_data(struct nvmet_tcp_cmd *cmd, bool last_in_batch) static int nvmet_try_send_response(struct nvmet_tcp_cmd *cmd, bool last_in_batch) { + struct msghdr msg = { .msg_flags = MSG_DONTWAIT | MSG_SPLICE_PAGES, }; + struct bio_vec bvec; u8 hdgst = nvmet_tcp_hdgst_len(cmd->queue); int left = sizeof(*cmd->rsp_pdu) - cmd->offset + hdgst; - int flags = MSG_DONTWAIT; int ret; if (!last_in_batch && cmd->queue->send_list_len) - flags |= MSG_MORE | MSG_SENDPAGE_NOTLAST; + msg.msg_flags |= MSG_MORE; else - flags |= MSG_EOR; + msg.msg_flags |= MSG_EOR; - ret = kernel_sendpage(cmd->queue->sock, virt_to_page(cmd->rsp_pdu), - offset_in_page(cmd->rsp_pdu) + cmd->offset, left, flags); + bvec_set_virt(&bvec, (void *)cmd->rsp_pdu + cmd->offset, left); + iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bvec, 1, left); + ret = sock_sendmsg(cmd->queue->sock, &msg); if (ret <= 0) return ret; cmd->offset += ret; @@ -677,18 +687,20 @@ static int nvmet_try_send_response(struct nvmet_tcp_cmd *cmd, static int nvmet_try_send_r2t(struct nvmet_tcp_cmd *cmd, bool last_in_batch) { + struct msghdr msg = { .msg_flags = MSG_DONTWAIT | MSG_SPLICE_PAGES, }; + struct bio_vec bvec; u8 hdgst = nvmet_tcp_hdgst_len(cmd->queue); int left = sizeof(*cmd->r2t_pdu) - cmd->offset + hdgst; - int flags = MSG_DONTWAIT; int ret; if (!last_in_batch && cmd->queue->send_list_len) - flags |= MSG_MORE | MSG_SENDPAGE_NOTLAST; + msg.msg_flags |= MSG_MORE; else - flags |= MSG_EOR; + msg.msg_flags |= MSG_EOR; - ret = kernel_sendpage(cmd->queue->sock, virt_to_page(cmd->r2t_pdu), - offset_in_page(cmd->r2t_pdu) + cmd->offset, left, flags); + bvec_set_virt(&bvec, (void *)cmd->r2t_pdu + cmd->offset, left); + iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bvec, 1, left); + ret = sock_sendmsg(cmd->queue->sock, &msg); if (ret <= 0) return ret; cmd->offset += ret; From patchwork Fri Jun 16 16:12:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13282943 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 3BD32EB64D7 for ; Fri, 16 Jun 2023 16:13:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C1FF18E0002; Fri, 16 Jun 2023 12:13:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BA84D8E0001; Fri, 16 Jun 2023 12:13:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A4C0C8E0002; Fri, 16 Jun 2023 12:13:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 9300C8E0001 for ; Fri, 16 Jun 2023 12:13:49 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 64814C0CB9 for ; Fri, 16 Jun 2023 16:13:49 +0000 (UTC) X-FDA: 80909106978.28.C505C95 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf28.hostedemail.com (Postfix) with ESMTP id 92418C0017 for ; Fri, 16 Jun 2023 16:13:47 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=TpZjNFrc; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf28.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.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=1686932027; 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=grJiPDzmVE+JWixhtEwEuCg8A7Is72x3RXUkHOLHxlw=; b=WB0oxmQbeZHQWOjsOOgU9M6hnum5NKsAVNLLOCaBfiWNq2I7UCx1ihUPFbn0dfoj4rAQBm 9uaFOl7eFGItxxCybOmBCcGHtwbfk9q5cOXAPjyAgfqBJSHzYUV/r9EeYR+AdYBTI8NbJI n5e5jXJuYg38sduVY1aVnWUyK0EqUNI= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=TpZjNFrc; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf28.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686932027; a=rsa-sha256; cv=none; b=yI7R4qtBg7RtueeYhKh4We70d7DDxPgFNQttrbvVo9Pp+EsziaEAWz6ouRvrtMGYOHQJL7 q+OEM7sYXFm1um//NeFjM24g0PT8hgDqKyXiaiudkOUUYaQadL+sDbaS0h5y29cGOEc0QE qpc738H0q21Na5kkmGVLMcBlpnr3QeM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686932026; 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=grJiPDzmVE+JWixhtEwEuCg8A7Is72x3RXUkHOLHxlw=; b=TpZjNFrcxvGig2U86Xza/Gx8qhyCqic8zNAYWmdMmNZrH9+pHF/UBE/brnwE0r3LnnD5NH f1jzseD91J0bGzF2IR1ZgWG5IcRpQliVgtzK4pRJ9+pikoVLmZjnw/4FcxObG/Uig/Fpyd 5VQC50LmuWco5+1RXRl0/VZQhAuLkac= 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-618-LdPYsu7wOhSU0jBx8Q1Imw-1; Fri, 16 Jun 2023 12:13:43 -0400 X-MC-Unique: LdPYsu7wOhSU0jBx8Q1Imw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 90AD5811E78; Fri, 16 Jun 2023 16:13:42 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9801FC1604C; Fri, 16 Jun 2023 16:13:40 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Alexander Duyck , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , Jens Axboe , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Karsten Graul , Wenjia Zhang , Jan Karcher , linux-s390@vger.kernel.org Subject: [PATCH net-next 11/17] smc: Drop smc_sendpage() in favour of smc_sendmsg() + MSG_SPLICE_PAGES Date: Fri, 16 Jun 2023 17:12:54 +0100 Message-ID: <20230616161301.622169-12-dhowells@redhat.com> In-Reply-To: <20230616161301.622169-1-dhowells@redhat.com> References: <20230616161301.622169-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Rspamd-Queue-Id: 92418C0017 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: rqstp65wxsxojch4y6hb87opt3p6xfn4 X-HE-Tag: 1686932027-845031 X-HE-Meta: U2FsdGVkX19BGWwG1leUX1uomJ60JRXiyoJYDEJ6gepTmm1zwTIhi6j79AqwgzjBqe3cs+5aVpfac0v6csFRsthaEvdMPNIrvGHhQ+eCjSHaFJeQBkoNrsi0hKbpDZuy5yANJ/iu05hrztwwZPrmZH7rUINGqF6inayAs3LLMlIe9LEgKEejKeTx/WcTRxn32uGZOtxgOkbdnMayvwXd/8rQJo1Z7iuLh/7UUsdXhnzoybkeVpQmP6N5c7ywL5OxuEVmCctkuYY4dbyznYYv1dEA+7/zW+2w15p37TEtgl9oaUgnk9H+4h0cc9877pcjJ6n04lPmnrNAv+beseBCl1laHir55jKmR1/F0uSQ5yF5Dq2DYLeySzAQ9XWxg7NFxZHuEo0C/MPmUZms7i3UCMN8w8sFG07vGDORH5hca+aazGNKZus2AsS0sHapIDw0ph9EOtioT6ka4yY27xhUgBQ7CxBoRpfCpKZlPIFbXgqmrBh5ZUZaf2Km4NuxwDndmmKfgPZe7bLz5mnyBBtknJNLRHnioBzKsQMPRWKBIHWCqsEavpn7UXEQUDg7Tg7Q9dTD8Yo75Bsice+jkap/Mb7ctktXzfF8eHL2JAu+F85bxqXYW8Sm+1C+zzBuS0Pig5AXS4rddgAqWh3AMRt+eGofQN14lCsVvJuUSEJ5GruxMpUDfSFnWX2O/BxM+M0vz6nKbgw3sYljULWkhP1frysnB0qJs//q91x0Su6ks0HUfwr/q032qjnu0Aq2pfCMxPzrnl/hKwqa5TnpIgGOeA3g2Zv0EQT6ttmGQfYCGytv0pR/5ilHy6bQk4LNwSpFYHgw9mAR04b8MHgxgmXhv/B+NAxNtOYad1XCkQ6oqr7q3ACl6dyz87eFZXgHPpNOOho1qm4ukHxI78kIbdLKBJVC7UQnMQtkaO2bFDll8nSBpZG2mfThDuXleFiwnD3zKypL7DZ0UnmzP1SRkKf fIPGKcOY DCZiIgYdfq//nGmbRsQwfsp2VmP0tfS23HqPRtgYptx16EqkcPZMyBSZzzHtMxE5KFAQoqUxQnLboStvjewSlrWZgLY9z0Wwn9p6zd/AGitovQF7pu5nFL/nTPvpJfgLScr93Hh5Q2VjtNnhCs4v70F/ZHiMMKywRuIcjfl7bs1HnukGZC4RaE3M7kIGN7eZATomKGghdALG6ljuBhanHC3RRHSztwfGDZlGcIHjBAB8LRJ83iiXsV6XUWhOr2W171qRL0dCgSl0aL+QCqH0lGotZOTKu0bjVvDDQncnOMvLr76AS4eLaCbjJ7ENojVzyxtVhLyLsNBSKv/FphwqUGpXhnSs2GGEARytru5WQsOlS7c+CZYTWnXogv2LtXU/Q3dIAp4gB0EhQGpf6s8itaZae/LyUzzSyfeY2IfiiT+verKR7e/BDG3lUzoM9VfDGCjtuaK8QiUdDAMAbexNof1Ki9atziy9sGB3eDhvxxue3RkZBOsUc/jTihECOkpvKifJtOkgvNdRpluQ= 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: Drop the smc_sendpage() code as smc_sendmsg() just passes the call down to the underlying TCP socket and smc_tx_sendpage() is just a wrapper around its sendmsg implementation. Signed-off-by: David Howells cc: Karsten Graul cc: Wenjia Zhang cc: Jan Karcher cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: Jens Axboe cc: Matthew Wilcox cc: linux-s390@vger.kernel.org cc: netdev@vger.kernel.org --- net/smc/af_smc.c | 29 ----------------------------- net/smc/smc_stats.c | 2 +- net/smc/smc_stats.h | 1 - net/smc/smc_tx.c | 22 +--------------------- net/smc/smc_tx.h | 2 -- 5 files changed, 2 insertions(+), 54 deletions(-) diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c index 538e9c6ec8c9..a7f887d91d89 100644 --- a/net/smc/af_smc.c +++ b/net/smc/af_smc.c @@ -3133,34 +3133,6 @@ static int smc_ioctl(struct socket *sock, unsigned int cmd, return put_user(answ, (int __user *)arg); } -static ssize_t smc_sendpage(struct socket *sock, struct page *page, - int offset, size_t size, int flags) -{ - struct sock *sk = sock->sk; - struct smc_sock *smc; - int rc = -EPIPE; - - smc = smc_sk(sk); - lock_sock(sk); - if (sk->sk_state != SMC_ACTIVE) { - release_sock(sk); - goto out; - } - release_sock(sk); - if (smc->use_fallback) { - rc = kernel_sendpage(smc->clcsock, page, offset, - size, flags); - } else { - lock_sock(sk); - rc = smc_tx_sendpage(smc, page, offset, size, flags); - release_sock(sk); - SMC_STAT_INC(smc, sendpage_cnt); - } - -out: - return rc; -} - /* Map the affected portions of the rmbe into an spd, note the number of bytes * to splice in conn->splice_pending, and press 'go'. Delays consumer cursor * updates till whenever a respective page has been fully processed. @@ -3232,7 +3204,6 @@ static const struct proto_ops smc_sock_ops = { .sendmsg = smc_sendmsg, .recvmsg = smc_recvmsg, .mmap = sock_no_mmap, - .sendpage = smc_sendpage, .splice_read = smc_splice_read, }; diff --git a/net/smc/smc_stats.c b/net/smc/smc_stats.c index e80e34f7ac15..ca14c0f3a07d 100644 --- a/net/smc/smc_stats.c +++ b/net/smc/smc_stats.c @@ -227,7 +227,7 @@ static int smc_nl_fill_stats_tech_data(struct sk_buff *skb, SMC_NLA_STATS_PAD)) goto errattr; if (nla_put_u64_64bit(skb, SMC_NLA_STATS_T_SENDPAGE_CNT, - smc_tech->sendpage_cnt, + 0, SMC_NLA_STATS_PAD)) goto errattr; if (nla_put_u64_64bit(skb, SMC_NLA_STATS_T_CORK_CNT, diff --git a/net/smc/smc_stats.h b/net/smc/smc_stats.h index 84b7ecd8c05c..b60fe1eb37ab 100644 --- a/net/smc/smc_stats.h +++ b/net/smc/smc_stats.h @@ -71,7 +71,6 @@ struct smc_stats_tech { u64 clnt_v2_succ_cnt; u64 srv_v1_succ_cnt; u64 srv_v2_succ_cnt; - u64 sendpage_cnt; u64 urg_data_cnt; u64 splice_cnt; u64 cork_cnt; diff --git a/net/smc/smc_tx.c b/net/smc/smc_tx.c index 9b9e0a190734..5147207808e5 100644 --- a/net/smc/smc_tx.c +++ b/net/smc/smc_tx.c @@ -167,8 +167,7 @@ static bool smc_tx_should_cork(struct smc_sock *smc, struct msghdr *msg) * sndbuf_space is still available. The applications * should known how/when to uncork it. */ - if ((msg->msg_flags & MSG_MORE || - smc_tx_is_corked(smc)) && + if ((msg->msg_flags & MSG_MORE || smc_tx_is_corked(smc)) && atomic_read(&conn->sndbuf_space)) return true; @@ -297,25 +296,6 @@ int smc_tx_sendmsg(struct smc_sock *smc, struct msghdr *msg, size_t len) return rc; } -int smc_tx_sendpage(struct smc_sock *smc, struct page *page, int offset, - size_t size, int flags) -{ - struct msghdr msg = {.msg_flags = flags}; - char *kaddr = kmap(page); - struct kvec iov; - int rc; - - if (flags & MSG_SENDPAGE_NOTLAST) - msg.msg_flags |= MSG_MORE; - - iov.iov_base = kaddr + offset; - iov.iov_len = size; - iov_iter_kvec(&msg.msg_iter, ITER_SOURCE, &iov, 1, size); - rc = smc_tx_sendmsg(smc, &msg, size); - kunmap(page); - return rc; -} - /***************************** sndbuf consumer *******************************/ /* sndbuf consumer: actual data transfer of one target chunk with ISM write */ diff --git a/net/smc/smc_tx.h b/net/smc/smc_tx.h index 34b578498b1f..a59f370b8b43 100644 --- a/net/smc/smc_tx.h +++ b/net/smc/smc_tx.h @@ -31,8 +31,6 @@ void smc_tx_pending(struct smc_connection *conn); void smc_tx_work(struct work_struct *work); void smc_tx_init(struct smc_sock *smc); int smc_tx_sendmsg(struct smc_sock *smc, struct msghdr *msg, size_t len); -int smc_tx_sendpage(struct smc_sock *smc, struct page *page, int offset, - size_t size, int flags); int smc_tx_sndbuf_nonempty(struct smc_connection *conn); void smc_tx_sndbuf_nonfull(struct smc_sock *smc); void smc_tx_consumer_update(struct smc_connection *conn, bool force); From patchwork Fri Jun 16 16:12:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13282945 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 C9360EB64DA for ; Fri, 16 Jun 2023 16:14:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A239A940008; Fri, 16 Jun 2023 12:13:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9F9E38E0001; Fri, 16 Jun 2023 12:13:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 851E4940008; Fri, 16 Jun 2023 12:13:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 667AC8E0001 for ; Fri, 16 Jun 2023 12:13:59 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 3F25DAF282 for ; Fri, 16 Jun 2023 16:13:59 +0000 (UTC) X-FDA: 80909107398.08.351BA26 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 53072160014 for ; Fri, 16 Jun 2023 16:13:56 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=EricP103; 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=1686932036; 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=9Poz7OqJAkVJsv5byM8EW5EOnvfZYE9IRVGDTeluoLg=; b=JAzPXdfQuaR8SjV37IMtOF7Spi0apwkBWZvSa08ZPejXdgzS0OPI1BOvTe/tHVR3Jd1Gb9 1XBp5mbVQPyatDB3/mNWraMxPpUvmrsFoa6qQClOoUah8bPhWRnN7plunq8cKXabN78fUA /lFhW3lETYdcD8W0x4INwtyY4Ihv8WA= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=EricP103; 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=1686932036; a=rsa-sha256; cv=none; b=hVWyM3UzxrDpZ1eZOoQ86Js5ZGBVeShH2KnBfNeTIPbujcP0xDm34zAYSDHBWd3DFFJ8IU stUfnm9U8Pg9FpDqybyYBARKc1vzT7Wa5b3Q6uNc7yYniwddAZ3ue6G11C6WrgDyU5FMo9 exVpf8XXeoc++gkA39LnDehMV2eoKeo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686932034; 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=9Poz7OqJAkVJsv5byM8EW5EOnvfZYE9IRVGDTeluoLg=; b=EricP103sL3V/G2sP+29+VvpXUvyCu20qySt7L3uzw3Hbsmk7TJzO2+rfjniT/q4b8TVa+ qw1zLBcU5JwUngM9eRRSFnNAOVWyrggcSlZ77Dr33hqa/SVg5/VD9Q+6yXKqFz4giWKusS gDG0hykdx6Oh2eurbDnbtucT486fMhM= 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-151-E4yhn9g7O6WajN0Qa6IrDA-1; Fri, 16 Jun 2023 12:13:46 -0400 X-MC-Unique: E4yhn9g7O6WajN0Qa6IrDA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 816103C0E455; Fri, 16 Jun 2023 16:13:45 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id 513131121314; Fri, 16 Jun 2023 16:13:43 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Alexander Duyck , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , Jens Axboe , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Mark Fasheh , Joel Becker , Joseph Qi , ocfs2-devel@oss.oracle.com Subject: [PATCH net-next 12/17] ocfs2: Use sendmsg(MSG_SPLICE_PAGES) rather than sendpage() Date: Fri, 16 Jun 2023 17:12:55 +0100 Message-ID: <20230616161301.622169-13-dhowells@redhat.com> In-Reply-To: <20230616161301.622169-1-dhowells@redhat.com> References: <20230616161301.622169-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 53072160014 X-Stat-Signature: yzw6riot5ipnmxhwk4opzd5rs8g99r8e X-HE-Tag: 1686932036-848341 X-HE-Meta: U2FsdGVkX197uTJ9KRUtit7Ic6qXMui2Ie6SQ2fQy0J9boxhZ1iIPZQLrZjh5XiGbeUWCyZjkmZOY69W0hEFSkV11wM98rkti/OkU3PWNIzLsqHDAi983cp9nf+mXFAeniQc2gKv70cQVKioGjirWxaWmw3fgmWk8jHFkUL+0OHgxEr6/euBGlnRhiTDnL1se1oc9gOCfB9j6xh6EG6wt7n7z1XhnJdlt5dSaM2WMjNG5ugUxm8BMxi+Sxj7gV7aNho0jijQ5vNokYRWtpplj2q2KrnC2q7DENKoBTWLxvqjMpSzMBo1yUF0QdRol2BRt/AfVGj98u/+4CfdB1oxub1uOEh4f43PvgkPwaH3C0wUawtwKaPlFId70aE+LV+uU2sv+HcLuqhiN8WzDHuiBcBLaXecQl/p9ZWYbgmQFCPTcuX1X0Xw9g8YoqmaFXhdASnfRPprMphUXxcmQzzQyohWGfpq18E/3fXkuvZ/8d9Bpfaj8bIabetVxdgYE3y8e+Xqe4DVAewENggm/pRksHITV42vm25L5b03+PJBYgSBshgLFPgJx8QJDtS6h+HAklacyq6wlLyF2dCMbNtAzy45iMJvCqqjk3scsoGc9zzAPTmmAlAZajmLEyotO59wdrII9gQvmRNCc9ugT8cdxXyoJEht0lXGVv2Y4NR+fYe4Vsgt8BrWBgnkEy3fYVGbCbjVfVRl4/RoFcZK/x5WEDxsw8Xb39iLriB+v+nuGmp9FkyrGOyhyvfvW3TSYojyv0iQvUM/DxBx5fnZR8BzdiW1YJKCnPN2WRzjomrnw94my5a6mbvoaUllEeJXxGzFwarfoyC3T1VFpx97AosGX4jeRR/7VWn1LGRxvcQiQx7ZR28KtRTHsKi5udqk5UkSeRHtS+CeLe5i1qug9p297nZGFw2Orrnvt1pkABuvl5hIxpBAMi0jTyCKc44p2BS3XfJm8KpsIklugr+gAUo k17LVnuQ i99GrcUKjbrxkLM1TD7I05FJHkP9cR6im+jcdXz+pGqDzAZKKBjeNGJt1CPaExBPQhNohzi1XcB6YGuacgooN4NaGOvU2+cZryXVMbz8ms5yCQWRTj5gwrIvI2AUx7pm7/C4IF7gcVAttYKI8HF86sbxfWUrLMcESYql3R1gQDV1G8fJT5IfL/ayo6am0iG31bWQmVlRaHisxTrBklLzjFSoWZaUbZM5sBbUrYyS/pfRrghe5hjvZ9UktcSmH27/f8/Z/wI6zCdHz7KEVKETQlT+RAfjIiIEdvKgcCE5IrWxf3QVvXH68ZO9Lf1TWmEo2RYPUB1hKmNxUewd4ExUQMS4OEXaN93cNWY6GvrzDMvTRDo4TBTesNlLMS+hv8V12o1Edv5qXxi2qsWG8jCtfuCrOR0veGGjRSBzrmNYEFX4AqC3tgp2QxlEdMtEGKDUKzit1+t/0dj4zsZvT/DKivzjX03uM2StPgXsFjoXyB5I4yyWAM4c8akLsCA2n5oEY7dVGVGCIq65U6P0q/4AkJtm0fejQjME3WmLrcCBvn7xo9GqM76AFU+PsIS9IwNGYgbfcktV0zUivFk2s0k5rGWEYcu/ORhqa5a/j 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: Fix ocfs2 to use the page fragment allocator rather than kzalloc in order to allocate the buffers for the handshake message and keepalive request and reply messages. Switch from using sendpage() to using sendmsg() + MSG_SPLICE_PAGES so that sendpage can be phased out. Signed-off-by: David Howells cc: Mark Fasheh cc: Joel Becker cc: Joseph Qi cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: ocfs2-devel@oss.oracle.com cc: netdev@vger.kernel.org --- fs/ocfs2/cluster/tcp.c | 107 ++++++++++++++++++++++------------------- 1 file changed, 58 insertions(+), 49 deletions(-) diff --git a/fs/ocfs2/cluster/tcp.c b/fs/ocfs2/cluster/tcp.c index aecbd712a00c..b543f72d85f2 100644 --- a/fs/ocfs2/cluster/tcp.c +++ b/fs/ocfs2/cluster/tcp.c @@ -110,9 +110,6 @@ static struct work_struct o2net_listen_work; static struct o2hb_callback_func o2net_hb_up, o2net_hb_down; #define O2NET_HB_PRI 0x1 -static struct o2net_handshake *o2net_hand; -static struct o2net_msg *o2net_keep_req, *o2net_keep_resp; - static int o2net_sys_err_translations[O2NET_ERR_MAX] = {[O2NET_ERR_NONE] = 0, [O2NET_ERR_NO_HNDLR] = -ENOPROTOOPT, @@ -930,19 +927,22 @@ static int o2net_send_tcp_msg(struct socket *sock, struct kvec *vec, } static void o2net_sendpage(struct o2net_sock_container *sc, - void *kmalloced_virt, - size_t size) + void *virt, size_t size) { struct o2net_node *nn = o2net_nn_from_num(sc->sc_node->nd_num); + struct msghdr msg = {}; + struct bio_vec bv; ssize_t ret; + bvec_set_virt(&bv, virt, size); + iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bv, 1, size); + while (1) { + msg.msg_flags = MSG_DONTWAIT | MSG_SPLICE_PAGES; mutex_lock(&sc->sc_send_lock); - ret = sc->sc_sock->ops->sendpage(sc->sc_sock, - virt_to_page(kmalloced_virt), - offset_in_page(kmalloced_virt), - size, MSG_DONTWAIT); + ret = sock_sendmsg(sc->sc_sock, &msg); mutex_unlock(&sc->sc_send_lock); + if (ret == size) break; if (ret == (ssize_t)-EAGAIN) { @@ -1168,6 +1168,7 @@ static int o2net_process_message(struct o2net_sock_container *sc, struct o2net_msg *hdr) { struct o2net_node *nn = o2net_nn_from_num(sc->sc_node->nd_num); + struct o2net_msg *keep_resp; int ret = 0, handler_status; enum o2net_system_error syserr; struct o2net_msg_handler *nmh = NULL; @@ -1186,8 +1187,16 @@ static int o2net_process_message(struct o2net_sock_container *sc, be32_to_cpu(hdr->status)); goto out; case O2NET_MSG_KEEP_REQ_MAGIC: - o2net_sendpage(sc, o2net_keep_resp, - sizeof(*o2net_keep_resp)); + keep_resp = alloc_skb_frag(sizeof(*keep_resp), + GFP_KERNEL); + if (!keep_resp) { + ret = -ENOMEM; + goto out; + } + memset(keep_resp, 0, sizeof(*keep_resp)); + keep_resp->magic = cpu_to_be16(O2NET_MSG_KEEP_RESP_MAGIC); + o2net_sendpage(sc, keep_resp, sizeof(*keep_resp)); + folio_put(virt_to_folio(keep_resp)); goto out; case O2NET_MSG_KEEP_RESP_MAGIC: goto out; @@ -1439,15 +1448,22 @@ static void o2net_rx_until_empty(struct work_struct *work) sc_put(sc); } -static void o2net_initialize_handshake(void) +static struct o2net_handshake *o2net_initialize_handshake(void) { - o2net_hand->o2hb_heartbeat_timeout_ms = cpu_to_be32( - O2HB_MAX_WRITE_TIMEOUT_MS); - o2net_hand->o2net_idle_timeout_ms = cpu_to_be32(o2net_idle_timeout()); - o2net_hand->o2net_keepalive_delay_ms = cpu_to_be32( - o2net_keepalive_delay()); - o2net_hand->o2net_reconnect_delay_ms = cpu_to_be32( - o2net_reconnect_delay()); + struct o2net_handshake *hand; + + hand = alloc_skb_frag(sizeof(*hand), GFP_KERNEL); + if (!hand) + return NULL; + + memset(hand, 0, sizeof(*hand)); + hand->protocol_version = cpu_to_be64(O2NET_PROTOCOL_VERSION); + hand->connector_id = cpu_to_be64(1); + hand->o2hb_heartbeat_timeout_ms = cpu_to_be32(O2HB_MAX_WRITE_TIMEOUT_MS); + hand->o2net_idle_timeout_ms = cpu_to_be32(o2net_idle_timeout()); + hand->o2net_keepalive_delay_ms = cpu_to_be32(o2net_keepalive_delay()); + hand->o2net_reconnect_delay_ms = cpu_to_be32(o2net_reconnect_delay()); + return hand; } /* ------------------------------------------------------------ */ @@ -1456,16 +1472,22 @@ static void o2net_initialize_handshake(void) * rx path will see the response and mark the sc valid */ static void o2net_sc_connect_completed(struct work_struct *work) { + struct o2net_handshake *hand; struct o2net_sock_container *sc = container_of(work, struct o2net_sock_container, sc_connect_work); + hand = o2net_initialize_handshake(); + if (!hand) + goto out; + mlog(ML_MSG, "sc sending handshake with ver %llu id %llx\n", (unsigned long long)O2NET_PROTOCOL_VERSION, - (unsigned long long)be64_to_cpu(o2net_hand->connector_id)); + (unsigned long long)be64_to_cpu(hand->connector_id)); - o2net_initialize_handshake(); - o2net_sendpage(sc, o2net_hand, sizeof(*o2net_hand)); + o2net_sendpage(sc, hand, sizeof(*hand)); + folio_put(virt_to_folio(hand)); +out: sc_put(sc); } @@ -1475,8 +1497,15 @@ static void o2net_sc_send_keep_req(struct work_struct *work) struct o2net_sock_container *sc = container_of(work, struct o2net_sock_container, sc_keepalive_work.work); + struct o2net_msg *keep_req; - o2net_sendpage(sc, o2net_keep_req, sizeof(*o2net_keep_req)); + keep_req = alloc_skb_frag(sizeof(*keep_req), GFP_KERNEL); + if (keep_req) { + memset(keep_req, 0, sizeof(*keep_req)); + keep_req->magic = cpu_to_be16(O2NET_MSG_KEEP_REQ_MAGIC); + o2net_sendpage(sc, keep_req, sizeof(*keep_req)); + folio_put(virt_to_folio(keep_req)); + } sc_put(sc); } @@ -1780,6 +1809,7 @@ static int o2net_accept_one(struct socket *sock, int *more) struct socket *new_sock = NULL; struct o2nm_node *node = NULL; struct o2nm_node *local_node = NULL; + struct o2net_handshake *hand; struct o2net_sock_container *sc = NULL; struct o2net_node *nn; unsigned int nofs_flag; @@ -1882,8 +1912,11 @@ static int o2net_accept_one(struct socket *sock, int *more) o2net_register_callbacks(sc->sc_sock->sk, sc); o2net_sc_queue_work(sc, &sc->sc_rx_work); - o2net_initialize_handshake(); - o2net_sendpage(sc, o2net_hand, sizeof(*o2net_hand)); + hand = o2net_initialize_handshake(); + if (hand) { + o2net_sendpage(sc, hand, sizeof(*hand)); + folio_put(virt_to_folio(hand)); + } out: if (new_sock) @@ -2090,21 +2123,8 @@ int o2net_init(void) unsigned long i; o2quo_init(); - o2net_debugfs_init(); - o2net_hand = kzalloc(sizeof(struct o2net_handshake), GFP_KERNEL); - o2net_keep_req = kzalloc(sizeof(struct o2net_msg), GFP_KERNEL); - o2net_keep_resp = kzalloc(sizeof(struct o2net_msg), GFP_KERNEL); - if (!o2net_hand || !o2net_keep_req || !o2net_keep_resp) - goto out; - - o2net_hand->protocol_version = cpu_to_be64(O2NET_PROTOCOL_VERSION); - o2net_hand->connector_id = cpu_to_be64(1); - - o2net_keep_req->magic = cpu_to_be16(O2NET_MSG_KEEP_REQ_MAGIC); - o2net_keep_resp->magic = cpu_to_be16(O2NET_MSG_KEEP_RESP_MAGIC); - for (i = 0; i < ARRAY_SIZE(o2net_nodes); i++) { struct o2net_node *nn = o2net_nn_from_num(i); @@ -2122,21 +2142,10 @@ int o2net_init(void) } return 0; - -out: - kfree(o2net_hand); - kfree(o2net_keep_req); - kfree(o2net_keep_resp); - o2net_debugfs_exit(); - o2quo_exit(); - return -ENOMEM; } void o2net_exit(void) { o2quo_exit(); - kfree(o2net_hand); - kfree(o2net_keep_req); - kfree(o2net_keep_resp); o2net_debugfs_exit(); } From patchwork Fri Jun 16 16:12:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13282944 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 D31C5EB64D7 for ; Fri, 16 Jun 2023 16:13:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7168A8E000B; Fri, 16 Jun 2023 12:13:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 69ED08E000C; Fri, 16 Jun 2023 12:13:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 518518E000B; Fri, 16 Jun 2023 12:13:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 41DDB8E0001 for ; Fri, 16 Jun 2023 12:13:59 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id E5C21120CF3 for ; Fri, 16 Jun 2023 16:13:58 +0000 (UTC) X-FDA: 80909107356.07.8866BFC Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf09.hostedemail.com (Postfix) with ESMTP id 2C9F7140019 for ; Fri, 16 Jun 2023 16:13:56 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=U2GDvDjR; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf09.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=1686932037; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=p9xwt/KxOmKt8o2VLLrb8jjs8WGzx+nDwsNmG750aho=; b=yN5WQi40IhQkM7UsW9gKhz6X/jWiNYLxjlRw9vHT3JxUO6qgf+I5fxcJxxFosYqUTWoerD ofnJBkMZE3UIZDyJ+ECUNqnYZcoIVGOCxtJ7ADEGvDWKYBLAimVSjoDHh6155CD89w/vvK NifCa9EMurMET7aC5PA1nSy9c4F5aPs= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=U2GDvDjR; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf09.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=1686932037; a=rsa-sha256; cv=none; b=gcm18uH+W5kV7+eaJeupxgIGhELP+dUDzh5fqV1Y0nCVrtSo7+LvSG5I7t8h0MOzo/I3kf vIGk19ycLKVzTFBTCyno13MROSOWFdmIu3MiqeCz04DejgJ8YSgQyPwz5FZD23kkVrsDqc b33CaLNKTFhHIETI3j0YUZy+gvjqGCU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686932036; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=p9xwt/KxOmKt8o2VLLrb8jjs8WGzx+nDwsNmG750aho=; b=U2GDvDjRqVAaUzHDVzx68EGKV+GG6BFkkhHW+WYNR5iaP27vg8ePrUiOydRGTlsuRAdalQ uXF7oJZ7WmNIttJNU5yi74iXnACrSKAjMQPa3txZvP8eYH+7cNldObZKYr61NmXr1+/St0 2yrOIRlpw53h/Cy+UEzaKEOuygcFWMo= 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-437-eFc4iCLxMeSIHuIkvb1k0A-1; Fri, 16 Jun 2023 12:13:50 -0400 X-MC-Unique: eFc4iCLxMeSIHuIkvb1k0A-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6958F80120F; Fri, 16 Jun 2023 16:13:49 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4E1BD40CF8F6; Fri, 16 Jun 2023 16:13:46 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Alexander Duyck , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , Jens Axboe , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Philipp Reisner , Lars Ellenberg , =?utf-8?q?Christoph_B=C3=B6hmwa?= =?utf-8?q?lder?= , drbd-dev@lists.linbit.com, linux-block@vger.kernel.org Subject: [PATCH net-next 13/17] drbd: Use sendmsg(MSG_SPLICE_PAGES) rather than sendpage() Date: Fri, 16 Jun 2023 17:12:56 +0100 Message-ID: <20230616161301.622169-14-dhowells@redhat.com> In-Reply-To: <20230616161301.622169-1-dhowells@redhat.com> References: <20230616161301.622169-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 2C9F7140019 X-Stat-Signature: b77qhxj9ad93cgyhfxbio1d7uk5tnhfu X-HE-Tag: 1686932036-676646 X-HE-Meta: U2FsdGVkX187TSq+K/MmntA3iAQ0Zz68siECZqqSoljYgDyytyncxIe8VJO7AtDH3VfIk+0itj90th5Yn9tMfYzpG52/vOY/Dmprs8ueQyOaZcvbfFaUEHuuCdJo4ucF/rmdpWqaBXmLzWBBlM8LGJMNS7ozuS2mt8oXiQW9BcumF4Nj7GlYJOivqeon5iv+9eYgALLZf8JNkjPi/faWLku97P0c6SkPUSlIxHYePWdUslUewf1fv08GpGvDnfDMJvLV5QrPEu7cH5YnqNkOFeauwu9VpbYPmbmemti6mUk/3tYmKmAB9xYgsOkANRC2wf9VeknIIpDDHScJneRN1lwuLzOkj0tzb4NmZK6IucmZ+xVcQm4RbmtJUlvFeJRb3/vgfUUta6ha01Vy42ED2A5CXvxzIjk6R0VZhQNwBA6cl4tg8R2dh9EMk7aWItCGxVMBL2YB9FhdWvDAfvmBIwkqu1L1b2lVH/n61dyeU7XaFdEnKbgUUVLGXJv4nbROrQwnbK5L6TP3OyoxCnC1tU5DcAFGv1M04fFY6gapLEdzTk7NTKukGEG/MVp1V2yHciWd0nYlOf6TTjlLU4gNU4LK7H2N6UK+ERPcbjaLL+zAbrLPTAvYGUnmoXcLQy8uDXRkg9D/wZiFQaFfsJ4Y1VStdxChMvx+mQXTbNi5W7Z1C3KQh4xw5ZryRGVmwbG7uygHkmtiBiXsONmwHfH+MDWtlCpuo7KOsVPkRjY6/o9J/cS0c24gIOh16zolQPfJ7Hrupqb1rQH5Gucf+LzYzUBtZkjVpiYvh07ssvdSxFaurbceDkvg8qGmLOcdQ3+yRNu2vPIM71IPoMHJ1vW7wZmexVpN89Tzwtb429+O7M/qdMysWcq86+oEexs871RybdVRfc9WPciw6dvhvVYtVsJbL8O4YHn2eogU0GDI2aIOBe5oGcqaMy7H7zFWGnvNy0U4B+1V1rQXQqSoQRi FoWhhtk8 0H2one/3Qk6qtEyEswuLH9FQ3fciPZw4dVzK2ALCn9DNBcnd0uYCL+/r6Az4R+sCKIBlvjSJRp7IBmHsYF6UOaEBYkUR610AMNzxCfJW47K4qkQJGGkKKLnZa320uJTjn8uPHFlplFodcI4TLSupkBkcbNdfaS5DN0DMu+sk3+c0eA06cF18pL4GN7unIiSxVUpmnzg56nLwgsNAl6rRTv7mUdW1vj0Q57qWRdH1xQ1yOCctRQHuhjewtY31lu0hUULKeURGxqIKnItFq22jrSv5qWpIszkjm/HJSWOZpHcxnyxZD1Ar2gQiX6Tv7FNwyT7Xi09/hQ0t1ygneysQSKmQPvPUyRhPqnvSXTxeNz7CCN5J2+9xLzXm8qkgTpdToPV2sjZDnWvv2XgtXMSMNGvOA4lkaWG5mrHjVxhABRmLRryXdS3s101tlO3jMby1+4KoMg8HfFqLspP9KmiTTXTStlCor7HuTfSz0hvjGwsuWZ/kw5D0YQMiFAA== 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: Use sendmsg() conditionally with MSG_SPLICE_PAGES in _drbd_send_page() rather than calling sendpage() or _drbd_no_send_page(). Signed-off-by: David Howells cc: Philipp Reisner cc: Lars Ellenberg cc: "Christoph Böhmwalder" cc: Jens Axboe cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: drbd-dev@lists.linbit.com cc: linux-block@vger.kernel.org cc: netdev@vger.kernel.org --- drivers/block/drbd/drbd_main.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c index 83987e7a5ef2..c9d84183844c 100644 --- a/drivers/block/drbd/drbd_main.c +++ b/drivers/block/drbd/drbd_main.c @@ -1540,7 +1540,8 @@ static int _drbd_send_page(struct drbd_peer_device *peer_device, struct page *pa int offset, size_t size, unsigned msg_flags) { struct socket *socket = peer_device->connection->data.socket; - int len = size; + struct bio_vec bvec; + struct msghdr msg = { .msg_flags = msg_flags, }; int err = -EIO; /* e.g. XFS meta- & log-data is in slab pages, which have a @@ -1549,33 +1550,33 @@ static int _drbd_send_page(struct drbd_peer_device *peer_device, struct page *pa * put_page(); and would cause either a VM_BUG directly, or * __page_cache_release a page that would actually still be referenced * by someone, leading to some obscure delayed Oops somewhere else. */ - if (drbd_disable_sendpage || !sendpage_ok(page)) - return _drbd_no_send_page(peer_device, page, offset, size, msg_flags); + if (!drbd_disable_sendpage && sendpage_ok(page)) + msg.msg_flags |= MSG_NOSIGNAL | MSG_SPLICE_PAGES; + + bvec_set_page(&bvec, page, offset, size); + iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bvec, 1, size); - msg_flags |= MSG_NOSIGNAL; drbd_update_congested(peer_device->connection); do { int sent; - sent = socket->ops->sendpage(socket, page, offset, len, msg_flags); + sent = sock_sendmsg(socket, &msg); if (sent <= 0) { if (sent == -EAGAIN) { if (we_should_drop_the_connection(peer_device->connection, socket)) break; continue; } - drbd_warn(peer_device->device, "%s: size=%d len=%d sent=%d\n", - __func__, (int)size, len, sent); + drbd_warn(peer_device->device, "%s: size=%d len=%zu sent=%d\n", + __func__, (int)size, msg_data_left(&msg), sent); if (sent < 0) err = sent; break; } - len -= sent; - offset += sent; - } while (len > 0 /* THINK && device->cstate >= C_CONNECTED*/); + } while (msg_data_left(&msg) /* THINK && device->cstate >= C_CONNECTED*/); clear_bit(NET_CONGESTED, &peer_device->connection->flags); - if (len == 0) { + if (!msg_data_left(&msg)) { err = 0; peer_device->device->send_cnt += size >> 9; } From patchwork Fri Jun 16 16:12:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13282946 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 D3632EB64D8 for ; Fri, 16 Jun 2023 16:14:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 62D19940009; Fri, 16 Jun 2023 12:14:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5DC2D8E0001; Fri, 16 Jun 2023 12:14:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 45643940009; Fri, 16 Jun 2023 12:14:02 -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 310428E0001 for ; Fri, 16 Jun 2023 12:14:02 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 07A541C8EAD for ; Fri, 16 Jun 2023 16:14:02 +0000 (UTC) X-FDA: 80909107524.02.50BAD95 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf27.hostedemail.com (Postfix) with ESMTP id 31DA64001E for ; Fri, 16 Jun 2023 16:13:59 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=HVQSsBMo; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf27.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=1686932040; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=icD5kbVEsLPzkQFWUHTmSK0TWNtewf4a1nLsJ/B7qIk=; b=ahixIslV3tEpafrFQ4UOe8KvWIkETVccuLkN0vvo60hYb9ockiM49Tbp2gsqUC7k5agxu0 RNTx0D2AE2K1vdnvlM3K6Djhm/oYaWC8RJsTmvsNreaSF9paAHFbMM8RO3dMvbgx7DfZuC qHQkuhkddol0Y5wWAa9x+xHuF/W8dfo= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=HVQSsBMo; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf27.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=1686932040; a=rsa-sha256; cv=none; b=SUrqTLSSyhO8DEx+Zh8JHlyQGLalDQfh+YCumoQie3T0dBm83Y+pTVtIFgTgU4DxaP7hI5 QkPfvTzQgiF+zG1dVoatsxCvYmqNy+sUID7uaW/axjwdoIJJBSPmvmKpvXUA6mhfTEG60N IHl8XhpUlFRGH/03DW7qp/XGIFCoz9g= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686932039; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=icD5kbVEsLPzkQFWUHTmSK0TWNtewf4a1nLsJ/B7qIk=; b=HVQSsBMobsakaA8Ecx4U9LLKFBM4x4QVnDTnkNvIOxP5VMhSKEbSEr5HIxV0Ug5Cx0Hxgq X7ELD3q8gGNcEFJxm728B756tdD5pfBfSrI3NL4zNiz3LEMl21c4u8/qjh9AeYvFbKWRrj 36rIpreOaWNe9PqngOcfZlU0N0MTkj0= 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-543-k2tOiSBtOmiq9_ek1Ymj9w-1; Fri, 16 Jun 2023 12:13:54 -0400 X-MC-Unique: k2tOiSBtOmiq9_ek1Ymj9w-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 2C23729AB3EE; Fri, 16 Jun 2023 16:13:53 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id 67C21140E952; Fri, 16 Jun 2023 16:13:50 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Alexander Duyck , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , Jens Axboe , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Philipp Reisner , Lars Ellenberg , =?utf-8?q?Christoph_B=C3=B6hmwa?= =?utf-8?q?lder?= , drbd-dev@lists.linbit.com, linux-block@vger.kernel.org Subject: [PATCH net-next 14/17] drdb: Send an entire bio in a single sendmsg Date: Fri, 16 Jun 2023 17:12:57 +0100 Message-ID: <20230616161301.622169-15-dhowells@redhat.com> In-Reply-To: <20230616161301.622169-1-dhowells@redhat.com> References: <20230616161301.622169-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Rspamd-Queue-Id: 31DA64001E X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: chddcw95ipf8kad7aqncu4amsya8hmhu X-HE-Tag: 1686932039-512573 X-HE-Meta: U2FsdGVkX1/YdQSI3T+px/c20YscqwNAXrkFbSqLirBB1y+1LAzMdhUANHip/Vk+q9i74vCPIu/3HD+qvGxa3nFYwG8bQJTkObQMSkNolPd0x6suDgJTDs39WpdRGcAGVhtTnm9U4bB7ajwHGZPCU/+gp9B7QwvIlDpMGwTlH1pb5FQ990DIfNMNIZmrZJLK34/juuuIpH683mQgbTOFOCorv+4Dzo/uJi0b1kzvTvVI1B+M+4gUkWlWv0FSPk1czDeZ/XDO7wmCcI7vOt2oq8MIWz5MEFsnM62dDeHE/CiG1wXa+NvmCmwq42AyKMRmo6fYO4C1jiXBZH9DYoK6EHXBSG4mA038HH4bH/sfN+RZ1n8EmHJxXlwdVHA9d+6j+GzZqv4QBl5wk9SwDbcqeSL2R8XYK3qR0OKy4Pf82maOIFcqRUNlVRtwN1VqsXE3ZBUZo9N8WNEfPncO61iku8MReSAqgmUGeZNQUtvxbPnzS0q3y+g60zB7P5TQ1Iuz27dKab8xIOI+rbr/IwpzWbhi1BzFzzd4rdSuxuEUXyk+drxUNrXuiWO226xA+DZdvbR13JT5W7nY+Hf3eeXqeaKFnMGSl5Q3uOA/M1Y0vIY+cQy5YBNFRxnYRgCp4IqX5vyPp7REpRvfIfjW4KrcRE7aunmX2Qxu8hUSwW4iT79pvBh2jh3YyvP12eOD/dY/2kTsVf1X6lz+pDw4FupCyXP9Dsvyu6Zmhn/LPUsph2AR2XLRycdE47y9/TuTzwFng10AWZI5V5FplHeT4ccBqTrBSi7I/+b5U2O1DF1yXv1o6IfV/jwoW1hbbyaEkQEIeXTc/Mepon4uvTIaRkc1+6il1yH8h2vv9bvTvjVvgtYloTz/08QmS4hfMLYW6nYJpd9CMbHOR20aa9w96Xho5/TFXiZS541FDFMYzOANaD4iq0Ub3P7MupGJEs68Ua9Bpvucf/eCxB5Fgt1Dh8K 6mi/PKyB 1nuPwKzLiqkA2u2RaAHk0obThJO+Wkc63KXWVgSZquCoaJnUCTC1r2YBJlQ7nw5bU+NcX6dU5Hc0LEgKVXicjlgWVgy1as30LnZ3Z6dFB6R+lC47Dhkg0k+gJs7ytNWPIrGTxb7AyilvJOaCttDE5P+vI50gBLqo6FiNTIYuIKrpfnQp7Q1FXawmd9+3OT5uZsfzbiE3FGlvuQgaI4qlVfvHSDhDgHn8jWYGDNjbE55UxoEzo5EL9HdOtUJo7IHN6m5ewQRDlrM4k04t6zia/KlZG6AMyNsJwmBfa/WkGg/R2/bm7WqRmL3iuhXrcWSykWv9CtPWSWaNO9AVNDP0+E+k3ajhf6HzUNKtB0FInyMkhoh6ED6T7aIJLCFGuJYP3Aju1eoJ8hDsSCo1NhPJ8GBg1FKwzeOe1kRe5aWkGXI3/35rZkFjRo2gbJTIMhX6iTl7N7tvr9NgxSnc= 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: Since _drdb_sendpage() is now using sendmsg to send the pages rather sendpage, pass the entire bio in one go using a bvec iterator instead of doing it piecemeal. Signed-off-by: David Howells cc: Philipp Reisner cc: Lars Ellenberg cc: "Christoph Böhmwalder" cc: Jens Axboe cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: drbd-dev@lists.linbit.com cc: linux-block@vger.kernel.org cc: netdev@vger.kernel.org --- drivers/block/drbd/drbd_main.c | 77 +++++++++++----------------------- 1 file changed, 25 insertions(+), 52 deletions(-) diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c index c9d84183844c..f7ebdb5ab45e 100644 --- a/drivers/block/drbd/drbd_main.c +++ b/drivers/block/drbd/drbd_main.c @@ -1520,28 +1520,15 @@ static void drbd_update_congested(struct drbd_connection *connection) * As a workaround, we disable sendpage on pages * with page_count == 0 or PageSlab. */ -static int _drbd_no_send_page(struct drbd_peer_device *peer_device, struct page *page, - int offset, size_t size, unsigned msg_flags) -{ - struct socket *socket; - void *addr; - int err; - - socket = peer_device->connection->data.socket; - addr = kmap(page) + offset; - err = drbd_send_all(peer_device->connection, socket, addr, size, msg_flags); - kunmap(page); - if (!err) - peer_device->device->send_cnt += size >> 9; - return err; -} - -static int _drbd_send_page(struct drbd_peer_device *peer_device, struct page *page, - int offset, size_t size, unsigned msg_flags) +static int _drbd_send_pages(struct drbd_peer_device *peer_device, + struct iov_iter *iter, unsigned msg_flags) { struct socket *socket = peer_device->connection->data.socket; - struct bio_vec bvec; - struct msghdr msg = { .msg_flags = msg_flags, }; + struct msghdr msg = { + .msg_flags = msg_flags | MSG_NOSIGNAL, + .msg_iter = *iter, + }; + size_t size = iov_iter_count(iter); int err = -EIO; /* e.g. XFS meta- & log-data is in slab pages, which have a @@ -1550,11 +1537,8 @@ static int _drbd_send_page(struct drbd_peer_device *peer_device, struct page *pa * put_page(); and would cause either a VM_BUG directly, or * __page_cache_release a page that would actually still be referenced * by someone, leading to some obscure delayed Oops somewhere else. */ - if (!drbd_disable_sendpage && sendpage_ok(page)) - msg.msg_flags |= MSG_NOSIGNAL | MSG_SPLICE_PAGES; - - bvec_set_page(&bvec, page, offset, size); - iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bvec, 1, size); + if (drbd_disable_sendpage) + msg.msg_flags &= ~(MSG_NOSIGNAL | MSG_SPLICE_PAGES); drbd_update_congested(peer_device->connection); do { @@ -1585,39 +1569,22 @@ static int _drbd_send_page(struct drbd_peer_device *peer_device, struct page *pa static int _drbd_send_bio(struct drbd_peer_device *peer_device, struct bio *bio) { - struct bio_vec bvec; - struct bvec_iter iter; + struct iov_iter iter; - /* hint all but last page with MSG_MORE */ - bio_for_each_segment(bvec, bio, iter) { - int err; + iov_iter_bvec(&iter, ITER_SOURCE, bio->bi_io_vec, bio->bi_vcnt, + bio->bi_iter.bi_size); - err = _drbd_no_send_page(peer_device, bvec.bv_page, - bvec.bv_offset, bvec.bv_len, - bio_iter_last(bvec, iter) - ? 0 : MSG_MORE); - if (err) - return err; - } - return 0; + return _drbd_send_pages(peer_device, &iter, 0); } static int _drbd_send_zc_bio(struct drbd_peer_device *peer_device, struct bio *bio) { - struct bio_vec bvec; - struct bvec_iter iter; + struct iov_iter iter; - /* hint all but last page with MSG_MORE */ - bio_for_each_segment(bvec, bio, iter) { - int err; + iov_iter_bvec(&iter, ITER_SOURCE, bio->bi_io_vec, bio->bi_vcnt, + bio->bi_iter.bi_size); - err = _drbd_send_page(peer_device, bvec.bv_page, - bvec.bv_offset, bvec.bv_len, - bio_iter_last(bvec, iter) ? 0 : MSG_MORE); - if (err) - return err; - } - return 0; + return _drbd_send_pages(peer_device, &iter, MSG_SPLICE_PAGES); } static int _drbd_send_zc_ee(struct drbd_peer_device *peer_device, @@ -1629,10 +1596,16 @@ static int _drbd_send_zc_ee(struct drbd_peer_device *peer_device, /* hint all but last page with MSG_MORE */ page_chain_for_each(page) { + struct iov_iter iter; + struct bio_vec bvec; unsigned l = min_t(unsigned, len, PAGE_SIZE); - err = _drbd_send_page(peer_device, page, 0, l, - page_chain_next(page) ? MSG_MORE : 0); + bvec_set_page(&bvec, page, 0, l); + iov_iter_bvec(&iter, ITER_SOURCE, &bvec, 1, l); + + err = _drbd_send_pages(peer_device, &iter, + MSG_SPLICE_PAGES | + (page_chain_next(page) ? MSG_MORE : 0)); if (err) return err; len -= l; From patchwork Fri Jun 16 16:12:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13282947 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 2C9E3EB64D7 for ; Fri, 16 Jun 2023 16:14:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0FD2A8E0001; Fri, 16 Jun 2023 12:14:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0D47294000A; Fri, 16 Jun 2023 12:14:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E8D548E000C; Fri, 16 Jun 2023 12:14:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id D6C038E0001 for ; Fri, 16 Jun 2023 12:14:02 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 92C0CB060B for ; Fri, 16 Jun 2023 16:14:02 +0000 (UTC) X-FDA: 80909107524.22.B46D988 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf23.hostedemail.com (Postfix) with ESMTP id 900E614002D for ; Fri, 16 Jun 2023 16:14:00 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=C1dYt+Dz; spf=pass (imf23.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=1686932040; a=rsa-sha256; cv=none; b=s3PYnRFNK32Yw8NEqh1ihbXuCTQKAjthGex1BkcMC8ZM91TpbcZoNT51kIvzeCpvhrrUBJ clh0bM0B+reRRhAvGG68o3NsK+/GOCQh+O2BU45lf18d8SD2OgiEf8RtY0Zf2FoATmqPI3 v1JOilc1EALxcqPwSDyu8Pgwmzd5Fxw= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=C1dYt+Dz; spf=pass (imf23.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=1686932040; 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=1mlTQ7sLbMYrLbD7sQOL6EL8ri/fJk9iL2N/GT0ngis=; b=LDHnppm6h09vLMaiHygIVLxBq0r8zzhv1FqQtMeNu1qCoFNd+Hqj22yMAj/iXvaS3cff5I 0rCj67jYBd6vrUDZte9t9fMsZenNpMoog/fqV75f7a1LJ7hJY41hEAhJXLYLwc1k2+Qzal vqJFZuE4QWDteCoCa/AdwJ6fZTzsLmA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686932039; 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=1mlTQ7sLbMYrLbD7sQOL6EL8ri/fJk9iL2N/GT0ngis=; b=C1dYt+DzvQMhIsTcvNEqAH15xKZgziE83XD//um90h8RnD7CNCoAC7h23gCUli+toizckj gtHNLJz4UHr2sD/KvAQ6UzPNNBa3aAcBEd3dhrviF+NV0DqwcmXhvSOoKRbznLO6hrSSHo BL4fmRLr1mnVhktjoL3s4VOiFQRIc/E= 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-80--ZJjLFLpNDyvwEUeqVNoyg-1; Fri, 16 Jun 2023 12:13:56 -0400 X-MC-Unique: -ZJjLFLpNDyvwEUeqVNoyg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C768A38041C6; Fri, 16 Jun 2023 16:13:55 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id C88111121314; Fri, 16 Jun 2023 16:13:53 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Alexander Duyck , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , Jens Axboe , linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Martin K. Petersen" , linux-scsi@vger.kernel.org, target-devel@vger.kernel.org Subject: [PATCH net-next 15/17] iscsi: Use sendmsg(MSG_SPLICE_PAGES) rather than sendpage Date: Fri, 16 Jun 2023 17:12:58 +0100 Message-ID: <20230616161301.622169-16-dhowells@redhat.com> In-Reply-To: <20230616161301.622169-1-dhowells@redhat.com> References: <20230616161301.622169-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 900E614002D X-Stat-Signature: g73orfyo8pbu843ueywhngbadnocpyaz X-Rspam-User: X-HE-Tag: 1686932040-574906 X-HE-Meta: U2FsdGVkX1/OMDncUEANTG3Xf+Du5svzZ29LkuR0uFuxqZAFuRAF4fXLKVG52QIisgYZ+lhABG1VE6ss7nPY3rkwSR0aHHglR9fk46VM/Hrnmz1IMmXKPZfLX4BQptI1o0eczEZNWcmJn7eU5xomvMaalVN9/+LuFmkEpPPUgpCXJqPzSdNZCaCYiO7Ias3Zfwj4cLBUa1FijlVeisn58+RlAq3dUgDCwQ3wfthKFCfaS9IO9PuoDk9zVUQ/IuJ4b87F7j2lcOuMFStVZ5N8sCs+Nrt2xnRMqkflUls1dvAJMe/4H7CNLiZsDcE+Ctk91ev0K0CoRw82lzYcSO67Sv94Ylpk6Z+4ku3E14+4WT7hESTWIGs7LyEmoGZ3truBqVaCf/a26y0l2nP37L0ckwAehihbgJdwdCFRJeZVcN9wR2IAqOKSYD3Uu6dOIZ99l/OXvR9zgAUs+r4Fod6rg8/L9yhipTjnAvrtpY9TBkLFhnWcIV4WDjx65TX/iIJMTVB9gvjDVuqhfwwgALqsglFVonrj1KNdrIt5CIG7CFG62W71EXnPsPOWCwHnNeWnxghx4id9E0AafpyKWA5wlrqwyCAGmGBm11Ph05fjWPlAp5z3yDR8kRYioE/9s8SFsPrAG80NsU21kC3jUMhyOWW06aIN65HYD4hXCicz+8Bujzl2KFq+rVXAo5BtJ9hlAqRqM1p7+RG7VifjcVAaqJcxKXJfq9NngqH5Zuy4EkhALTrM/ymmbkoJaNmCQsJ/EK9JrFQF0Rzt7FjeODVbBkmp3qj9QRG5AEmXTPt0QFV2imMuNKvAvHDzeAIUqPX9cTpklf5RoJzJpfKMG08Mf4ocZRugRj6S1gEWMxu/PZ6fvEhiz6ktMJfEJe5U1HyrEE0Lv35EnXpoBe4UJOEu/NA+ZVJ6UxmSyJfz97paOegwYytCuI32x/noR79yO62DnbvT10oWhbMr3HE74Bs LJM/RWNR w8E+P4gkS+QEN5b5g9HRMaGW7vaIZLAeXVuSaxKT8PMV7vZEAZMsw49Nj2ey3YuCslxOHleWhTU8r/aGGnZ5Y0wKLhhcUi8f21a9SdizhszG0kC9Bzd4zSxM5gmhS3zpFepICjIqpemjYiyoTZuizBQF++dP1gp8zIUmXemmj9rruUGGCCHTHxF3BxESrS2hZ4FynveC7cxqmhx34OcMBYZXH1AfXhTiHSsnvmJk2xc9dUufKmA2H+7tpwvJv/aDWhqxf74WZ2FvFAJUuZhC1FHT38R61RKN6Hg0Z7N3llKQFATKnWNIRHFyB7itFhKaLVNoNBs8+LXrX2ak//IViDnNmQzW8oiT8K3VIt+qHpiZsykywPm08OP3KE0a84b+uTUIVh6LGh/MF9zaw/5srovEVL4qN0r6TOLgO3qpQofzdmXt1+VkZnMOak2f5JasNC/1pV51ejeyl0sGSd1FuHMLKQkOinGSnJfPtew45h1SbuZUF2/BqZ+lVRKl69WnakhO33hNR7wvzsvQ= 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: Use sendmsg() with MSG_SPLICE_PAGES rather than sendpage. This allows multiple pages and multipage folios to be passed through. TODO: iscsit_fe_sendpage_sg() should perhaps set up a bio_vec array for the entire set of pages it's going to transfer plus two for the header and trailer and page fragments to hold the header and trailer - and then call sendmsg once for the entire message. Signed-off-by: David Howells cc: "Martin K. Petersen" cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: Jens Axboe cc: Matthew Wilcox cc: linux-scsi@vger.kernel.org cc: target-devel@vger.kernel.org cc: netdev@vger.kernel.org --- drivers/scsi/iscsi_tcp.c | 26 +++++++++--------------- drivers/scsi/iscsi_tcp.h | 2 +- drivers/target/iscsi/iscsi_target_util.c | 14 +++++++------ 3 files changed, 19 insertions(+), 23 deletions(-) diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c index 9637d4bc2bc9..9ab8555180a3 100644 --- a/drivers/scsi/iscsi_tcp.c +++ b/drivers/scsi/iscsi_tcp.c @@ -301,35 +301,32 @@ static int iscsi_sw_tcp_xmit_segment(struct iscsi_tcp_conn *tcp_conn, while (!iscsi_tcp_segment_done(tcp_conn, segment, 0, r)) { struct scatterlist *sg; + struct msghdr msg = {}; + struct bio_vec bv; unsigned int offset, copy; - int flags = 0; r = 0; offset = segment->copied; copy = segment->size - offset; if (segment->total_copied + segment->size < segment->total_size) - flags |= MSG_MORE | MSG_SENDPAGE_NOTLAST; + msg.msg_flags |= MSG_MORE; if (tcp_sw_conn->queue_recv) - flags |= MSG_DONTWAIT; + msg.msg_flags |= MSG_DONTWAIT; - /* Use sendpage if we can; else fall back to sendmsg */ if (!segment->data) { + if (!tcp_conn->iscsi_conn->datadgst_en) + msg.msg_flags |= MSG_SPLICE_PAGES; sg = segment->sg; offset += segment->sg_offset + sg->offset; - r = tcp_sw_conn->sendpage(sk, sg_page(sg), offset, - copy, flags); + bvec_set_page(&bv, sg_page(sg), copy, offset); } else { - struct msghdr msg = { .msg_flags = flags }; - struct kvec iov = { - .iov_base = segment->data + offset, - .iov_len = copy - }; - - r = kernel_sendmsg(sk, &msg, &iov, 1, copy); + bvec_set_virt(&bv, segment->data + offset, copy); } + iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bv, 1, copy); + r = sock_sendmsg(sk, &msg); if (r < 0) { iscsi_tcp_segment_unmap(segment); return r; @@ -746,7 +743,6 @@ iscsi_sw_tcp_conn_bind(struct iscsi_cls_session *cls_session, sock_no_linger(sk); iscsi_sw_tcp_conn_set_callbacks(conn); - tcp_sw_conn->sendpage = tcp_sw_conn->sock->ops->sendpage; /* * set receive state machine into initial state */ @@ -777,8 +773,6 @@ static int iscsi_sw_tcp_conn_set_param(struct iscsi_cls_conn *cls_conn, return -ENOTCONN; } iscsi_set_param(cls_conn, param, buf, buflen); - tcp_sw_conn->sendpage = conn->datadgst_en ? - sock_no_sendpage : tcp_sw_conn->sock->ops->sendpage; mutex_unlock(&tcp_sw_conn->sock_lock); break; case ISCSI_PARAM_MAX_R2T: diff --git a/drivers/scsi/iscsi_tcp.h b/drivers/scsi/iscsi_tcp.h index 68e14a344904..d6ec08d7eb63 100644 --- a/drivers/scsi/iscsi_tcp.h +++ b/drivers/scsi/iscsi_tcp.h @@ -48,7 +48,7 @@ struct iscsi_sw_tcp_conn { uint32_t sendpage_failures_cnt; uint32_t discontiguous_hdr_cnt; - ssize_t (*sendpage)(struct socket *, struct page *, int, size_t, int); + bool can_splice_to_tcp; }; struct iscsi_sw_tcp_host { diff --git a/drivers/target/iscsi/iscsi_target_util.c b/drivers/target/iscsi/iscsi_target_util.c index b14835fcb033..8bab1898f1d0 100644 --- a/drivers/target/iscsi/iscsi_target_util.c +++ b/drivers/target/iscsi/iscsi_target_util.c @@ -1129,6 +1129,8 @@ int iscsit_fe_sendpage_sg( struct iscsit_conn *conn) { struct scatterlist *sg = cmd->first_data_sg; + struct bio_vec bvec; + struct msghdr msghdr = { .msg_flags = MSG_SPLICE_PAGES, }; struct kvec iov; u32 tx_hdr_size, data_len; u32 offset = cmd->first_data_sg_off; @@ -1172,17 +1174,17 @@ int iscsit_fe_sendpage_sg( u32 space = (sg->length - offset); u32 sub_len = min_t(u32, data_len, space); send_pg: - tx_sent = conn->sock->ops->sendpage(conn->sock, - sg_page(sg), sg->offset + offset, sub_len, 0); + bvec_set_page(&bvec, sg_page(sg), sub_len, sg->offset + offset); + iov_iter_bvec(&msghdr.msg_iter, ITER_SOURCE, &bvec, 1, sub_len); + + tx_sent = conn->sock->ops->sendmsg(conn->sock, &msghdr, sub_len); if (tx_sent != sub_len) { if (tx_sent == -EAGAIN) { - pr_err("tcp_sendpage() returned" - " -EAGAIN\n"); + pr_err("sendmsg/splice returned -EAGAIN\n"); goto send_pg; } - pr_err("tcp_sendpage() failure: %d\n", - tx_sent); + pr_err("sendmsg/splice failure: %d\n", tx_sent); return -1; } From patchwork Fri Jun 16 16:13:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13282948 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 2BD02EB64D7 for ; Fri, 16 Jun 2023 16:14:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B5B7C8E0008; Fri, 16 Jun 2023 12:14:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B0B3D8E0003; Fri, 16 Jun 2023 12:14:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9D3838E0008; Fri, 16 Jun 2023 12:14:14 -0400 (EDT) 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 8DA318E0003 for ; Fri, 16 Jun 2023 12:14:14 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 442FC120CE9 for ; Fri, 16 Jun 2023 16:14:14 +0000 (UTC) X-FDA: 80909108028.02.8F86256 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf17.hostedemail.com (Postfix) with ESMTP id 747C040004 for ; Fri, 16 Jun 2023 16:14:12 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="C/cgzHYM"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf17.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.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=1686932052; 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=GgXl23oT7K0tvgN6cZOrzYYVKbsvCr/2QJSVqeWfBGc=; b=YGhGVQcxrEh3cDLeNNU+KDBEnMz0/cS50lh02mHQRy/8lrZHN4dOQTWgW1WfiCg4kAC9fy sFYEeSYsKAUZCM2FmQNhXP0MN4M1gCbGT54IFV91jxaj/9GoY1G1+N4KaLReXp696y8yv3 0x+uFeM4EIQJxcRgkurT/F38rxsLVhs= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="C/cgzHYM"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf17.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686932052; a=rsa-sha256; cv=none; b=KtSOTWecU7yU0oftXHuXL8SYdmXQJvtu86BtQCTVqtRhZIUIiay9okW1VevH4TYoD3le0x 4yB2VO9+QePT6vrShdoZheWOf/bkLsWPLdbHfQzfGPjiqnayM7btGsEdEu8nwNEdQUJcl5 WsScGVWV4nHKrw7RMJXxvclq4buWPPA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686932051; 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=GgXl23oT7K0tvgN6cZOrzYYVKbsvCr/2QJSVqeWfBGc=; b=C/cgzHYM2xsyBh3cpAcVzK6W0u3RlVNZ5WX6HI5KpkySwcgzBNSpM5T7zhXz9YEqcqYpOr Qa+mkIdYcz4PFjRPBD+DNrVdYr5WHZPfCZEpVQhwf92c1RlStBCPbB7XP6kt3spELJ9O33 ZglM+A3gBDJro1nzHMjyelq2b+FGX2c= 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-474-4xCSkvt7P5eT3R0bKQzV_A-1; Fri, 16 Jun 2023 12:14:06 -0400 X-MC-Unique: 4xCSkvt7P5eT3R0bKQzV_A-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 6B849801211; Fri, 16 Jun 2023 16:14:05 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id CCF571415102; Fri, 16 Jun 2023 16:14:03 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Alexander Duyck , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , Jens Axboe , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 17/17] net: Kill MSG_SENDPAGE_NOTLAST Date: Fri, 16 Jun 2023 17:13:00 +0100 Message-ID: <20230616161301.622169-18-dhowells@redhat.com> In-Reply-To: <20230616161301.622169-1-dhowells@redhat.com> References: <20230616161301.622169-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 747C040004 X-Stat-Signature: 79yp68dkscax4nu1ip4bos8gde8dqd4n X-HE-Tag: 1686932052-541491 X-HE-Meta: U2FsdGVkX1/GxtOVIASyEt01xrvfF1cAzHjKUz0a6xyfpXy7hxakcmG428yWDBQdg0nR8woT1vLefmA6+ZiPAsdaTlXeOhtBK5IHBEx9X8WlrLw4rod51K4Rb5sw8IOV36smQDr6ayYzytWAkaW48bIATGP/pYipo4P/UDFXIwLEGAsAWvKUCidQHrGW0yGO9V2P8Ite4VZX0doZneS3pswFZCztV8ZUJQX0h/VVlv9rBAwMA4ogaXZytPbfx3Ui43FlqU0zEqQxwiNq2CYIA6so9LeJZCUATi6YokVrgKCd07x/EeIEh6zNF93IJOQIteDcDDbLxiGL83rpN3ZkJOvcfV0aZzZ5bn4VlCvHPxUpdKGnkIZvYyxTfd8juexot3PK4eQLsc14fw+SDWhO2GAhQn0DLeTAmVYFYkZ/DZDQGGBUjrpTOPRae4arpBvvcsvH8b5VBlnQBQPEBFkCdc5qMM8gkdjcyH00ob+HDR0W+ONA2E6wEhzisBGmOhygDPG8kR++cD5bhBpouz1TWDTH5BN3H3EvjO9AR3wWJLJJPPGbFBAlaO/vsLKHRkcvMcpDfs+9jvKJJApKfnaP/wxKe0QI6zRsr9r/TpuRLBc4rRlRVHyrwQbJa/BhB0A3f1/7NecSgOXG3yG9wN2Xw6PzpjeRALrCt7kLS9WMQWyY1Nfzy9+kb1H34LvyTW6RvoA35Ah4gUJPYVnJZMfGK5xS3Be2XHjiP7m7YREDThunuTRAaWPscPPeFZGt524EiKfUjYJazH08jUZz/8xWMGi3its8KNnKSwzULhC89oFeFXxnsxaTOPPi8d0vx9b1uoKoouq0U9CnJ+veEzrxd7YZHzSWUJZuBG7d93aMP4L7E49G2ke3mebs0rD07dmb1Lt87SIEwR2EU8rdKgaRRkUquQHb1ktGBScT9U4YmUKVaFZqGOVE/n8p4VlUttegHtYPxncDNDZfPRqAPRz +J//ifKU pH6ycXCEt6r9x0zpFyP89FnBWu75VpU9qgKV2fD+RtKGTQSzNPH4quRMcdpMQMb9Z1Wx6rzdRIySlKwk/wmL01xYk0KpGmduUOR/k+22Gmod18z+2Ze+ZgKZITUvGYQCDn1k57aRWUHyG1b4HCneVQb5XT5VywbV+vujWn5WW6NHVtEUKpM4EFxV7110fT+AjsDt0M+6XuDWWNiQphTZ00DBmKJFlyktRFroo4MRNbHGivtFVktdg2zME7rT4v18B4tuA8AsrwRbvXSk= 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: --- include/linux/socket.h | 4 +--- net/ipv4/tcp_bpf.c | 4 +++- net/tls/tls_device.c | 3 +-- net/tls/tls_main.c | 2 +- net/tls/tls_sw.c | 2 +- tools/perf/trace/beauty/include/linux/socket.h | 1 - tools/perf/trace/beauty/msg_flags.c | 3 --- 7 files changed, 7 insertions(+), 12 deletions(-) diff --git a/include/linux/socket.h b/include/linux/socket.h index 58204700018a..39b74d83c7c4 100644 --- a/include/linux/socket.h +++ b/include/linux/socket.h @@ -319,7 +319,6 @@ struct ucred { #define MSG_MORE 0x8000 /* Sender will send more */ #define MSG_WAITFORONE 0x10000 /* recvmmsg(): block until 1+ packets avail */ #define MSG_SENDPAGE_NOPOLICY 0x10000 /* sendpage() internal : do no apply policy */ -#define MSG_SENDPAGE_NOTLAST 0x20000 /* sendpage() internal : not the last page */ #define MSG_BATCH 0x40000 /* sendmmsg(): more messages coming */ #define MSG_EOF MSG_FIN #define MSG_NO_SHARED_FRAGS 0x80000 /* sendpage() internal : page frags are not shared */ @@ -341,8 +340,7 @@ struct ucred { /* Flags to be cleared on entry by sendmsg and sendmmsg syscalls */ #define MSG_INTERNAL_SENDMSG_FLAGS \ - (MSG_SPLICE_PAGES | MSG_SENDPAGE_NOPOLICY | MSG_SENDPAGE_NOTLAST | \ - MSG_SENDPAGE_DECRYPTED) + (MSG_SPLICE_PAGES | MSG_SENDPAGE_NOPOLICY | MSG_SENDPAGE_DECRYPTED) /* Setsockoptions(2) level. Thanks to BSD these must match IPPROTO_xxx */ #define SOL_IP 0 diff --git a/net/ipv4/tcp_bpf.c b/net/ipv4/tcp_bpf.c index 870c1cde4010..8f535e436ea3 100644 --- a/net/ipv4/tcp_bpf.c +++ b/net/ipv4/tcp_bpf.c @@ -90,7 +90,9 @@ static int tcp_bpf_push(struct sock *sk, struct sk_msg *msg, u32 apply_bytes, { bool apply = apply_bytes; struct scatterlist *sge; - struct msghdr msghdr = { .msg_flags = flags | MSG_SPLICE_PAGES, }; + struct msghdr msghdr = { + .msg_flags = flags | MSG_SPLICE_PAGES | MSG_MORE, + }; struct page *page; int size, ret = 0; u32 off; diff --git a/net/tls/tls_device.c b/net/tls/tls_device.c index 840ee06f1708..2021fe557e50 100644 --- a/net/tls/tls_device.c +++ b/net/tls/tls_device.c @@ -441,8 +441,7 @@ static int tls_push_data(struct sock *sk, long timeo; if (flags & - ~(MSG_MORE | MSG_DONTWAIT | MSG_NOSIGNAL | MSG_SENDPAGE_NOTLAST | - MSG_SPLICE_PAGES)) + ~(MSG_MORE | MSG_DONTWAIT | MSG_NOSIGNAL | MSG_SPLICE_PAGES)) return -EOPNOTSUPP; if (unlikely(sk->sk_err)) diff --git a/net/tls/tls_main.c b/net/tls/tls_main.c index d5ed4d47b16e..b6896126bb92 100644 --- a/net/tls/tls_main.c +++ b/net/tls/tls_main.c @@ -127,7 +127,7 @@ int tls_push_sg(struct sock *sk, { struct bio_vec bvec; struct msghdr msg = { - .msg_flags = MSG_SENDPAGE_NOTLAST | MSG_SPLICE_PAGES | flags, + .msg_flags = MSG_SPLICE_PAGES | flags, }; int ret = 0; struct page *p; diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c index 9b3aa89a4292..53f944e6d8ef 100644 --- a/net/tls/tls_sw.c +++ b/net/tls/tls_sw.c @@ -1194,7 +1194,7 @@ int tls_sw_sendmsg(struct sock *sk, struct msghdr *msg, size_t size) if (msg->msg_flags & ~(MSG_MORE | MSG_DONTWAIT | MSG_NOSIGNAL | MSG_CMSG_COMPAT | MSG_SPLICE_PAGES | - MSG_SENDPAGE_NOTLAST | MSG_SENDPAGE_NOPOLICY)) + MSG_SENDPAGE_NOPOLICY)) return -EOPNOTSUPP; ret = mutex_lock_interruptible(&tls_ctx->tx_lock); diff --git a/tools/perf/trace/beauty/include/linux/socket.h b/tools/perf/trace/beauty/include/linux/socket.h index 13c3a237b9c9..3bef212a24d7 100644 --- a/tools/perf/trace/beauty/include/linux/socket.h +++ b/tools/perf/trace/beauty/include/linux/socket.h @@ -318,7 +318,6 @@ struct ucred { #define MSG_MORE 0x8000 /* Sender will send more */ #define MSG_WAITFORONE 0x10000 /* recvmmsg(): block until 1+ packets avail */ #define MSG_SENDPAGE_NOPOLICY 0x10000 /* sendpage() internal : do no apply policy */ -#define MSG_SENDPAGE_NOTLAST 0x20000 /* sendpage() internal : not the last page */ #define MSG_BATCH 0x40000 /* sendmmsg(): more messages coming */ #define MSG_EOF MSG_FIN #define MSG_NO_SHARED_FRAGS 0x80000 /* sendpage() internal : page frags are not shared */ diff --git a/tools/perf/trace/beauty/msg_flags.c b/tools/perf/trace/beauty/msg_flags.c index ea68db08b8e7..b5b580e5a77e 100644 --- a/tools/perf/trace/beauty/msg_flags.c +++ b/tools/perf/trace/beauty/msg_flags.c @@ -8,9 +8,6 @@ #ifndef MSG_WAITFORONE #define MSG_WAITFORONE 0x10000 #endif -#ifndef MSG_SENDPAGE_NOTLAST -#define MSG_SENDPAGE_NOTLAST 0x20000 -#endif #ifndef MSG_FASTOPEN #define MSG_FASTOPEN 0x20000000 #endif