From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.4 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2D2FC35666 for ; Fri, 21 Feb 2020 21:21:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 74383207FD for ; Fri, 21 Feb 2020 21:21:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="NL6MH+w3" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 74383207FD Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 1C3F66B0003; Fri, 21 Feb 2020 16:21:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1750B6B0006; Fri, 21 Feb 2020 16:21:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 08D0F6B0007; Fri, 21 Feb 2020 16:21:56 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0020.hostedemail.com [216.40.44.20]) by kanga.kvack.org (Postfix) with ESMTP id E3E3D6B0003 for ; Fri, 21 Feb 2020 16:21:55 -0500 (EST) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 7F27D180AD811 for ; Fri, 21 Feb 2020 21:21:55 +0000 (UTC) X-FDA: 76515406590.09.sort94_10b4551d5bf52 X-HE-Tag: sort94_10b4551d5bf52 X-Filterd-Recvd-Size: 6654 Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by imf35.hostedemail.com (Postfix) with ESMTP for ; Fri, 21 Feb 2020 21:21:54 +0000 (UTC) Received: by mail-wm1-f66.google.com with SMTP id z12so4689wmi.4 for ; Fri, 21 Feb 2020 13:21:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=kCojeGCbYv0/Jqi1Rd5ewidQhYyqj8mEtyF/C7SM9lk=; b=NL6MH+w3h66AF/fbLXBfLwROsxIucUAMI15KKfXzR/bjcLk7MjH1WsJyyFwj9hfSWz 8/pSnkfVszwgvNdnucLGdGEDJLnEn5UdkBURH4nmqLbce/DZXXTgbKe8dm5aNnhJop+O ZKOtZCN2M97yV42SA365i5rERAKLHaQmOwtziZa3kPbZ4fdMINpcuRt3hZ6gYR0V6uOd 032oVnIO6dQAabLiFwxYRWxbsWU5NCwy/QDSXOAh1s6hlqcVu4uyWtJFSxbDL1ZTEt4x 1ftLdmMPBJecGa9ShdGOa/MzIeW76Mbyq4lywFEjIcZW0Zt+cvm3OIQBwSARJSKZcn9n Rbtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=kCojeGCbYv0/Jqi1Rd5ewidQhYyqj8mEtyF/C7SM9lk=; b=RqEYzAFZTkZYRu5YcLN3ra9/UzbeDpZmDCNV0148KrOr0CO/red2qQhDa+mf3zq9q1 5BwQVtu1kFwi/QYC45VWAiRcdZ5H2/PjLCz220fTH555rDY7s1icUqXuXe1s2xeJ5QqW MoC4os9LVjhNtyBgYTzbAbCWMnB6J20l1178Uko0mqQ7VpbEUFU2piSBxvk2jjpYYQtI GdQM5tJSd+du+golIamkD1cDnfTaVQArlFPFh90pDTbI3llU8VKSCPHM4rm4oklON+DV 8SZug2bfzANxCxbJVsaTA0aCYiQNvNaqVUJbU1wS79lxVjGWL+fJ+Y+9ZeQDT0hrCgPS 8zRg== X-Gm-Message-State: APjAAAWdlvD6lQuNeCQAusS3hUWsXHBvMhT45WDmnQDFEE50OjDPE5Wb yoUpK7h+1BL0OnpTDt87l6k0fnv1IE0HNEXBCSgdDQ== X-Google-Smtp-Source: APXvYqxE/EEAuIfMxsuKqyKNpPlbuOrTCH3lN/BG7Y9t6z5GtbVJvPvIoOpIDYg1Q+XjoPAigvlw+UbYmrxJh1kctJQ= X-Received: by 2002:a1c:541b:: with SMTP id i27mr6113814wmb.137.1582320113195; Fri, 21 Feb 2020 13:21:53 -0800 (PST) MIME-Version: 1.0 References: <20200128025958.43490-1-arjunroy.kdev@gmail.com> <20200128025958.43490-3-arjunroy.kdev@gmail.com> <20200212185605.d89c820903b7aa9fbbc060b2@linux-foundation.org> In-Reply-To: From: Arjun Roy Date: Fri, 21 Feb 2020 13:21:41 -0800 Message-ID: Subject: Re: [PATCH resend mm,net-next 3/3] net-zerocopy: Use vm_insert_pages() for tcp rcv zerocopy. To: Andrew Morton Cc: Arjun Roy , David Miller , netdev@vger.kernel.org, linux-mm@kvack.org, Eric Dumazet , Soheil Hassas Yeganeh Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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: Andrew, David - I remain a bit concerned regarding the merge process for this specific patch (0003, the net/ipv4/tcp.c change) since I have other in-flight changes for TCP receive zerocopy that I'd like to upstream for net-next - and would like to avoid weird merge issues. So perhaps the following could work: 1. Andrew, perhaps we could remove this particular patch (0003, the net/ipv4/tcp.c change) from mm-next; that way we merge vm_insert_pages() but not the call-site within TCP, for now. 2. net-next will eventually pick vm_insert_pages() up. 3. I can modify the zerocopy code to use it at that point? Else I'm concerned a complicated merge situation may result. What do you all think? Thanks, -Arjun On Sun, Feb 16, 2020 at 6:49 PM Arjun Roy wrote: > > On Wed, Feb 12, 2020 at 6:56 PM Andrew Morton = wrote: > > > > On Mon, 27 Jan 2020 18:59:58 -0800 Arjun Roy = wrote: > > > > > Use vm_insert_pages() for tcp receive zerocopy. Spin lock cycles > > > (as reported by perf) drop from a couple of percentage points > > > to a fraction of a percent. This results in a roughly 6% increase in > > > efficiency, measured roughly as zerocopy receive count divided by CPU > > > utilization. > > > > > > The intention of this patch-set is to reduce atomic ops for > > > tcp zerocopy receives, which normally hits the same spinlock multiple > > > times consecutively. > > > > For some reason the patch causes this: > > > > In file included from ./arch/x86/include/asm/atomic.h:5:0, > > from ./include/linux/atomic.h:7, > > from ./include/linux/crypto.h:15, > > from ./include/crypto/hash.h:11, > > from net/ipv4/tcp.c:246: > > net/ipv4/tcp.c: In function =E2=80=98do_tcp_getsockopt.isra.29=E2=80=99= : > > ./include/linux/compiler.h:225:31: warning: =E2=80=98tp=E2=80=99 may be= used uninitialized in this function [-Wmaybe-uninitialized] > > case 4: *(volatile __u32 *)p =3D *(__u32 *)res; break; > > ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~ > > net/ipv4/tcp.c:1779:19: note: =E2=80=98tp=E2=80=99 was declared here > > struct tcp_sock *tp; > > ^~ > > > > It's a false positive. gcc-7.2.0 > > > > : out: > > : up_read(¤t->mm->mmap_sem); > > : if (length) { > > : WRITE_ONCE(tp->copied_seq, seq); > > > > but `length' is zero here. > > > > This suppresses it: > > > > --- a/net/ipv4/tcp.c~net-zerocopy-use-vm_insert_pages-for-tcp-rcv-zeroc= opy-fix > > +++ a/net/ipv4/tcp.c > > @@ -1788,6 +1788,8 @@ static int tcp_zerocopy_receive(struct s > > > > sock_rps_record_flow(sk); > > > > + tp =3D tcp_sk(sk); > > + > > down_read(¤t->mm->mmap_sem); > > > > ret =3D -EINVAL; > > @@ -1796,7 +1798,6 @@ static int tcp_zerocopy_receive(struct s > > goto out; > > zc->length =3D min_t(unsigned long, zc->length, vma->vm_end - a= ddress); > > > > - tp =3D tcp_sk(sk); > > seq =3D tp->copied_seq; > > inq =3D tcp_inq(sk); > > zc->length =3D min_t(u32, zc->length, inq); > > > > and I guess it's zero-cost. > > > > > > Anyway, I'll sit on this lot for a while, hoping for a davem ack? > > Actually, speaking of the ack on the networking side: > > I guess this patch set is a bit weird since it requires some > non-trivial coordination between mm and net-next? Not sure what the > normal approach is in this case. > > -Arjun