Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp207347pxf; Wed, 17 Mar 2021 20:23:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZ9BmvVJNqYHCZb3yHrjsyhqQE3dZQKDNT1dD1/3zda9gkN6zn/mvSEMVsOQ/eop1PiA2G X-Received: by 2002:a17:906:3e89:: with SMTP id a9mr21770853ejj.405.1616037791923; Wed, 17 Mar 2021 20:23:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616037791; cv=none; d=google.com; s=arc-20160816; b=nVxwGkuxScBtDxr7dP6nJnIpQCdkEaUdSiWB7rTngx2uUBLG9Pxiv0bgawOHuxpgtm 39AYr5UBUfO40M7ds6qSh8lynrzAA73AH25XSJfyFCvAN28o7j901s+mmvFVVOQgDANm ieAaxJfE61/h9I6OHTXUrjJBDe2MHNaSzX3/FAOWeX7yA3CT5n05mdi9JmjUQH3VMvuu 1kaRSCiQOO6Eu0sbmIeKO2rb7QZ2to9lKnK+tMscQtw8E8ZQhtQ+emxBI294RjyTOG6S OBHMesyTsJp1bkaskbE2mz0LM8ELDfegSS6tQOCkUwlcXmESdtLJkoxgS24VjSoVcCYD KqkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=edcWGgIJ3mdnQYXsXg9wcs3/yCdoK/lJjgNOUl9Szds=; b=mOPz4b5fk4WtG7SElgsTBQqsceSEXIeG9fm96ci6XT2Y55KAcpAUp3oCAvP7cUJE0t tDgyFW2pKYXTCcGLv/T7gb6kK6ALcjY801twBJk4k3APFLlF7e9GIWcb8IVvtAzjr/Qj 59JS/yast9rjEKyjzLpegP24LxCjtGDIp+sjUYLhTDp3xHVPglthIzS3g75MPmc/LlrR It3uHh5UwxFjILlDzypEC76CiXfoWYKBnj+75gX0u3wYEPlZHvgDsYqA+sXak3GtO1oX hZ1LW7Yw6my0gMaEvo8efh0/YrXnXOima45kj/ucV4rNGA05CN4+tmy6AnhehOiMsVQ+ 2E4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=RUXwEgkZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dd3si561603edb.360.2021.03.17.20.22.49; Wed, 17 Mar 2021 20:23:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=RUXwEgkZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230493AbhCRDVd (ORCPT + 99 others); Wed, 17 Mar 2021 23:21:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:50744 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229702AbhCRDVZ (ORCPT ); Wed, 17 Mar 2021 23:21:25 -0400 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.