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=-0.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 8EF8FC3B186 for ; Thu, 13 Feb 2020 02:56:08 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 306862168B for ; Thu, 13 Feb 2020 02:56:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="a7+1+jEh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 306862168B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9261B6B0500; Wed, 12 Feb 2020 21:56:07 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8D6C46B0501; Wed, 12 Feb 2020 21:56:07 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8135C6B0502; Wed, 12 Feb 2020 21:56:07 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0144.hostedemail.com [216.40.44.144]) by kanga.kvack.org (Postfix) with ESMTP id 673176B0500 for ; Wed, 12 Feb 2020 21:56:07 -0500 (EST) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 1ED3D4995F7 for ; Thu, 13 Feb 2020 02:56:07 +0000 (UTC) X-FDA: 76483589574.10.jeans78_527a929239b09 X-HE-Tag: jeans78_527a929239b09 X-Filterd-Recvd-Size: 3790 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf50.hostedemail.com (Postfix) with ESMTP for ; Thu, 13 Feb 2020 02:56:06 +0000 (UTC) Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7970621739; Thu, 13 Feb 2020 02:56:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581562565; bh=v1Cdow8c5mnT/NMDSQZkvFxjLExeUuklGL4gKnniKXs=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=a7+1+jEh8u1G/rdtaepjruSQQTwG5z1NHyOkLot8vD1WbNRqccP+XJhHxzYhtWFCR 1Xy9x1m1LyhaAJSTKS2NOMn71lcsgbJR+IovLNztH7t4BEYfQsK41VP5kT/7NLLT9b m490Lyxu3UsoUPYGilDHonx//E+lgK6OQI22INxs= Date: Wed, 12 Feb 2020 18:56:05 -0800 From: Andrew Morton To: Arjun Roy Cc: davem@davemloft.net, netdev@vger.kernel.org, linux-mm@kvack.org, arjunroy@google.com, Eric Dumazet , Soheil Hassas Yeganeh Subject: Re: [PATCH resend mm,net-next 3/3] net-zerocopy: Use vm_insert_pages() for tcp rcv zerocopy. Message-Id: <20200212185605.d89c820903b7aa9fbbc060b2@linux-foundation.org> In-Reply-To: <20200128025958.43490-3-arjunroy.kdev@gmail.com> References: <20200128025958.43490-1-arjunroy.kdev@gmail.com> <20200128025958.43490-3-arjunroy.kdev@gmail.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 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: On Mon, 27 Jan 2020 18:59:58 -0800 Arjun Roy wr= ote: > 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. >=20 > 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 u= sed 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. =20 This suppresses it: --- a/net/ipv4/tcp.c~net-zerocopy-use-vm_insert_pages-for-tcp-rcv-zerocop= y-fix +++ a/net/ipv4/tcp.c @@ -1788,6 +1788,8 @@ static int tcp_zerocopy_receive(struct s =20 sock_rps_record_flow(sk); =20 + tp =3D tcp_sk(sk); + down_read(¤t->mm->mmap_sem); =20 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 - address); =20 - 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?