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 0372BC3B1BF for ; Mon, 17 Feb 2020 02:49:46 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B3DBF208C4 for ; Mon, 17 Feb 2020 02:49:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="BC8iPXbU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B3DBF208C4 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 51D476B0003; Sun, 16 Feb 2020 21:49:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 47D546B0005; Sun, 16 Feb 2020 21:49:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 346456B0007; Sun, 16 Feb 2020 21:49:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0062.hostedemail.com [216.40.44.62]) by kanga.kvack.org (Postfix) with ESMTP id 16A896B0003 for ; Sun, 16 Feb 2020 21:49:45 -0500 (EST) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id DEF578248068 for ; Mon, 17 Feb 2020 02:49:44 +0000 (UTC) X-FDA: 76498088688.17.cloth89_7222fd9687f02 X-HE-Tag: cloth89_7222fd9687f02 X-Filterd-Recvd-Size: 5609 Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by imf42.hostedemail.com (Postfix) with ESMTP for ; Mon, 17 Feb 2020 02:49:44 +0000 (UTC) Received: by mail-wr1-f68.google.com with SMTP id m16so17754995wrx.11 for ; Sun, 16 Feb 2020 18:49:44 -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=QbCKuQ3HWUk2tjBL4ms2S9fkU78qMXUWOgnMMNKtfqA=; b=BC8iPXbUVUjLotfxMGgI0rzf15pX7EZZZIpYktiRoItFNovqCq5y1XMx2ouZIh8zSU WcIhCsB9TSgsoRRTF7kE8iH5s9Lfibp9pfWche8yXhP8SGS6hevjysl4SlDT0Hx0wNO5 /A0/CTgM0/0/eRn3zfTroGwPglBnBfQqe3NuqCcHQlW5eL0ogyHw/5edc6bHamKk20d7 Q6Z2eV/pkdUmBrjXkfXjpaEIGPlWqfd94b91dK1GkF7FgZrowdjSKWhH+/nuyohKdcpZ MP5azqKnXM2BAa0F5/v8/tUbwngsYihHWRoGV+j+aQ+LLq2XW10pbxnGoIsu1kKsrlzi YSdw== 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=QbCKuQ3HWUk2tjBL4ms2S9fkU78qMXUWOgnMMNKtfqA=; b=hfuZaunmY3fpNu04E6Fr8Fuc887MrZWynlx/mWmLuOOfBl3NDAsEeSLm81AaZo/u2g 22yyjMWqz0nSxxGJB0JAwB6QNGpYYB8AStV74EFMZOKXkHq4tRBZ7nCGXpxp2LEeDmxf Uvu5H03cNpNOmLKrHush8cQWhpt9YoPFymsecTvQSOLInhForfDrm9HUadnnWiZSQ8L/ k4LlcJXYpJqagJA2EK1zRrRIhjWehiVWfoO4E1tXJUBWeQ76CspdjGIYA1biHnUw9Lzs 9z9fnsLfOZ4tuey0Vp3SuZL9RMq4P3QeWNHKa/AFIcABuhhOMpO9U+2B7v5IILz8LM8P 8j4Q== X-Gm-Message-State: APjAAAXLxGqSMJh6UJJhKTJa6Ek4NvespPwUCx00+bMPtmhujuWVwgJg hvTCVcstLxo1weNmEfatjnT/eHNOuvmy//kyd/QXeg== X-Google-Smtp-Source: APXvYqyb4CGujtE+7iOmYlkYkOUSWA+lEPcMiT5hg9For2xP7aoDRWM21l5+HQgr9UrviS1J0HU0+Qt3LFYTA2oWk5U= X-Received: by 2002:a5d:6545:: with SMTP id z5mr18489870wrv.3.1581907782489; Sun, 16 Feb 2020 18:49:42 -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: <20200212185605.d89c820903b7aa9fbbc060b2@linux-foundation.org> From: Arjun Roy Date: Sun, 16 Feb 2020 18:49:31 -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 , davem@davemloft.net, 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: On Wed, Feb 12, 2020 at 6:56 PM Andrew Morton w= rote: > > 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. > > > > 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. > > 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 > > 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 - add= ress); > > - 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