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=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,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 7C869C433E0 for ; Thu, 18 Mar 2021 03:21:28 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id AA91664EFD for ; Thu, 18 Mar 2021 03:21:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AA91664EFD 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 1D5256B0071; Wed, 17 Mar 2021 23:21:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 185446B0072; Wed, 17 Mar 2021 23:21:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 04E1D6B0073; Wed, 17 Mar 2021 23:21:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0065.hostedemail.com [216.40.44.65]) by kanga.kvack.org (Postfix) with ESMTP id DE3206B0071 for ; Wed, 17 Mar 2021 23:21:26 -0400 (EDT) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 8FEA518001C0C for ; Thu, 18 Mar 2021 03:21:26 +0000 (UTC) X-FDA: 77931544530.08.3A66C89 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf02.hostedemail.com (Postfix) with ESMTP id 01425407F8E8 for ; Thu, 18 Mar 2021 03:21:25 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 1463364EFC; Thu, 18 Mar 2021 03:21:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1616037684; bh=QOtXK6Ec9/3i2FBcUrutU4vPFPJXNzko8Hou0zo6b0g=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=RUXwEgkZOfdEA9KgB1z8gfEFWzOZZilJmfuz4cG+74p7eXjqFu2d/kYgp8eEmI2jp Lh9SoXDyVjcLcKn+PGnwvxJxOLxJ6CFiljMM1uTs9Wfc3ppS1ano9o3d5Y8+A1f9I9 mrsICt7zVT+9c4NHN9bxa2zgvPS9KMDJNdmLRfjI= Date: Wed, 17 Mar 2021 20:21:23 -0700 From: Andrew Morton To: Arjun Roy Cc: davem@davemloft.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org, arjunroy@google.com, shakeelb@google.com, edumazet@google.com, soheil@google.com, kuba@kernel.org, mhocko@kernel.org, hannes@cmpxchg.org, shy828301@gmail.com, guro@fb.com Subject: Re: [mm, net-next v2] mm: net: memcg accounting for TCP rx zerocopy Message-Id: <20210317202123.7d2eaa0e54c36c20571a335c@linux-foundation.org> In-Reply-To: <20210316013003.25271-1-arjunroy.kdev@gmail.com> References: <20210316013003.25271-1-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=US-ASCII Content-Transfer-Encoding: 7bit X-Stat-Signature: stban45uwgxds34o7cydyhia48oaaqph X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 01425407F8E8 Received-SPF: none (linux-foundation.org>: No applicable sender policy available) receiver=imf02; identity=mailfrom; envelope-from=""; helo=mail.kernel.org; client-ip=198.145.29.99 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1616037685-257834 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, 15 Mar 2021 18:30:03 -0700 Arjun Roy wrote: > From: Arjun Roy > > TCP zerocopy receive is used by high performance network applications > to further scale. For RX zerocopy, the memory containing the network > data filled by the network driver is directly mapped into the address > space of high performance applications. To keep the TLB cost low, > these applications unmap the network memory in big batches. So, this > memory can remain mapped for long time. This can cause a memory > isolation issue as this memory becomes unaccounted after getting > mapped into the application address space. This patch adds the memcg > accounting for such memory. > > Accounting the network memory comes with its own unique challenges. > The high performance NIC drivers use page pooling to reuse the pages > to eliminate/reduce expensive setup steps like IOMMU. These drivers > keep an extra reference on the pages and thus we can not depend on the > page reference for the uncharging. The page in the pool may keep a > memcg pinned for arbitrary long time or may get used by other memcg. > > This patch decouples the uncharging of the page from the refcnt and > associates it with the map count i.e. the page gets uncharged when the > last address space unmaps it. Now the question is, what if the driver > drops its reference while the page is still mapped? That is fine as > the address space also holds a reference to the page i.e. the > reference count can not drop to zero before the map count. What tree were you hoping to get this merged through? I'd suggest net - it's more likely to get tested over there. > > ... > > --- a/mm/memcontrol.c > +++ b/mm/memcontrol.c These changes could be inside #ifdef CONFIG_NET. Although I expect MEMCG=y&&NET=n is pretty damn rare.