Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp632879rwe; Fri, 14 Apr 2023 07:48:55 -0700 (PDT) X-Google-Smtp-Source: AKy350a9ax5+Zz+mb1CVGk02i1QItgC4LpvMnZz3BnIhKf6T3tshUGOBrR5+ncG1Kx5+Y6slEozb X-Received: by 2002:a17:90a:cb8c:b0:233:f393:f6cd with SMTP id a12-20020a17090acb8c00b00233f393f6cdmr5800358pju.5.1681483735168; Fri, 14 Apr 2023 07:48:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681483735; cv=none; d=google.com; s=arc-20160816; b=oTzq52tyyLoo1hoqhWn/PRmqVzy58XJLcUXYeLJAWEEZG4BgZ4N6JRDli8GbUecPEs I8PNGAqGBu+RAyisnn+Y/vCLeJ9GApAVIfiKtHzTIQ7CZf74ehuMSm5m0FawT93/Xqn2 wE9QSp/HnKlvHcEg1Y4BFILAKmGWup1foyb5UDFQTxX8IHgPCXGETnLdxysUUldWzxk+ 5sPEuC51+p/YJKK3Ct3+AfDOpkWkN6ciM2sssC1Cr6vd/BjzDHjGxImCq0szRu6Gwq5F qRgGBr6cEE+jZOSVSrbjCld+EgdIkyIFpCnObjBgsvfnElYnSmeZVUd6HhAjlQhSfUXs 8mMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=MyWqJg+TEEMkoUyXIV4qRUXghOyIcc1b77Z/puaO8vo=; b=AwYOMktu7iJq63h+8W1pQspbwCvbGRGpKmO4oeCiqR2Tok9Qlh258iWrc8OmqAmgz+ yB5QaeW4eq5Z3hvKskdvGDUFcs2Mz+AB4G7kddW6rvmoITJZyIRyvLHoUWlONUCzpUk1 ziVffH19A59YGi2qdw8mm8edtXKd/x4LnAeYHXww1a2PgrZe58QODcNHrh7N2l+WXCwy a9yUg7QBckUO/UzWyoEgqFfA2aGO4V32JabKxCAf4id3vy5n0G1wWCZtbeuTWZRgh3Tz k76PnlfsupOCItuOjdOhVnd46UqCNqIEJ285yPlI0xQrvNOWSu/ATdfKJCN54z9v9jym nV2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dneg.com header.s=google header.b=gwacbKk8; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=dneg.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h2-20020a17090a470200b00246c56750c0si7011218pjg.184.2023.04.14.07.48.34; Fri, 14 Apr 2023 07:48:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-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=@dneg.com header.s=google header.b=gwacbKk8; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=dneg.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229933AbjDNOmn (ORCPT + 99 others); Fri, 14 Apr 2023 10:42:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229497AbjDNOmm (ORCPT ); Fri, 14 Apr 2023 10:42:42 -0400 Received: from mail-yw1-x1130.google.com (mail-yw1-x1130.google.com [IPv6:2607:f8b0:4864:20::1130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2AE9576AC for ; Fri, 14 Apr 2023 07:42:31 -0700 (PDT) Received: by mail-yw1-x1130.google.com with SMTP id 00721157ae682-54c12009c30so455476257b3.9 for ; Fri, 14 Apr 2023 07:42:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dneg.com; s=google; t=1681483350; x=1684075350; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=MyWqJg+TEEMkoUyXIV4qRUXghOyIcc1b77Z/puaO8vo=; b=gwacbKk8ZhAw/+4XWDKbLBigHaYvNUIUpTATkPqb5TsgWk47p0IlMhF4habn6ly3q+ EdOhisafu607FxcK5j2P0BL2S3WpgHAnunYhQ9TrdVySAU3dfKWPIdodlP5wIoBps+63 M5XRXeJyDChxoxs0c08zhUhL/pvQ1jSyM/zKVZuXaz0M0d+udQofR3M9RNbHfFfXM/38 QcgOmDq0hgYAomtXXd+kxVXsJ98oSqM8IJs7kZmovc1mw6nh6GF6Lw9H5eg1uxtSQCVq N1Qio8FeCOrT0UrnDo3JrjCNf/pgm9l7tSjCgTVG5sysEzOTNi4SJUGx4a9fL/bZ6aln Sp9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681483350; x=1684075350; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=MyWqJg+TEEMkoUyXIV4qRUXghOyIcc1b77Z/puaO8vo=; b=cKztoPDCTCivC8Tz0bQyFKexzYxSxIittNRB+BGeTQHUekBOXxOegergOxgUzOJTVZ uQE9b5ELp8sEeC7FGn9vPpKcjuuWekRnj7tY5ECNzcYK5bNKxi8L8STmlOGPX0tETt/r meD8Hsu+n12gyIUdxh6PaqbDSc2Fk7/OqQ+goQOCk0n6yKTw/o8WJxa5blvbujLY+zi2 iTKajNKEFS0lSmWWCRNOlOMxL8zHAgf+mf1j4zyiCCbgHfBMDSwPFJpqneEFTwiXMCHN bGuJWRYRwqFqd0FGTNPU7G7zZk+zjqnnN/Impc2hGCTEmLwPDkwmz6Qi25eYOfh50DaK foFQ== X-Gm-Message-State: AAQBX9eBlEtFJisRtaX/Ns3smvrxobIUIgY+iUL5rorKKOlcc8H8rL3V 1Q0pam8V3XWMyy+ruTc5h0xQ3zdUBdJVQQ73q3ld3w== X-Received: by 2002:a81:ae12:0:b0:545:8202:bbcf with SMTP id m18-20020a81ae12000000b005458202bbcfmr3804319ywh.9.1681483350245; Fri, 14 Apr 2023 07:42:30 -0700 (PDT) MIME-Version: 1.0 References: <3A132FA8-A764-416E-9753-08E368D6877A@oracle.com> <812034.1680181285@warthog.procyon.org.uk> <6F2985FF-2474-4F36-BD94-5F8E97E46AC2@oracle.com> <20230329141354.516864-1-dhowells@redhat.com> <20230329141354.516864-41-dhowells@redhat.com> <812755.1680182190@warthog.procyon.org.uk> <822317.1680186419@warthog.procyon.org.uk> In-Reply-To: From: Daire Byrne Date: Fri, 14 Apr 2023 15:41:53 +0100 Message-ID: Subject: Re: [RFC PATCH v2 40/48] sunrpc: Use sendmsg(MSG_SPLICE_PAGES) rather then sendpage To: Chuck Lever III Cc: David Howells , Matthew Wilcox , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Al Viro , Christoph Hellwig , Jens Axboe , Jeff Layton , Christian Brauner , Linus Torvalds , "open list:NETWORKING [GENERAL]" , linux-fsdevel , Linux Kernel Mailing List , Linux Memory Management List , Trond Myklebust , Anna Schumaker , Linux NFS Mailing List Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, 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-nfs@vger.kernel.org I gave this a spin because I had noticed a previous regression around the 5.7 time frame in sendpage/sendmsg code changes: https://bugzilla.kernel.org/show_bug.cgi?id=209439 In that case there was a noticeable regression in performance for high performance servers (100gbit). I see no such performance problems with David's iov-sendpage branch and it all looks good to me with simple benchmarks (100gbit server, 100 x 1gbit clients reading data). Tested-by: Daire Byrne Cheers, Daire On Thu, 30 Mar 2023 at 17:37, Chuck Lever III wrote: > > > > > On Mar 30, 2023, at 10:26 AM, David Howells wrote: > > > > Chuck Lever III wrote: > > > >> Don't. Just change svc_tcp_send_kvec() to use sock_sendmsg, and > >> leave the marker alone for now, please. > > > > If you insist. See attached. > > Very good, thank you for accommodating my regression paranoia. > > Acked-by: Chuck Lever > > > > > > David > > --- > > sunrpc: Use sendmsg(MSG_SPLICE_PAGES) rather then sendpage > > > > 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 > > cc: Trond Myklebust > > cc: Anna Schumaker > > cc: Chuck Lever > > 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 | 40 +++++++++++++--------------------------- > > 2 files changed, 18 insertions(+), 33 deletions(-) > > > > diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h > > index 877891536c2f..456ae554aa11 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 03a4f5615086..af146e053dfc 100644 > > --- a/net/sunrpc/svcsock.c > > +++ b/net/sunrpc/svcsock.c > > @@ -1059,17 +1059,18 @@ static int svc_tcp_recvfrom(struct svc_rqst *rqstp) > > svc_xprt_received(rqstp->rq_xprt); > > return 0; /* record not complete */ > > } > > - > > + > > 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. > > * > > @@ -1109,28 +1110,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); > > > > -- > Chuck Lever > >