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=-13.3 required=3.0 tests=BAYES_00,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 7F5FAC433DB for ; Mon, 22 Mar 2021 21:19:28 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E30BC61984 for ; Mon, 22 Mar 2021 21:19:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E30BC61984 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 5A72C6B010A; Mon, 22 Mar 2021 17:19:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 52F936B010C; Mon, 22 Mar 2021 17:19:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3822E6B0114; Mon, 22 Mar 2021 17:19:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0209.hostedemail.com [216.40.44.209]) by kanga.kvack.org (Postfix) with ESMTP id 18B1B6B010A for ; Mon, 22 Mar 2021 17:19:27 -0400 (EDT) Received: from smtpin36.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id CD0C3180295A9 for ; Mon, 22 Mar 2021 21:19:26 +0000 (UTC) X-FDA: 77948776332.36.DF0AE0A Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) by imf22.hostedemail.com (Postfix) with ESMTP id 890AAC001C57 for ; Mon, 22 Mar 2021 21:19:21 +0000 (UTC) Received: by mail-pj1-f54.google.com with SMTP id w8so9134693pjf.4 for ; Mon, 22 Mar 2021 14:19:21 -0700 (PDT) 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; bh=gyGz6jIAyesHb03GrLq2sQ8gNXK0GEF8U0hfkl4YQos=; b=WFU7Cd+KSjhmC3zYLefyH/pznYkILEn4gUYD7fgJdX15GrVZXGIjvctmLzMcUMehix DBe1X1g3cy/+Fh385KsKSImJA5ngvSqHLfHMA2T/6M2Vzm0ArF8tP3xMXk2oKzX9jfCl /eFW9cpATHI9XDuToVZyvmbnwaxiZJE2ZKS6JAw1kodd+wtBYwgc1/INQS7ISYzJ2lrA Dtyq6CFbKILtk389p0xzfizKYo9bBAoYISMoZZmM22cKcI3MpJgHYdEhXvpscEVor9kl cdao8Wx9Ba+End5w8sZotV3yefDZwsz6ZyKzGmtgPONmz3bCJRLPfX9axapxptljnzDF ogTQ== 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; bh=gyGz6jIAyesHb03GrLq2sQ8gNXK0GEF8U0hfkl4YQos=; b=njF1c3/JnLrnwJUx0jVo5H+72/dhj1qaiIF1cGU+oI2VMLv2nVEOp3zIAJwkcedFIs fAO/JDDd6dInN56yZyl9iP80V4aUJAM8+4udDTvmssAOPm6Qn+5IEJwKJoLVWy6vO7tz vXnpj634cHJIVYFXNRaJ6qd+qbwMN36vJQEBCwylOxbX6L9UmbMjRoVfqU1JlHTS2AQW 9kBzPuN4twe6x58jbN7OZWNaF5j61RNAUQXXqqHygmz69w9mR649Trayhij0D34Cw2Ol QB2f9QTUrUg7K1sxAtlGNx605jBb97lfy7m/3Rkr0gBT6Wn96YSABtYizRT8wTkBQudS c6ig== X-Gm-Message-State: AOAM532fCnQmoBVDK5H37Ajdzv1SDa5y/aw+o4qaF0B/AkdGhQuBawPZ XYXKjM28OP57NJyQbsSALUIoL3nAne3Jt0CbFHa8dw== X-Google-Smtp-Source: ABdhPJztKcI5ep4UOORSfmYloXc4k3wIwkZdGAoDP8c4OKeJLhR4kr4msS8/HHYTGyPLpTJrBkJ0OlQj6jZMRzb/OAY= X-Received: by 2002:a17:90a:9d82:: with SMTP id k2mr1017479pjp.48.1616447959140; Mon, 22 Mar 2021 14:19:19 -0700 (PDT) MIME-Version: 1.0 References: <20210316013003.25271-1-arjunroy.kdev@gmail.com> <20210317202123.7d2eaa0e54c36c20571a335c@linux-foundation.org> In-Reply-To: <20210317202123.7d2eaa0e54c36c20571a335c@linux-foundation.org> From: Arjun Roy Date: Mon, 22 Mar 2021 14:19:08 -0700 Message-ID: Subject: Re: [mm, net-next v2] mm: net: memcg accounting for TCP rx zerocopy To: Andrew Morton Cc: Arjun Roy , David Miller , netdev , Linux Kernel Mailing List , Cgroups , Linux MM , Shakeel Butt , Eric Dumazet , Soheil Hassas Yeganeh , Jakub Kicinski , Michal Hocko , Johannes Weiner , Yang Shi , Roman Gushchin Content-Type: text/plain; charset="UTF-8" X-Stat-Signature: nqcf6hz6xmwk7p5p3ewudijhrna8kj64 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 890AAC001C57 Received-SPF: none (google.com>: No applicable sender policy available) receiver=imf22; identity=mailfrom; envelope-from=""; helo=mail-pj1-f54.google.com; client-ip=209.85.216.54 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1616447961-170803 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, Mar 17, 2021 at 8:21 PM Andrew Morton wrote: > > 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. > That was one part I wasn't quite sure about - the v3 patchset makes things less clear even, since while v1/v2 are mostly mm heavy v3 would have some significant changes in both subsystems. I'm open to whichever is the "right" way to go, but am not currently certain which would be. Thanks, -Arjun > > > > ... > > > > --- 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. >