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=-11.3 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SIGNED_OFF_BY,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 DC7E9C433DF for ; Fri, 19 Jun 2020 01:32:02 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9A8E3207FC for ; Fri, 19 Jun 2020 01:32:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="bF/KL5lL" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9A8E3207FC 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 425E18D006D; Thu, 18 Jun 2020 21:32:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3FCDD8D0052; Thu, 18 Jun 2020 21:32:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3121C8D006D; Thu, 18 Jun 2020 21:32:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0119.hostedemail.com [216.40.44.119]) by kanga.kvack.org (Postfix) with ESMTP id 1A1288D0052 for ; Thu, 18 Jun 2020 21:32:02 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 9C9F0180AD806 for ; Fri, 19 Jun 2020 01:32:01 +0000 (UTC) X-FDA: 76944235242.19.touch46_2c137dc26e15 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin19.hostedemail.com (Postfix) with ESMTP id 6DC831AD1B9 for ; Fri, 19 Jun 2020 01:32:01 +0000 (UTC) X-HE-Tag: touch46_2c137dc26e15 X-Filterd-Recvd-Size: 5182 Received: from mail-lf1-f67.google.com (mail-lf1-f67.google.com [209.85.167.67]) by imf46.hostedemail.com (Postfix) with ESMTP for ; Fri, 19 Jun 2020 01:32:00 +0000 (UTC) Received: by mail-lf1-f67.google.com with SMTP id t74so4622913lff.2 for ; Thu, 18 Jun 2020 18:32:00 -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=YRNqswcDD+7gU99eajO2uAdW0qLUELxTADFfqedXHc0=; b=bF/KL5lLdnHf/s7iJT80JuKJRDQcYtt7xPZ9sx9O49I5AiG4oJtqkhIvIg0WmhFY0N In50ikw30tfIpXqwcFiuSCyiz3Mw545oRB0022NjuqwLUdjP1p3V0oItWtblZeiRcrrQ H3/P6XaaZ+A3QFfkraICyjmqmyuw58xqWBYkLII4VuWyZjtKSHPoOCEwXWL+tVHNBcgQ uCj0bmxEUA6On/3hivi1s4q78VSM1624m4GzEAHWvW7MNBBAot5QpKSs+i8q1GNvaO2H YIpP7YEPPrdx4foQw2LDBqbE9VEufglIpAlA8AJhtmwrfu8sSNpiJC5H7L6yMC2X0jiN hdLw== 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=YRNqswcDD+7gU99eajO2uAdW0qLUELxTADFfqedXHc0=; b=Pc1Z+NjS5vDmqm8JXqQUH2rwFrHqLwwEt1azW7I5mSRZu/OL7mUzettOmOR3kefbxj M6WOFaraUh00C6l1Onvu1y10ugszns3oARZ+R+kQA66ngzBrU1TDH9T2AfcmYvMKRc9M FBXLLO21+yQo1IZNbyLU8nTyKAxgQHpw3D73P6FtA5qeSa/k2MnyDfECN+2N//NEDpla P2qZeukWYO4R5gKyfOwVPgVt2ZxMkG2m4NRhuENHhHm6BcOOZST0lC6sYVISOvUgcDRk f+yJek+Fl8Gc8xZwON6V0R+dCiN9JY444L0Jy/1SsXZYp/OGRWjBT9ShD5mjeDR5SNHx 5gMg== X-Gm-Message-State: AOAM530hOszugNYI/1SLbU+rqQCwGvVTm6tZ+VvKSXRMbVfvTo4p3EyK BxZEo+ZjrVfQHKYHafndx0hskJ2fekaXAWN0d7GQcbkQ X-Google-Smtp-Source: ABdhPJxd/k2n5PiFiQPd1NPow/mTdHCH7OcWv89FNWviXu1HPDOyEDJxtsQwjndapO916JRvoqeTPjYiI80AV8vrpIs= X-Received: by 2002:a05:6512:482:: with SMTP id v2mr532247lfq.3.1592530319205; Thu, 18 Jun 2020 18:31:59 -0700 (PDT) MIME-Version: 1.0 References: <20200608230654.828134-1-guro@fb.com> <20200608230654.828134-6-guro@fb.com> In-Reply-To: <20200608230654.828134-6-guro@fb.com> From: Shakeel Butt Date: Thu, 18 Jun 2020 18:31:48 -0700 Message-ID: Subject: Re: [PATCH v6 05/19] mm: memcontrol: decouple reference counting from page accounting To: Roman Gushchin Cc: Andrew Morton , Christoph Lameter , Johannes Weiner , Michal Hocko , Linux MM , Vlastimil Babka , Kernel Team , LKML Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 6DC831AD1B9 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 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, Jun 8, 2020 at 4:07 PM Roman Gushchin wrote: > > From: Johannes Weiner > > The reference counting of a memcg is currently coupled directly to how > many 4k pages are charged to it. This doesn't work well with Roman's > new slab controller, which maintains pools of objects and doesn't want > to keep an extra balance sheet for the pages backing those objects. > > This unusual refcounting design (reference counts usually track > pointers to an object) is only for historical reasons: memcg used to > not take any css references and simply stalled offlining until all > charges had been reparented and the page counters had dropped to > zero. When we got rid of the reparenting requirement, the simple > mechanical translation was to take a reference for every charge. > > More historical context can be found in commit e8ea14cc6ead ("mm: > memcontrol: take a css reference for each charged page"), > commit 64f219938941 ("mm: memcontrol: remove obsolete kmemcg pinning > tricks") and commit b2052564e66d ("mm: memcontrol: continue cache > reclaim from offlined groups"). > > The new slab controller exposes the limitations in this scheme, so > let's switch it to a more idiomatic reference counting model based on > actual kernel pointers to the memcg: > > - The per-cpu stock holds a reference to the memcg its caching > > - User pages hold a reference for their page->mem_cgroup. Transparent > huge pages will no longer acquire tail references in advance, we'll > get them if needed during the split. > > - Kernel pages hold a reference for their page->mem_cgroup > > - Pages allocated in the root cgroup will acquire and release css > references for simplicity. css_get() and css_put() optimize that. > > - The current memcg_charge_slab() already hacked around the per-charge > references; this change gets rid of that as well. > > Roman: > 1) Rebased on top of the current mm tree: added css_get() in > mem_cgroup_charge(), dropped mem_cgroup_try_charge() part > 2) I've reformatted commit references in the commit log to make > checkpatch.pl happy. > > Signed-off-by: Johannes Weiner > Signed-off-by: Roman Gushchin > Acked-by: Roman Gushchin Reviewed-by: Shakeel Butt