Message ID | 20230329141354.516864-26-dhowells@redhat.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 6D921C6FD18 for <linux-mm@archiver.kernel.org>; Wed, 29 Mar 2023 14:15:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EC0176B0080; Wed, 29 Mar 2023 10:15:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E497D6B009F; Wed, 29 Mar 2023 10:15:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C4DCB6B00A0; Wed, 29 Mar 2023 10:15:15 -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 B29616B0080 for <linux-mm@kvack.org>; Wed, 29 Mar 2023 10:15:15 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 9012C1C6197 for <linux-mm@kvack.org>; Wed, 29 Mar 2023 14:15:15 +0000 (UTC) X-FDA: 80622132990.18.F1291A2 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf27.hostedemail.com (Postfix) with ESMTP id 853F04001C for <linux-mm@kvack.org>; Wed, 29 Mar 2023 14:15:13 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=EOIXLoHs; spf=pass (imf27.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=1680099313; 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=mERLnHIZ7Ufhp5QAaSwmDcCxGjZ2CWUtcWDMeYUTupY=; b=dOAe97sZlRFm+McTrTfqARF7DPdzbE/Sm9J8dOJlY/L0KS4sOQywXd6TVsoMDG4W6EXKvN ciXAnIJ0/7V6u+Jwi+866ZJWtJovVhxi1ye8CAowc8FovH8Qp7/7vFq/uEDujzT3Wd4W41 QY3IHbJ3YCH0eTYTd8kQqhuIXxsHwVQ= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=EOIXLoHs; spf=pass (imf27.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=1680099313; a=rsa-sha256; cv=none; b=SPGt0sH71FR8S3HBtP7Wlr4SQ6R77nR0NT5r9P3KwySRDtj7m+56Ksfs246X++5onv8smk w1xyhT31W0RXt2sSIYyaWSnPwn6lGc18bVbGjCc9RXYBMDyk6n1U9yq98KqKm7+pPAahA9 UlFJrbvjO8za/BSynuNct1saWWb3SwM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680099312; 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=mERLnHIZ7Ufhp5QAaSwmDcCxGjZ2CWUtcWDMeYUTupY=; b=EOIXLoHspO8cxkJf0cT9nDBiYNB1tdqEe2xLsnf7leZsX79PAQY8T4PEl9hNhU7DClmB1h i2m44o7iUP7c7qsvd2fCJQfxqqF/CZkyf+LLOWb9S0RdOAXWr0hg9b7PU6MM/L/mmQxcb9 Q9O6knMaAe+6BhFAX3QWyofz5yDvDio= 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-590-z9dsdsf9NKCR0l94rUYaTw-1; Wed, 29 Mar 2023 10:15:08 -0400 X-MC-Unique: z9dsdsf9NKCR0l94rUYaTw-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 98FAE885625; Wed, 29 Mar 2023 14:15:07 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 85B182027040; Wed, 29 Mar 2023 14:15:05 +0000 (UTC) From: David Howells <dhowells@redhat.com> To: Matthew Wilcox <willy@infradead.org>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com> Cc: David Howells <dhowells@redhat.com>, Al Viro <viro@zeniv.linux.org.uk>, Christoph Hellwig <hch@infradead.org>, Jens Axboe <axboe@kernel.dk>, Jeff Layton <jlayton@kernel.org>, Christian Brauner <brauner@kernel.org>, Chuck Lever III <chuck.lever@oracle.com>, Linus Torvalds <torvalds@linux-foundation.org>, netdev@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Herbert Xu <herbert@gondor.apana.org.au>, linux-crypto@vger.kernel.org Subject: [RFC PATCH v2 25/48] crypto: af_alg: Convert af_alg_sendpage() to use MSG_SPLICE_PAGES Date: Wed, 29 Mar 2023 15:13:31 +0100 Message-Id: <20230329141354.516864-26-dhowells@redhat.com> In-Reply-To: <20230329141354.516864-1-dhowells@redhat.com> References: <20230329141354.516864-1-dhowells@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Stat-Signature: 757fewszbrr413mjypnnsg3wdoumibek X-Rspam-User: X-Rspamd-Queue-Id: 853F04001C X-Rspamd-Server: rspam06 X-HE-Tag: 1680099313-131729 X-HE-Meta: U2FsdGVkX19K82PIy7CXc2lfbidngC8ZF779Df8bYcNaUC58LwJxFdO5w/9y0aFjDf/piE2Y9ANeKGuBfw86UJw3l7cVNLYPysV/konrq9ckQQQ8Q4RQtFFUCUxeEwdU8aLwKf7CeQeW9zjqKm8Dk54A0EGYWiZicMQ7rDeyRpkeEC3+QvzYlHs/f91A3sA4PGyOj2O3bzrO0WMEvNzXvZF82QvsGnQlF2XHs/fXrWrrMyGA3xn9NDtukHSTCvCU4FR6bV1usJ9BNR++P2TPHltxJd89H7AvznGLFJHf5sJDDnsQUj/hePRb4m3Xz/NXbAI2aazaoUM9+dBp0u5LSmv4uynGknhL1wdUNPwrxphFTk1DbalyyIEN2LJUAOoRLfU04gJzTfnaT0bdu3jRuspS2GPz18kMPy5gcp3jmV7usn/OXJXvFXPnc2hppEHn4Tnjn6rIyPTFZmB8MpoCifv2ik3VheSlgGgyZbuBoTCNdk5snM3YcDcGKIjAE+EH2CepkuH1oN9cMcwxErgbM4wYjYkh8Zgenpy7iW0yR+8hoI811ekdXTLNNN5ob6Ws1lR5iSmiYDTqiLEKpQ2XRlTEp0aPOTXvIMg1lJjiL3XgUZvxSzbsOwvB1hvsHGC8zaUZgYFXHUTEv28LRfyxRUrYubaYt3RDZj9DTuODRcGEz3X+XAl9Iv6hJnHHRdsGoG/azBPIryWJqLI+zsM9Dcoaxey++TmGo+z8rqPVRueS0XnfhMYbUpW8u0auGcrERj5ErKwB6OqSlUXNvZ3nYx7taebrDQphyGd/IkG9V0bXaou9AKwyuDCudj2A/AirGH6JQEW4BhmZoGTgcvfPmpZ4cI90wGZzMA/MqVyXYczA0j89daOAGhtb2dx/JNi4e5e6USy/yit79NV9oAvxyu7KfCKV27Pq0EZAHD5v0ouJT6Br50k3H36XxpGsQIgLdCCDnKoD0+S9JsWO2/n rcUFrqKM kO+3xBbozfmnFQyzIiSDiraXUqmPpbKUOf316dCd8LYZMMtKlHk3QJmw+hevw62lrdWJZV+As+TT8dVwkntQVX4reaVF8uVXiL2WDxzY1p67jpDhC86kxRu5Lw8HBeKg1mTVWDPdvUrVq5fvqSg8EBm8bhsDbYIujhzDXlyzuWDHJoJxtXt8hoCx/NtAJm0QxrRzWjeBTj05ukOLM3QtUp6LFzbUuPlbqvbBY1JjTHW3OghqtHcg70SasuYFzmRh49wqbPVgTVV4a+VlmZAwJ7JNKacOfQ4QiHleEfR4sug876PW7EmA23SJPEtU3EzSWjxCsoelbxUZK5BNYJDlEWWDxQt9FsuRIxOHXCjzrtbUWaPUEsDMbmlCej49jYJZIidA3v8lNlaWcnKT20ouEHry9VsgzoyQdwWMWVEYIHTKVkURqFjelfNr5x9aE3gLQ6aCM2hSrUUgC823W1d/oP2536+HHzAmYrmjmWH4LFUkYrEteBAHzXBMLLw== 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: <linux-mm.kvack.org> |
Series |
splice, net: Replace sendpage with sendmsg(MSG_SPLICE_PAGES)
|
expand
|
diff --git a/crypto/af_alg.c b/crypto/af_alg.c index 3088ab298632..7fe8c8db6bb5 100644 --- a/crypto/af_alg.c +++ b/crypto/af_alg.c @@ -1118,53 +1118,18 @@ EXPORT_SYMBOL_GPL(af_alg_sendmsg); ssize_t af_alg_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 af_alg_ctx *ctx = ask->private; - struct af_alg_tsgl *sgl; - int err = -EINVAL; - - if (flags & MSG_SENDPAGE_NOTLAST) - flags |= MSG_MORE; - - lock_sock(sk); - if (!ctx->more && ctx->used) - goto unlock; - - if (!size) - goto done; - - if (!af_alg_writable(sk)) { - err = af_alg_wait_for_wmem(sk, flags); - if (err) - goto unlock; - } - - err = af_alg_alloc_tsgl(sk); - if (err) - goto unlock; - - ctx->merge = 0; - sgl = list_entry(ctx->tsgl_list.prev, struct af_alg_tsgl, list); - - if (sgl->cur) - sg_unmark_end(sgl->sg + sgl->cur - 1); + struct bio_vec bvec; + struct msghdr msg = { + .msg_flags = flags | MSG_SPLICE_PAGES, + }; - sg_mark_end(sgl->sg + sgl->cur); + bvec_set_page(&bvec, page, size, offset); + iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bvec, 1, size); - get_page(page); - sg_set_page(sgl->sg + sgl->cur, page, size, offset); - sgl->cur++; - ctx->used += size; - -done: - ctx->more = flags & MSG_MORE; - -unlock: - af_alg_data_wakeup(sk); - release_sock(sk); + if (flags & MSG_SENDPAGE_NOTLAST) + msg.msg_flags |= MSG_MORE; - return err ?: size; + return sock_sendmsg(sock, &msg); } EXPORT_SYMBOL_GPL(af_alg_sendpage);
Convert af_alg_sendpage() to use sendmsg() with MSG_SPLICE_PAGES rather than directly splicing in the pages itself. This allows ->sendpage() to be replaced by something that can handle multiple multipage folios in a single transaction. [!] Note that this makes use of netfs_extract_iter_to_sg() from netfslib. This probably needs moving to core code somewhere. Signed-off-by: David Howells <dhowells@redhat.com> cc: Herbert Xu <herbert@gondor.apana.org.au> cc: "David S. Miller" <davem@davemloft.net> cc: Eric Dumazet <edumazet@google.com> cc: Jakub Kicinski <kuba@kernel.org> cc: Paolo Abeni <pabeni@redhat.com> cc: Jens Axboe <axboe@kernel.dk> cc: Matthew Wilcox <willy@infradead.org> cc: linux-crypto@vger.kernel.org cc: netdev@vger.kernel.org --- crypto/af_alg.c | 53 +++++++++---------------------------------------- 1 file changed, 9 insertions(+), 44 deletions(-)