Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1072437rwd; Wed, 7 Jun 2023 10:33:03 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5Pml6OtL00GfAXHFluaTCvi9gFavVKs2vz3lhEIBmpr4883L4wlqfmwGK+S5E+jWWI5OFI X-Received: by 2002:a05:6a20:a20d:b0:115:dfb:da59 with SMTP id u13-20020a056a20a20d00b001150dfbda59mr1324473pzk.3.1686159183429; Wed, 07 Jun 2023 10:33:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686159183; cv=none; d=google.com; s=arc-20160816; b=NFkVTuZ036EGMDAiy06Y2w4kS1W0eEZ3BBJoCCUUvnsI63U1ui/aPADv5TttYF2O65 aDOpkZz2vlobiptmcXJEygGSRZLW77ySqYM5G6OhMBTMZQoYrFmF4zRhyWQdwvXSWihY Zm8NGaq9i3KOJJTvdz41IDPZ9V5zswM9umiHE1Q48DocClhAMrymxtgIn5DHBKajbOZ5 umwje58bSDwAMsSb3mZ5Ah6BE0CK92lWga+TWHCi5on89qw4NCN3nxGPt1ESsvA7h8l1 cELRhjOl6PCX/8OBCH5a1O7WA+4dF0zXNzX49F8cF5D0+w1l/4i31c28kNtFuIzgwsbp 8nGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=KLQxkecXHCX3ycVxsqXRnFiPWz7biyJZj7MSngZtPow=; b=aGhC2Jv8beP6aEB5wOxZW5JfZCGFfo9kl8b1Fv70yAHXQEHpTfkj7Pw4vzz1BT5K10 r0cW6tPAxu+Mj13U00cYuXdMULmy9j4sJ8Ie9Wm39srW6QFw0eAgh/KKXXvDWpH4MKTP kZEZG5N8MGhiS0xF6p9WG+iG5r7Av0b6k1fTF4V4Ovr2D/4ZIYjs/YL8rTQk6e0g+FE5 3Ya4MJAdo9IxjrBbXRgbhlrxRBOCKSOiZTranZI08FXGmlE5NQ5cvd1wor9cbvxziBQf cmvpE3i37e19CJtFyKJkhIC/XmXa05IVwYJRcVgcSLoxtnYrFYJbFld6sxXtXyB+SnVO ixww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kQpZB91n; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g6-20020aa79f06000000b0065cb0204893si4705394pfr.308.2023.06.07.10.32.51; Wed, 07 Jun 2023 10:33:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kQpZB91n; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231540AbjFGRUG (ORCPT + 99 others); Wed, 7 Jun 2023 13:20:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231346AbjFGRTu (ORCPT ); Wed, 7 Jun 2023 13:19:50 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A14291FD5 for ; Wed, 7 Jun 2023 10:19:48 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 18CDF641D4 for ; Wed, 7 Jun 2023 17:19:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CCBBBC433D2; Wed, 7 Jun 2023 17:19:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686158387; bh=sM9s5rM2STlzlaVPLAL0I0uiZASg+eSmYmdRpfR8XhA=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=kQpZB91nZiuTOirqxWJgBPdqf25i2CyhejL+gKom8fvSGnOZB68iLEp89ML4qSTP3 hgwvsrMX1Jp0GbQxXzphYLAOQ2fxK+zcFoMMpkH7y24R0H6rKfb32NpUzBk75yYtra 6VinNPwHhS5cBbHrTF3ghHOKNqlhYUPKbmEKReGrIVcs77JYGON8x1Dela4expLhLB E6LCB7JcQzcTsW4VEMfKmUBiMyE/Hr4bAutkwbRfaJY4HZN8asyExxWnKGpKPNwBQa 0D5dJ3z2PHDmZcCZ0ENLuquMg3jkHsxe6+k+/RpFWNvu3E8wAdx8FhPvDIhCZOdEwC glFM3AnwMbSrA== Date: Wed, 7 Jun 2023 10:19:45 -0700 From: Jakub Kicinski To: David Howells Cc: netdev@vger.kernel.org, Linus Torvalds , Chuck Lever , Boris Pismenny , John Fastabend , "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: Re: [PATCH net-next v5 11/14] tls/sw: Support MSG_SPLICE_PAGES Message-ID: <20230607101945.65c5df51@kernel.org> In-Reply-To: <20230607140559.2263470-12-dhowells@redhat.com> References: <20230607140559.2263470-1-dhowells@redhat.com> <20230607140559.2263470-12-dhowells@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 7 Jun 2023 15:05:56 +0100 David Howells wrote: > +static int tls_sw_sendmsg_splice(struct sock *sk, struct msghdr *msg, > + struct sk_msg *msg_pl, size_t try_to_copy, > + ssize_t *copied) > +{ > + struct page *page = NULL, **pages = &page; > + > + do { > + ssize_t part; > + size_t off; > + bool put = false; > + > + part = iov_iter_extract_pages(&msg->msg_iter, &pages, > + try_to_copy, 1, 0, &off); > + if (part <= 0) > + return part ?: -EIO; > + > + if (WARN_ON_ONCE(!sendpage_ok(page))) { > + iov_iter_revert(&msg->msg_iter, part); > + return -EIO; > + } > + > + sk_msg_page_add(msg_pl, page, part, off); > + sk_mem_charge(sk, part); > + if (put) > + put_page(page); is put ever set to true? > + *copied += part; > + try_to_copy -= part; > + } while (try_to_copy && !sk_msg_full(msg_pl)); > + > + return 0; > +} > + > int tls_sw_sendmsg(struct sock *sk, struct msghdr *msg, size_t size) > { > long timeo = sock_sndtimeo(sk, msg->msg_flags & MSG_DONTWAIT); > @@ -1020,6 +1052,17 @@ int tls_sw_sendmsg(struct sock *sk, struct msghdr *msg, size_t size) > full_record = true; > } > > + if (try_to_copy && (msg->msg_flags & MSG_SPLICE_PAGES)) { > + ret = tls_sw_sendmsg_splice(sk, msg, msg_pl, > + try_to_copy, &copied); > + if (ret < 0) > + goto send_end; > + tls_ctx->pending_open_record_frags = true; > + if (full_record || eor || sk_msg_full(msg_pl)) > + goto copied; > + continue; > + } > + > if (!is_kvec && (full_record || eor) && !async_capable) { > u32 first = msg_pl->sg.end; > > @@ -1082,8 +1125,9 @@ int tls_sw_sendmsg(struct sock *sk, struct msghdr *msg, size_t size) > /* Open records defined only if successfully copied, otherwise > * we would trim the sg but not reset the open record frags. > */ > - tls_ctx->pending_open_record_frags = true; > copied += try_to_copy; > +copied: > + tls_ctx->pending_open_record_frags = true; Why move pending-open-record-frags setting if it's also set before jumping? > if (full_record || eor) { > ret = bpf_exec_tx_verdict(msg_pl, sk, full_record, > record_type, &copied,