From patchwork Tue Apr 11 16:08: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: 13207815 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 A95B2C76196 for ; Tue, 11 Apr 2023 16:09:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4691F900009; Tue, 11 Apr 2023 12:09:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3F153900002; Tue, 11 Apr 2023 12:09:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 291A1900009; Tue, 11 Apr 2023 12:09:45 -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 14652900002 for ; Tue, 11 Apr 2023 12:09:45 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id C880F80E7B for ; Tue, 11 Apr 2023 16:09:44 +0000 (UTC) X-FDA: 80669595888.18.09CB1C0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf29.hostedemail.com (Postfix) with ESMTP id 11A30120031 for ; Tue, 11 Apr 2023 16:09:42 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="F7I7K/Ph"; spf=pass (imf29.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=1681229383; 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=rjJlYTxOmtT7wdKdf7S5Ju9QN7AtCPTA0VxjqyvYpeA=; b=I7S+S/NaJB7lljsO76+fhZoYvs8mQiM51QSkaHGrC227YOuKQNKTY/P2lP1WYsARMp5wNr g3QwXeJE4jt83FY6bwgkLHoj4J7tKTjd3ITBqGkMNfuaFCZtilphsopdOPSKIB14VdzgeV K9FqQehYvtaMVe7g+4VwfmM9I0vzN+k= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="F7I7K/Ph"; spf=pass (imf29.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=1681229383; a=rsa-sha256; cv=none; b=pwH6dhfJLn1j2XPTrtr0C63gTcd9Xn7jCqK0qYum6agNg/CBoKOB1OkCojwYL/scUDZEz3 jKfe4o/1F2C6xq4zzCyjEV8Ml/2hbo5uET4Qr3SPqELCNopnkwv43NJwt2Wu3v6/AWi8BW qkUBo2O+xG8tqdyLDkQvVl2h6baq7Ts= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681229382; 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=rjJlYTxOmtT7wdKdf7S5Ju9QN7AtCPTA0VxjqyvYpeA=; b=F7I7K/PhBye+yTjJhV8A7UC83T7LrJKnBBSg/eJIwkw8GwP0DYiWxunOTP1zmqov/Vh0JH LQfT3qOQtkS0JbNI0Vpg/8W9NsbVd8B4EbEQQENuEizCbQWuUH9lzGH4slAFqGawChxcyY MHm74AL1mY1Y7Zy1TLRicDj5C7ZEXH0= 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-548-cmT0nmxaN_-wKHRfTU4xrw-1; Tue, 11 Apr 2023 12:09:39 -0400 X-MC-Unique: cmT0nmxaN_-wKHRfTU4xrw-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 ABF7538149AF; Tue, 11 Apr 2023 16:09:37 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 47A44C15BBA; Tue, 11 Apr 2023 16:09:35 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , Al Viro , Christoph Hellwig , Jens Axboe , Jeff Layton , Christian Brauner , Chuck Lever III , Linus Torvalds , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, John Fastabend , Jakub Sitnicki , bpf@vger.kernel.org Subject: [PATCH net-next v6 09/18] tcp_bpf: Inline do_tcp_sendpages as it's now a wrapper around tcp_sendmsg Date: Tue, 11 Apr 2023 17:08:53 +0100 Message-Id: <20230411160902.4134381-10-dhowells@redhat.com> In-Reply-To: <20230411160902.4134381-1-dhowells@redhat.com> References: <20230411160902.4134381-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: cwbrg6kr15bkp9te6yi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D21e8ZILKB1z1GN2d0ZmcfzAzJX7xAh1mBWMHTTcozM1p36vwANLrjWogOQDFPj8mDlV33voqw/bRKzqj1IzuJ0LjVj/LhnTjDN/trdSwXHZ4Z0PdvU/SwGK4+55OJ4dt276z/NsMpWsRzjt8aXthNptRgdwj2eOYzLxrhEU+0TN5YyXWeJlKTKQWzWGxKaGO+AGT0eGQXiM2NPVnU46pt3GcGrUFBH8ND2exd71ijEU1sE9ieWDol13ZifSRbJDmvDGuxYvFv1R8uBeC1B+XUQ3adLDaNjnDmNCp8my4eXrl94masISfbk3+fp5AM+atTzFzCsKpgslCsFZ02DUwXhtGGQPl3ZYYbzuybbTcXsgsSGVDXF1kU+Zgj89R3NG4MWhSR2z6mgvlFmrjXDa0cBekKLyRDtWpz8mJ+vs1JguWgguQrcuWZEyAAM7bzOhEAHoMSTBSxYYrDJMK4sCL/6PODzFk2QxjJLxufYZ4OUyFUP1fJHwre/p5ZJZQDP+q4HiCA/qYwV7A1bWWMyB2YR90dc3RPLApQ== 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: do_tcp_sendpages() is now just a small wrapper around tcp_sendmsg_locked(), so inline it. This is part of replacing ->sendpage() with a call to sendmsg() with MSG_SPLICE_PAGES set. Signed-off-by: David Howells cc: John Fastabend cc: Jakub Sitnicki cc: "David S. Miller" cc: Eric Dumazet cc: David Ahern cc: Jakub Kicinski cc: Paolo Abeni cc: Jens Axboe cc: Matthew Wilcox cc: netdev@vger.kernel.org cc: bpf@vger.kernel.org --- net/ipv4/tcp_bpf.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/net/ipv4/tcp_bpf.c b/net/ipv4/tcp_bpf.c index ebf917511937..24bfb885777e 100644 --- a/net/ipv4/tcp_bpf.c +++ b/net/ipv4/tcp_bpf.c @@ -72,11 +72,13 @@ 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 page *page; int size, ret = 0; u32 off; while (1) { + struct bio_vec bvec; bool has_tx_ulp; sge = sk_msg_elem(msg, msg->sg.start); @@ -88,16 +90,18 @@ static int tcp_bpf_push(struct sock *sk, struct sk_msg *msg, u32 apply_bytes, tcp_rate_check_app_limited(sk); retry: has_tx_ulp = tls_sw_has_ctx_tx(sk); - if (has_tx_ulp) { - flags |= MSG_SENDPAGE_NOPOLICY; - ret = kernel_sendpage_locked(sk, - page, off, size, flags); - } else { - ret = do_tcp_sendpages(sk, page, off, size, flags); - } + 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); if (ret <= 0) return ret; + if (apply) apply_bytes -= ret; msg->sg.size -= ret; @@ -404,7 +408,7 @@ static int tcp_bpf_sendmsg(struct sock *sk, struct msghdr *msg, size_t size) long timeo; int flags; - /* Don't let internal do_tcp_sendpages() flags through */ + /* Don't let internal sendpage flags through */ flags = (msg->msg_flags & ~MSG_SENDPAGE_DECRYPTED); flags |= MSG_NO_SHARED_FRAGS;