From patchwork Fri Jun 9 10:02:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13273615 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 58C95C7EE37 for ; Fri, 9 Jun 2023 10:02:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DFC168E0005; Fri, 9 Jun 2023 06:02:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DE22E8E0006; Fri, 9 Jun 2023 06:02:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C2A708E0005; Fri, 9 Jun 2023 06:02:37 -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 B54C78E0001 for ; Fri, 9 Jun 2023 06:02:37 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 824FF801BB for ; Fri, 9 Jun 2023 10:02:37 +0000 (UTC) X-FDA: 80882769954.20.5B69EE7 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf10.hostedemail.com (Postfix) with ESMTP id 6593CC002F for ; Fri, 9 Jun 2023 10:02:34 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=D8iRJxSp; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf10.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=1686304954; 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=5xS0EjvCiKchfkvdTJdOtsTA5MUfwNb38QZYdhFXqpc=; b=2H+QGsLlU8cAp8UUGbV4JNQYwiEG9r0OtUe4mZw93WjQ9uIK/yEPfEgtB/C+ZlWa4zpQ/O 5FQpIdjXfYSa2ozaHzL+zI9fWZG80O2gcszW1mQTFZmHXMI85S5GjW6sqDt6I7WwK5VAO+ cjGUSKE9gUb4kAQx3W5jyKzTblZz9YQ= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=D8iRJxSp; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf10.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=1686304954; a=rsa-sha256; cv=none; b=qBhxESflwk2DvhUKMvb00iI+FQKly+o/12rqQ7KZfck1tz9h5rvmGOlgJ2QSLvbScwP9ED B1y/VpXIwbS629YUcr620DWT9ABSA5VAmy6CUjaeik3UUyg9gniegykEUYD5XlkvP8s8L/ TW3pgDGm+FIIFbZYNq0U7DOlqGtobBo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686304953; 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=5xS0EjvCiKchfkvdTJdOtsTA5MUfwNb38QZYdhFXqpc=; b=D8iRJxSpvhRT4yBqCJ2rMYxWIdBG1e8/f4wK5Z6eaWa211jIn3i5i1DvsAAHogkY3FDdUR z+ZlKJqRXE8etGzCmlQeHTDOpCNiLIekybo55jJWfycYiU9VFmw6BmO1hhFlCWdtWlRytG 0TJ6IVFkk9w1VR5FuViQNltaLKAouhk= 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-516-FqgRmzDbNx-frSMXVDLQFw-1; Fri, 09 Jun 2023 06:02:28 -0400 X-MC-Unique: FqgRmzDbNx-frSMXVDLQFw-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 542BA101A53B; Fri, 9 Jun 2023 10:02:27 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id D69FF10C13; Fri, 9 Jun 2023 10:02:25 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , Jens Axboe , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 1/6] Remove file->f_op->sendpage Date: Fri, 9 Jun 2023 11:02:16 +0100 Message-ID: <20230609100221.2620633-2-dhowells@redhat.com> In-Reply-To: <20230609100221.2620633-1-dhowells@redhat.com> References: <20230609100221.2620633-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Rspam-User: X-Stat-Signature: u6i1gjsbznmz6ywj4bxumh9abcabztkf X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 6593CC002F X-HE-Tag: 1686304954-541225 X-HE-Meta: U2FsdGVkX1+MTbP2ovWfBPUJ25ti1voV2cu2pLBFjLVfORr+jNwjvudAZqFiJKR2KGcptBM2tzWag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y2uKn6XwmZqWVzIUOl83pXG5skLwnmTBHKcos/R5qqc+PJ491T8sjN3uMqdsuO1tg/xj8Nx5So6Nu55X3PHYzSR6s93VJzeRBEdiJDfpFYDWzp8KLhUUQiu6Tgj2bxAo17Ae42fYCK2/PDZuATa8TAmHG3fI6imbbdwAzNqy6T7W5+ZOpEEfakNQDe+y5IupzfhqLKIwpri2wKOJOOLibQMQgG2NLxVMxVUBWh3anI6X5bxNl6bYJoFgpOm3yIGyXIBTHYM5mmDDvZoDOrmOheMEVODw5PsgWbQppvW3Cq25CzdiUOyeJmG/461soPscgUy2PJzV7XLG+P/W8eg+mg== 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: Remove file->f_op->sendpage as splicing to a socket now calls sendmsg rather than sendpage. 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 --- include/linux/fs.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/linux/fs.h b/include/linux/fs.h index de2cb1132f07..67998c64556d 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1790,7 +1790,6 @@ struct file_operations { int (*fsync) (struct file *, loff_t, loff_t, int datasync); int (*fasync) (int, struct file *, int); int (*lock) (struct file *, int, struct file_lock *); - ssize_t (*sendpage) (struct file *, struct page *, int, size_t, loff_t *, int); unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long); int (*check_flags)(int); int (*flock) (struct file *, int, struct file_lock *); From patchwork Fri Jun 9 10:02:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13273616 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 32D19C7EE2E for ; Fri, 9 Jun 2023 10:02:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 28EEB8E0006; Fri, 9 Jun 2023 06:02:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 21BAB8E0001; Fri, 9 Jun 2023 06:02:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 08EDE8E0007; Fri, 9 Jun 2023 06:02:37 -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 D1AF08E0001 for ; Fri, 9 Jun 2023 06:02:37 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 9C942801C3 for ; Fri, 9 Jun 2023 10:02:37 +0000 (UTC) X-FDA: 80882769954.15.499C166 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf21.hostedemail.com (Postfix) with ESMTP id A6E841C0028 for ; Fri, 9 Jun 2023 10:02:34 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=dhbiso+s; spf=pass (imf21.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=1686304954; a=rsa-sha256; cv=none; b=H/6r9+TO230AKief9fwPjv5fGjbbTGGyDmvFY3STnMG0Sbee591L/rRQGiYaVsU905Kzet BulTwlL69RP+oZOPNHHFhMmMUt6P9bHa33bVTDRhX0kmSur5x495YjPRMWd4FH+/Y8vnc0 U7G2V+OpTH7GZwnh1zBOwdewUEGnxKw= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=dhbiso+s; spf=pass (imf21.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=1686304954; 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=pG6mXFErgEQ8ZgVFj/OVbi2iAUQF/l3Cm4NkJ83benc=; b=dYqnPKTtXmh4WpSo8DzlAjXK0lYWjCG1CEWdX6hKygvKirAGnGlCRNnKDseM2H81wFNY78 kyjKFQu4ONLPdv4Ifm70UTSNl/s8C1CIOpdSIVDH4mfVxuo/zW3cyXvBUBtxGTGTrmx82H kw3G2He9LXdFUPFxbbfrbsjX7tJlW4Q= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686304954; 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=pG6mXFErgEQ8ZgVFj/OVbi2iAUQF/l3Cm4NkJ83benc=; b=dhbiso+slD0fjsIU0ns7h3Chk+9Z4O4FuYon6YJokNw5Vg9v62jFR2b30xQwvIjMdJlsFH G8q15cxYA3UgoukpWcQHGKd8Ikjxw9iOHFX+7OQkXHyMju2G3/o/2r4Emx/A2JScZbRUXr 8pIYEwsYvyh+rIC2r1HMJ4M8EeUexh0= 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-66-QaZulYcBM26mge84teR9Xw-1; Fri, 09 Jun 2023 06:02:30 -0400 X-MC-Unique: QaZulYcBM26mge84teR9Xw-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 E214880013A; Fri, 9 Jun 2023 10:02:29 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id 223D9492B00; Fri, 9 Jun 2023 10:02:28 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , Jens Axboe , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Herbert Xu , linux-crypto@vger.kernel.org Subject: [PATCH net-next 2/6] algif: Remove hash_sendpage*() Date: Fri, 9 Jun 2023 11:02:17 +0100 Message-ID: <20230609100221.2620633-3-dhowells@redhat.com> In-Reply-To: <20230609100221.2620633-1-dhowells@redhat.com> References: <20230609100221.2620633-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: A6E841C0028 X-Stat-Signature: o7uy9ijpu8w6h1b4wt9kusfx456m76pu X-Rspam-User: X-HE-Tag: 1686304954-220950 X-HE-Meta: U2FsdGVkX18N3AxUp8QI1RO0wjwi4q2yCgJ2Wga+q318YpTaUtnG+zqhcCJwap8ixIIOpMI4xorD+rtsXE707QRnsxKvs1gAKHRkRiGC0ErVUc0IHuCv9F0VcZXkuP5Xy3ByITjgx3MabF0y7ZQhJr2bHMrysQ8ejli6HHXJaGg2Z0bqCJW28BeeulC2PsxEiEpvrNg0/PfPUWVnZzEKcLQDun+zztKNoLP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VjubJWRSyj1ceYNhY8E4AIpqklEj4z8AnjQVPP2r0lrtNtz6WdFKXSwDEcOqBaSk+YpYpm8rleJRUKHU9hX4FlY8q1vEmyhTtphxggjtRJ8uNwpDbijX13yK8XkNV1B5oFClNwY/HQsfPUjE4HprVmN7gU6cwkeaLYnyLm5Lf3AkcAvYpg3Pzjjuq7L3azH6CvXcXQLnapg1utfzqu1V2rLEXbn7LVuRc/e4= 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: Remove hash_sendpage*() as nothing should now call it since the rewrite of splice_to_socket()[1]. Signed-off-by: David Howells cc: Herbert Xu cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: Jens Axboe cc: Matthew Wilcox cc: linux-crypto@vger.kernel.org cc: netdev@vger.kernel.org Link: https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/commit/?id=2dc334f1a63a8839b88483a3e73c0f27c9c1791c [1] --- crypto/algif_hash.c | 66 --------------------------------------------- 1 file changed, 66 deletions(-) diff --git a/crypto/algif_hash.c b/crypto/algif_hash.c index 1a2d80c6c91a..dfb048cefb60 100644 --- a/crypto/algif_hash.c +++ b/crypto/algif_hash.c @@ -161,58 +161,6 @@ static int hash_sendmsg(struct socket *sock, struct msghdr *msg, goto unlock; } -static ssize_t hash_sendpage(struct socket *sock, struct page *page, - int offset, size_t size, int flags) -{ - struct sock *sk = sock->sk; - struct alg_sock *ask = alg_sk(sk); - struct hash_ctx *ctx = ask->private; - int err; - - if (flags & MSG_SENDPAGE_NOTLAST) - flags |= MSG_MORE; - - lock_sock(sk); - sg_init_table(ctx->sgl.sgl, 1); - sg_set_page(ctx->sgl.sgl, page, size, offset); - - if (!(flags & MSG_MORE)) { - err = hash_alloc_result(sk, ctx); - if (err) - goto unlock; - } else if (!ctx->more) - hash_free_result(sk, ctx); - - ahash_request_set_crypt(&ctx->req, ctx->sgl.sgl, ctx->result, size); - - if (!(flags & MSG_MORE)) { - if (ctx->more) - err = crypto_ahash_finup(&ctx->req); - else - err = crypto_ahash_digest(&ctx->req); - } else { - if (!ctx->more) { - err = crypto_ahash_init(&ctx->req); - err = crypto_wait_req(err, &ctx->wait); - if (err) - goto unlock; - } - - err = crypto_ahash_update(&ctx->req); - } - - err = crypto_wait_req(err, &ctx->wait); - if (err) - goto unlock; - - ctx->more = flags & MSG_MORE; - -unlock: - release_sock(sk); - - return err ?: size; -} - static int hash_recvmsg(struct socket *sock, struct msghdr *msg, size_t len, int flags) { @@ -328,7 +276,6 @@ static struct proto_ops algif_hash_ops = { .release = af_alg_release, .sendmsg = hash_sendmsg, - .sendpage = hash_sendpage, .recvmsg = hash_recvmsg, .accept = hash_accept, }; @@ -380,18 +327,6 @@ static int hash_sendmsg_nokey(struct socket *sock, struct msghdr *msg, return hash_sendmsg(sock, msg, size); } -static ssize_t hash_sendpage_nokey(struct socket *sock, struct page *page, - int offset, size_t size, int flags) -{ - int err; - - err = hash_check_key(sock); - if (err) - return err; - - return hash_sendpage(sock, page, offset, size, flags); -} - static int hash_recvmsg_nokey(struct socket *sock, struct msghdr *msg, size_t ignored, int flags) { @@ -430,7 +365,6 @@ static struct proto_ops algif_hash_ops_nokey = { .release = af_alg_release, .sendmsg = hash_sendmsg_nokey, - .sendpage = hash_sendpage_nokey, .recvmsg = hash_recvmsg_nokey, .accept = hash_accept_nokey, }; From patchwork Fri Jun 9 10:02:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13273618 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 0691AC7EE43 for ; Fri, 9 Jun 2023 10:02:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 947BB8E0008; Fri, 9 Jun 2023 06:02:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8CF0E8E0001; Fri, 9 Jun 2023 06:02:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7209E8E0008; Fri, 9 Jun 2023 06:02:42 -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 62AC98E0001 for ; Fri, 9 Jun 2023 06:02:42 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id F059A1C747A for ; Fri, 9 Jun 2023 10:02:41 +0000 (UTC) X-FDA: 80882770122.02.06B5AC1 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf26.hostedemail.com (Postfix) with ESMTP id 2378E14001D for ; Fri, 9 Jun 2023 10:02:38 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=BafAUcNZ; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf26.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=1686304959; 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=PTIph0AO3Glm0cHnpdSUPYaa1BCa6IyevnPVIS0MlWU=; b=19LGR23XfHnFOUrdxHRCPoRgPTRckWEJHlJ4v2eUVRXmSLHZ366vLCx8mHc4qyZCRq/vDO 84TcbHjSLhUroxbMSItVP85GrN3+WtWEkodpneTfgcZODdqzSgLcUs+7rply2Wr1e0TMoF 7fYC4nJML1ngiKPYZq0NX2djlp7MXO8= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=BafAUcNZ; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf26.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=1686304959; a=rsa-sha256; cv=none; b=eTC2cQETv4SSJg8mqGTW+6kT1q4JL0t0B2iRN4RBfGjFDIKPyFKk2hjAd7kibAPrU+DO4i lk8GOY/2y87s9iBU6gA260Osx+rHsmw6b8EkHiBviV4nP3YzdEtR7basfdvz6RBGMxJqY+ swtoHj4xmC0hrFvyduZtDc28NpNz/p0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686304958; 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=PTIph0AO3Glm0cHnpdSUPYaa1BCa6IyevnPVIS0MlWU=; b=BafAUcNZy/E83B/Q22rlwzOEf1VtnHwsnX4cYe45R2BhnJB15G3dTglU5Q3Elf8KoR4tUH PS1pSwhG/9Sy/28Tb/Nb65ol2oO3KFYo/S4rHHMucxh+PE1yKmggU4HpeQqG9iUapiB/uJ TX20Zwikujm/UC7yI3Ff/dl/Vvs7Cxc= 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-65-Y6xKU7LEMfuedTeRt3xdBA-1; Fri, 09 Jun 2023 06:02:34 -0400 X-MC-Unique: Y6xKU7LEMfuedTeRt3xdBA-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 75714185A78E; Fri, 9 Jun 2023 10:02:33 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id B47D840C1438; Fri, 9 Jun 2023 10:02:30 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , Jens Axboe , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Chuck Lever , Trond Myklebust , Anna Schumaker , Jeff Layton , linux-nfs@vger.kernel.org Subject: [PATCH net-next 3/6] sunrpc: Use sendmsg(MSG_SPLICE_PAGES) rather then sendpage Date: Fri, 9 Jun 2023 11:02:18 +0100 Message-ID: <20230609100221.2620633-4-dhowells@redhat.com> In-Reply-To: <20230609100221.2620633-1-dhowells@redhat.com> References: <20230609100221.2620633-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Rspamd-Queue-Id: 2378E14001D X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 6s31ns8zaz5k8zy8pdormc4mdddqana5 X-HE-Tag: 1686304958-290847 X-HE-Meta: U2FsdGVkX19AkrBeS88qOspYpW9EgGjp/uU+ojbylCboIDHuK/QIxMIC+eoUIRh9Hz35HhTBOeSKPf+TmZHlWHePfWp1CPzfFn3AMnJNmApvswQfZOLhklafQSLZSzSKQl5edjnZkksbyboKtZi5sgIRfcckRPpxauSGpHjoSGegTdruqOgQqPZjnPl6L7cfExEJl3GySoA8IGtXUCkVPNFRQsXBVHcCH5mxT+whVhIFHycv6kPGjP7t4jzxxhgvXOgziMRQfBoOcrFKx/OBIdUGDGLE5Jg93wt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aZ3P++MDYOj1KsOBjNSG9GFgVCWnlr2nRRtHnoM6/UIS5MkBLDFiwnopq2ORUA/bOCi5euwptr8fUk90pG+VrNVgqSXJ7tpKa7erCjXDwVYheV6Rfhr/biBGcNy9jKq84IZcQxoHC2EKaVqW2EJjysMHGecYuP8tjDK/jhzDXB2qySRcNtVdqok75VgP0utGLk9/IlmdQ52g= 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 sendmsg with MSG_SPLICE_PAGES to indicate that content should be spliced rather than performing sendpage calls to transmit header, data pages and trailer. Signed-off-by: David Howells Acked-by: Chuck Lever cc: Trond Myklebust cc: Anna Schumaker cc: Jeff Layton cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: Jens Axboe cc: Matthew Wilcox cc: linux-nfs@vger.kernel.org cc: netdev@vger.kernel.org --- include/linux/sunrpc/svc.h | 11 +++++------ net/sunrpc/svcsock.c | 38 ++++++++++++-------------------------- 2 files changed, 17 insertions(+), 32 deletions(-) diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h index 762d7231e574..f66ec8fdb331 100644 --- a/include/linux/sunrpc/svc.h +++ b/include/linux/sunrpc/svc.h @@ -161,16 +161,15 @@ static inline bool svc_put_not_last(struct svc_serv *serv) extern u32 svc_max_payload(const struct svc_rqst *rqstp); /* - * RPC Requsts and replies are stored in one or more pages. + * RPC Requests and replies are stored in one or more pages. * We maintain an array of pages for each server thread. * Requests are copied into these pages as they arrive. Remaining * pages are available to write the reply into. * - * Pages are sent using ->sendpage so each server thread needs to - * allocate more to replace those used in sending. To help keep track - * of these pages we have a receive list where all pages initialy live, - * and a send list where pages are moved to when there are to be part - * of a reply. + * Pages are sent using ->sendmsg with MSG_SPLICE_PAGES so each server thread + * needs to allocate more to replace those used in sending. To help keep track + * of these pages we have a receive list where all pages initialy live, and a + * send list where pages are moved to when there are to be part of a reply. * * We use xdr_buf for holding responses as it fits well with NFS * read responses (that have a header, and some data pages, and possibly diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c index f77cebe2c071..9d9f522e3ae1 100644 --- a/net/sunrpc/svcsock.c +++ b/net/sunrpc/svcsock.c @@ -1203,13 +1203,14 @@ static int svc_tcp_recvfrom(struct svc_rqst *rqstp) static int svc_tcp_send_kvec(struct socket *sock, const struct kvec *vec, int flags) { - return kernel_sendpage(sock, virt_to_page(vec->iov_base), - offset_in_page(vec->iov_base), - vec->iov_len, flags); + struct msghdr msg = { .msg_flags = MSG_SPLICE_PAGES | flags, }; + + iov_iter_kvec(&msg.msg_iter, ITER_SOURCE, vec, 1, vec->iov_len); + return sock_sendmsg(sock, &msg); } /* - * kernel_sendpage() is used exclusively to reduce the number of + * MSG_SPLICE_PAGES is used exclusively to reduce the number of * copy operations in this path. Therefore the caller must ensure * that the pages backing @xdr are unchanging. * @@ -1249,28 +1250,13 @@ static int svc_tcp_sendmsg(struct socket *sock, struct xdr_buf *xdr, if (ret != head->iov_len) goto out; - if (xdr->page_len) { - unsigned int offset, len, remaining; - struct bio_vec *bvec; - - bvec = xdr->bvec + (xdr->page_base >> PAGE_SHIFT); - offset = offset_in_page(xdr->page_base); - remaining = xdr->page_len; - while (remaining > 0) { - len = min(remaining, bvec->bv_len - offset); - ret = kernel_sendpage(sock, bvec->bv_page, - bvec->bv_offset + offset, - len, 0); - if (ret < 0) - return ret; - *sentp += ret; - if (ret != len) - goto out; - remaining -= len; - offset = 0; - bvec++; - } - } + msg.msg_flags = MSG_SPLICE_PAGES; + iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, xdr->bvec, + xdr_buf_pagecount(xdr), xdr->page_len); + ret = sock_sendmsg(sock, &msg); + if (ret < 0) + return ret; + *sentp += ret; if (tail->iov_len) { ret = svc_tcp_send_kvec(sock, tail, 0); From patchwork Fri Jun 9 10:02:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13273619 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 D4726C7EE2E for ; Fri, 9 Jun 2023 10:02:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6ACD18E0009; Fri, 9 Jun 2023 06:02:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 65CA98E0001; Fri, 9 Jun 2023 06:02:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4FDB48E0009; Fri, 9 Jun 2023 06:02:46 -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 3FC308E0001 for ; Fri, 9 Jun 2023 06:02:46 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id EC777A019D for ; Fri, 9 Jun 2023 10:02:45 +0000 (UTC) X-FDA: 80882770290.30.57F27B1 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf14.hostedemail.com (Postfix) with ESMTP id 3478710001C for ; Fri, 9 Jun 2023 10:02:43 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=X8nfrF2j; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf14.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=1686304964; 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=Q9KEcNHQNL0heWM2/AbZS5PCqRXLyTBij/nK3rNCY6c=; b=nK81/ieCR/tG3IduCUbXBiQbTMdzW/ADGZ3hvfeJCSpeY/KdeAY747V8lHTrrGL4NZ+bOq j3uu2pAQpC4wDl09d/D57vkWrrwK5qnshdYmvVwsWel8dHidC/tyI/C6D/XgHKnxwQcXrJ nvuTjUmtQ92PJSF/ga2EWimZyDjI91Y= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=X8nfrF2j; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf14.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=1686304964; a=rsa-sha256; cv=none; b=vjLob7SznL6J1Nx+u7V8pu/bYtOSCLPTynb7T2ZsSLW+vTjXOgJ9QjsHiiHFCfrCeBDTla 6cr8bvFIbpGZ2eHwoyCSglqGzl6UF3jbTyrt0xHzca3jsbzbP7fmYN6/tRKUJHkjms6GkJ CWDFvVVr/+GVgToBNtLVHKWAx0L+qnA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686304963; 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=Q9KEcNHQNL0heWM2/AbZS5PCqRXLyTBij/nK3rNCY6c=; b=X8nfrF2jTCA86pDidBpJkLlIK4wsBnGDikffEPrNRJN0JfShM4nlJZ0XRZev4A5LeyEHTl 7UaMUoTzw4n3rj5RV3anjOkDqaPThrCI/DrdMGRJcyPhJdcOveo9n4Y/pdA2BEEEeEfqUd Uc2UURQgAzD6L1dTTOgL3IUJVj3wQgI= 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-274-aAfw7x-ZPUWuB_Kb0AVAug-1; Fri, 09 Jun 2023 06:02:39 -0400 X-MC-Unique: aAfw7x-ZPUWuB_Kb0AVAug-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 AB5E680120A; Fri, 9 Jun 2023 10:02:38 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id 582EB145B965; Fri, 9 Jun 2023 10:02:35 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , Jens Axboe , linux-mm@kvack.org, linux-kernel@vger.kernel.org, John Fastabend , Jakub Sitnicki , bpf@vger.kernel.org Subject: [PATCH net-next 4/6] tcp_bpf: Make tcp_bpf_sendpage() go through tcp_bpf_sendmsg(MSG_SPLICE_PAGES) Date: Fri, 9 Jun 2023 11:02:19 +0100 Message-ID: <20230609100221.2620633-5-dhowells@redhat.com> In-Reply-To: <20230609100221.2620633-1-dhowells@redhat.com> References: <20230609100221.2620633-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: 3478710001C X-Stat-Signature: 3oxertd1xrpy9ryt7ypbckoafptxf9we X-HE-Tag: 1686304963-619036 X-HE-Meta: U2FsdGVkX18JWbjLvdr7+O5Fhcy6m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wObtyEXH5Y5HC6McdPKTi6ZgUMCEg5oTFOVCQQ6SqzP+ZroRbLRYinDcD5FZfMasIc/NMzWLt7yH6jrcywSHr+smmgKSP6sto9slNjV7H8pjtZ75+CTsRfOsWmg4KBXgSid6BvJkul3g8kjYUWc1soVXqdtwm+JRRHdStc01NNt1Ie5c5PtCWShiOCA/BYSBxuXoJOHek/Pqf08Z1KeU1LLqWGqDVrHQ4oMhyzv+h/0djccS9RN0cHadvNuR5qPcKhMDSUnEBwHPuSdcuxnqp8P3SlgAxXtHEWsYSmWiHNoWRCcXE92S8f+50qZ7yB9SE3n0gEduK9AaMTn9wBaB5kIjXXt2pHd2u5ieulKNFdRhOpEge3q1DpvWwVmBsVqcXof+1m0vcDnot0OPZL2J64V/zox5/HmmDd655z65X/zGkVNCCymn5qklgZt/ 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: Make tcp_bpf_sendpage() a wrapper around tcp_bpf_sendmsg(MSG_SPLICE_PAGES) rather than a loop calling tcp_sendpage(). sendpage() will be removed in the future. Signed-off-by: David Howells cc: John Fastabend cc: Jakub Sitnicki cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: Jens Axboe cc: Matthew Wilcox cc: bpf@vger.kernel.org cc: netdev@vger.kernel.org --- net/ipv4/tcp_bpf.c | 49 +++++++++------------------------------------- 1 file changed, 9 insertions(+), 40 deletions(-) diff --git a/net/ipv4/tcp_bpf.c b/net/ipv4/tcp_bpf.c index e75023ea052f..5a84053ac62b 100644 --- a/net/ipv4/tcp_bpf.c +++ b/net/ipv4/tcp_bpf.c @@ -568,49 +568,18 @@ static int tcp_bpf_sendmsg(struct sock *sk, struct msghdr *msg, size_t size) static int tcp_bpf_sendpage(struct sock *sk, struct page *page, int offset, size_t size, int flags) { - struct sk_msg tmp, *msg = NULL; - int err = 0, copied = 0; - struct sk_psock *psock; - bool enospc = false; - - psock = sk_psock_get(sk); - if (unlikely(!psock)) - return tcp_sendpage(sk, page, offset, size, flags); + struct bio_vec bvec; + struct msghdr msg = { + .msg_flags = flags | MSG_SPLICE_PAGES, + }; - lock_sock(sk); - if (psock->cork) { - msg = psock->cork; - } else { - msg = &tmp; - sk_msg_init(msg); - } + bvec_set_page(&bvec, page, size, offset); + iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bvec, 1, size); - /* Catch case where ring is full and sendpage is stalled. */ - if (unlikely(sk_msg_full(msg))) - goto out_err; - - sk_msg_page_add(msg, page, size, offset); - sk_mem_charge(sk, size); - copied = size; - if (sk_msg_full(msg)) - enospc = true; - if (psock->cork_bytes) { - if (size > psock->cork_bytes) - psock->cork_bytes = 0; - else - psock->cork_bytes -= size; - if (psock->cork_bytes && !enospc) - goto out_err; - /* All cork bytes are accounted, rerun the prog. */ - psock->eval = __SK_NONE; - psock->cork_bytes = 0; - } + if (flags & MSG_SENDPAGE_NOTLAST) + msg.msg_flags |= MSG_MORE; - err = tcp_bpf_send_verdict(sk, psock, msg, &copied, flags); -out_err: - release_sock(sk); - sk_psock_put(sk, psock); - return copied ? copied : err; + return tcp_bpf_sendmsg(sk, &msg, size); } enum { From patchwork Fri Jun 9 10:02:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13273621 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 C9D41C7EE2E for ; Fri, 9 Jun 2023 10:03:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 639B28E000B; Fri, 9 Jun 2023 06:03:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5C25C8E0001; Fri, 9 Jun 2023 06:03:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4621B8E000B; Fri, 9 Jun 2023 06:03:01 -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 334B88E0001 for ; Fri, 9 Jun 2023 06:03:01 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id EF5E014017C for ; Fri, 9 Jun 2023 10:03:00 +0000 (UTC) X-FDA: 80882770920.10.263A813 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf23.hostedemail.com (Postfix) with ESMTP id 3E4C6140023 for ; Fri, 9 Jun 2023 10:02:58 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fhtorRS2; spf=pass (imf23.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=1686304979; 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=R74bPi2kwyePE/xmRN7KyjHRwIflZ6VoOr6lAl3jXjM=; b=g7STVGsu8+pw/t8KC82+M8aL5bWGRX8bmgAieeD7WurARc+DC1QrdX1kEpjxjVDWPEwwnU j+axm2lqnKmd7C3eitcWEI+yH2ItDhbJqbfClhrkJNNr3Yd9URE21U6mPRR2iHE4+fRRb7 FDAMKCw1mg/IsjtCwLThE9QCTO1dmTY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686304979; a=rsa-sha256; cv=none; b=0iZXIocBoO8Ws2Qa3syr32rPFC3alZ9KCeC9HaL551i3A6rKgBqOq61zOeQhC6uAcj6LS+ iVuegbMvSaeiZK9e40eiBg3UxmpeG7WTlVCaSHTC3WPCwBR7Q1TwQVl6Tfo3332y+AE0Kx uIJEvA/giouilRrKW2XFdx2sr3UlKRc= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fhtorRS2; spf=pass (imf23.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686304978; 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=R74bPi2kwyePE/xmRN7KyjHRwIflZ6VoOr6lAl3jXjM=; b=fhtorRS2UnBGgWaU67YcN3Fq4QhH6cyNqYrxDo59fz51UNg06xiNVyG7ZUXoFnerZAj19R 7ztCCuIHK0s4rRkH+K72Qr0D3UaglfgwdZi4dUtZdj/OrINru4IVURLqa8BMB2xEnkLVtB X8ozhmNqC5O94eVff+DIHc7IHyW6rQQ= 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-631-Y2G43H3wN2OR5zQ7GU9neg-1; Fri, 09 Jun 2023 06:02:42 -0400 X-MC-Unique: Y2G43H3wN2OR5zQ7GU9neg-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6545785A5BA; Fri, 9 Jun 2023 10:02:41 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8EEBF492B0A; Fri, 9 Jun 2023 10:02:39 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , Jens Axboe , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Tom Herbert , Tom Herbert Subject: [PATCH net-next 5/6] kcm: Use sendmsg(MSG_SPLICE_PAGES) rather then sendpage Date: Fri, 9 Jun 2023 11:02:20 +0100 Message-ID: <20230609100221.2620633-6-dhowells@redhat.com> In-Reply-To: <20230609100221.2620633-1-dhowells@redhat.com> References: <20230609100221.2620633-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Rspamd-Queue-Id: 3E4C6140023 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 6hiwh9ipnp6dea374c59ffjcfkmf7ynb X-HE-Tag: 1686304978-570449 X-HE-Meta: U2FsdGVkX18HaE+145coO7KggC+ywNzaw4zBIm+kOuOzrrSAqVoyog4qgVTjGIEeAZY6kIrvYGp5dxdkL/k2WXbXaeZAYd1Ih+kk7e3ZBED2xFkA7giFxeiFrxVop4w5glugAzxl+Mpp7zhtgMUp/5rR3R77nPOr3yaOJOs492XQrERDoJFR/hlztWRhDFY2p2Bc3d5kMCRyJNFmAnaQL2Xtm/drvVwer2QQz1y5TJFkXRGYcjG8xeKDM8nHgCo/6xXLfe3D/8BCIzArA+ZS/hap9s2szQEXyEiV4688m/hdrZrbnO2WfuWsxi6tD1/ZJ9sY44HAYSKNk9WnVgWulhYOGfj8CvusFUCUj/q015ASTxLBZQg/nmNKM6w7AJ7xTXKVl6/ncP2PQ2iSelOWr5YDNUBSNaawlvFoh3SF+2KuFDAXuxle6iaO3Z9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/pKy89uOYQK8TfN+4AiADSMPghxZ7GN9+Nn+t+NzRvBWwIw0cSb4MSQi9kOoedteq/B+Tia/DE74hsdhj7zZVmDMDw= 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 the transport socket using sendmsg with MSG_SPLICE_PAGES to indicate that content should be spliced rather than using sendpage. Signed-off-by: David Howells cc: Tom Herbert cc: Tom Herbert 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/kcm/kcmsock.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/net/kcm/kcmsock.c b/net/kcm/kcmsock.c index 7dee74430b59..3bcac1453f10 100644 --- a/net/kcm/kcmsock.c +++ b/net/kcm/kcmsock.c @@ -641,6 +641,10 @@ static int kcm_write_msgs(struct kcm_sock *kcm) for (fragidx = 0; fragidx < skb_shinfo(skb)->nr_frags; fragidx++) { + struct bio_vec bvec; + struct msghdr msg = { + .msg_flags = MSG_DONTWAIT | MSG_SPLICE_PAGES, + }; skb_frag_t *frag; frag_offset = 0; @@ -651,11 +655,13 @@ static int kcm_write_msgs(struct kcm_sock *kcm) goto out; } - ret = kernel_sendpage(psock->sk->sk_socket, - skb_frag_page(frag), - skb_frag_off(frag) + frag_offset, - skb_frag_size(frag) - frag_offset, - MSG_DONTWAIT); + bvec_set_page(&bvec, + skb_frag_page(frag), + skb_frag_size(frag) - frag_offset, + skb_frag_off(frag) + frag_offset); + iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bvec, 1, + bvec.bv_len); + ret = sock_sendmsg(psock->sk->sk_socket, &msg); if (ret <= 0) { if (ret == -EAGAIN) { /* Save state to try again when there's From patchwork Fri Jun 9 10:02:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13273620 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 933DAC7EE37 for ; Fri, 9 Jun 2023 10:02:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 130FC8E000A; Fri, 9 Jun 2023 06:02:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0DE9D8E0001; Fri, 9 Jun 2023 06:02:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E9AAA8E000A; Fri, 9 Jun 2023 06:02:50 -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 D94118E0001 for ; Fri, 9 Jun 2023 06:02:50 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id AB370C01BB for ; Fri, 9 Jun 2023 10:02:50 +0000 (UTC) X-FDA: 80882770500.21.AAA64EF Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf26.hostedemail.com (Postfix) with ESMTP id 4A56A14001A for ; Fri, 9 Jun 2023 10:02:47 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=S3bHhqFA; spf=pass (imf26.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=1686304967; 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=3LFa2xxbJsqyZ30qpsSqRMBPDTmtcps3tB0X7zJ4/t0=; b=eL01VyvuLvArmYY0HlKCeh93kP7omZBZXk/0R9MIwqcG97VFupgh/8QxYhxmmpt3RsG8tj ail08c2ZtdERev+jd+N0A5uZYbLOiS+xbFArRCn5iPMTQFUrI5DCVdHSW0qKUg3n6iSzT/ bfVtz15RIFJISI2HcJwX61rfKdsuurE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686304967; a=rsa-sha256; cv=none; b=uZBHfqmHu+YzpGa122LFVE0iY+t/idFUgjcP5QNSDBBNCp/lsf1j8KoppOZa/Go4IGwRHv 5n3xWry7nMkJDmRDNghAShW2ZCUnUt0C7hiSMvskGCjAxTtJEw2jKQFhwLuE+9lsGxhXmx M7yGznR8+gnTvp7FzI/8iOqRYZancq8= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=S3bHhqFA; spf=pass (imf26.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=1686304966; 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=3LFa2xxbJsqyZ30qpsSqRMBPDTmtcps3tB0X7zJ4/t0=; b=S3bHhqFAh+MbFZcWjQgpZeYknxxAGJEZUW6ArviscDoNFGwo3sanoDTJoWzPpFgsH2+lpY XXfs0OHnCcci6YuOIVdWSdtNPzn1k0YVCrlkjsnYd57mh562x3LXp0CcgIMyL5gQ1IHydm En9ix9K9Jz1vA+rSbQJQpNWbGj/+1LU= 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-104-0rQ0XTexPKWqfrAzgZR2CA-1; Fri, 09 Jun 2023 06:02:45 -0400 X-MC-Unique: 0rQ0XTexPKWqfrAzgZR2CA-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 7C0C485A5BE; Fri, 9 Jun 2023 10:02:44 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id 22EF3145B965; Fri, 9 Jun 2023 10:02:42 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , Jens Axboe , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Tom Herbert , Tom Herbert Subject: [PATCH net-next 6/6] kcm: Send multiple frags in one sendmsg() Date: Fri, 9 Jun 2023 11:02:21 +0100 Message-ID: <20230609100221.2620633-7-dhowells@redhat.com> In-Reply-To: <20230609100221.2620633-1-dhowells@redhat.com> References: <20230609100221.2620633-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Rspamd-Queue-Id: 4A56A14001A X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: or867xxgkk9746kcqg5ax1pui3gqbiug X-HE-Tag: 1686304967-552354 X-HE-Meta: U2FsdGVkX19oLikfyDjCaB2OOEop9bouaGF9aqNdVf8TZPRV11psbYgdKzWsfffx2IA1Ahe8es0XWSD3NU+ECP+y4rotYHA9QvELiyW3eA3gCFUgRGmQPY1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p6sEuxtwyCbHoo8SeeuTwywD6k6X3HuGo1GBNHl+TASPDvHgcZtmywQSxZPJNMJ2boD/0BPz39mQdyE65B6ZYApgCijK4EBgX8e3P2TBrIdQunS4KQBEahr5SrHjCsCatVkpO/tw1JOrgRZXcRT9A0HtJXHYvVRbFZ8Ca+a3IHlR3Xl/vGQhlSjFx8KkQlYiaFXvSy9uH3rJH4I/YLZ1H7KRUAAZTs63U/NbX+etLDerSjErxn6aJvLsTc8bLOEs7HpGdpSlcS0rQpvSsYT0n390B4LoSNHdL0vBaF5iX8d+6rgzdPz6OdVOJErR07qKTxRvs7b2tCOwxy7d7IgQE0IA== 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: Rewrite the AF_KCM transmission loop to send all the fragments in a single skb or frag_list-skb in one sendmsg() with MSG_SPLICE_PAGES set. The list of fragments in each skb is conveniently a bio_vec[] that can just be attached to a BVEC iter. Note: I'm working out the size of each fragment-skb by adding up bv_len for all the bio_vecs in skb->frags[] - but surely this information is recorded somewhere? For the skbs in head->frag_list, this is equal to skb->data_len, but not for the head. head->data_len includes all the tail frags too. Signed-off-by: David Howells cc: Tom Herbert cc: Tom Herbert cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: Jens Axboe cc: Matthew Wilcox cc: netdev@vger.kernel.org --- include/net/kcm.h | 2 +- net/kcm/kcmsock.c | 126 ++++++++++++++++++---------------------------- 2 files changed, 51 insertions(+), 77 deletions(-) diff --git a/include/net/kcm.h b/include/net/kcm.h index 2d704f8f4905..90279e5e09a5 100644 --- a/include/net/kcm.h +++ b/include/net/kcm.h @@ -47,9 +47,9 @@ struct kcm_stats { struct kcm_tx_msg { unsigned int sent; - unsigned int fragidx; unsigned int frag_offset; unsigned int msg_flags; + bool started_tx; struct sk_buff *frag_skb; struct sk_buff *last_skb; }; diff --git a/net/kcm/kcmsock.c b/net/kcm/kcmsock.c index 3bcac1453f10..d75d775e9462 100644 --- a/net/kcm/kcmsock.c +++ b/net/kcm/kcmsock.c @@ -581,12 +581,10 @@ static void kcm_report_tx_retry(struct kcm_sock *kcm) */ static int kcm_write_msgs(struct kcm_sock *kcm) { + unsigned int total_sent = 0; struct sock *sk = &kcm->sk; struct kcm_psock *psock; - struct sk_buff *skb, *head; - struct kcm_tx_msg *txm; - unsigned short fragidx, frag_offset; - unsigned int sent, total_sent = 0; + struct sk_buff *head; int ret = 0; kcm->tx_wait_more = false; @@ -600,78 +598,57 @@ static int kcm_write_msgs(struct kcm_sock *kcm) if (skb_queue_empty(&sk->sk_write_queue)) return 0; - kcm_tx_msg(skb_peek(&sk->sk_write_queue))->sent = 0; - - } else if (skb_queue_empty(&sk->sk_write_queue)) { - return 0; + kcm_tx_msg(skb_peek(&sk->sk_write_queue))->started_tx = false; } - head = skb_peek(&sk->sk_write_queue); - txm = kcm_tx_msg(head); - - if (txm->sent) { - /* Send of first skbuff in queue already in progress */ - if (WARN_ON(!psock)) { - ret = -EINVAL; - goto out; +retry: + while ((head = skb_peek(&sk->sk_write_queue))) { + struct msghdr msg = { + .msg_flags = MSG_DONTWAIT | MSG_SPLICE_PAGES, + }; + struct kcm_tx_msg *txm = kcm_tx_msg(head); + struct sk_buff *skb; + unsigned int msize; + int i; + + if (!txm->started_tx) { + psock = reserve_psock(kcm); + if (!psock) + goto out; + skb = head; + txm->frag_offset = 0; + txm->sent = 0; + txm->started_tx = true; + } else { + if (WARN_ON(!psock)) { + ret = -EINVAL; + goto out; + } + skb = txm->frag_skb; } - sent = txm->sent; - frag_offset = txm->frag_offset; - fragidx = txm->fragidx; - skb = txm->frag_skb; - - goto do_frag; - } - -try_again: - psock = reserve_psock(kcm); - if (!psock) - goto out; - - do { - skb = head; - txm = kcm_tx_msg(head); - sent = 0; -do_frag_list: if (WARN_ON(!skb_shinfo(skb)->nr_frags)) { ret = -EINVAL; goto out; } - for (fragidx = 0; fragidx < skb_shinfo(skb)->nr_frags; - fragidx++) { - struct bio_vec bvec; - struct msghdr msg = { - .msg_flags = MSG_DONTWAIT | MSG_SPLICE_PAGES, - }; - skb_frag_t *frag; - - frag_offset = 0; -do_frag: - frag = &skb_shinfo(skb)->frags[fragidx]; - if (WARN_ON(!skb_frag_size(frag))) { - ret = -EINVAL; - goto out; - } + msize = 0; + for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) + msize += skb_shinfo(skb)->frags[i].bv_len; + + iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, + skb_shinfo(skb)->frags, skb_shinfo(skb)->nr_frags, + msize); + iov_iter_advance(&msg.msg_iter, txm->frag_offset); - bvec_set_page(&bvec, - skb_frag_page(frag), - skb_frag_size(frag) - frag_offset, - skb_frag_off(frag) + frag_offset); - iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bvec, 1, - bvec.bv_len); + do { ret = sock_sendmsg(psock->sk->sk_socket, &msg); if (ret <= 0) { if (ret == -EAGAIN) { /* Save state to try again when there's * write space on the socket */ - txm->sent = sent; - txm->frag_offset = frag_offset; - txm->fragidx = fragidx; txm->frag_skb = skb; - ret = 0; goto out; } @@ -685,39 +662,36 @@ static int kcm_write_msgs(struct kcm_sock *kcm) true); unreserve_psock(kcm); - txm->sent = 0; + txm->started_tx = false; kcm_report_tx_retry(kcm); ret = 0; - - goto try_again; + goto retry; } - sent += ret; - frag_offset += ret; + txm->sent += ret; + txm->frag_offset += ret; KCM_STATS_ADD(psock->stats.tx_bytes, ret); - if (frag_offset < skb_frag_size(frag)) { - /* Not finished with this frag */ - goto do_frag; - } - } + } while (msg.msg_iter.count > 0); if (skb == head) { if (skb_has_frag_list(skb)) { - skb = skb_shinfo(skb)->frag_list; - goto do_frag_list; + txm->frag_skb = skb_shinfo(skb)->frag_list; + txm->frag_offset = 0; + continue; } } else if (skb->next) { - skb = skb->next; - goto do_frag_list; + txm->frag_skb = skb->next; + txm->frag_offset = 0; + continue; } /* Successfully sent the whole packet, account for it. */ + sk->sk_wmem_queued -= txm->sent; + total_sent += txm->sent; skb_dequeue(&sk->sk_write_queue); kfree_skb(head); - sk->sk_wmem_queued -= sent; - total_sent += sent; KCM_STATS_INCR(psock->stats.tx_msgs); - } while ((head = skb_peek(&sk->sk_write_queue))); + } out: if (!head) { /* Done with all queued messages. */