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.6 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,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 B2ED9C433E0 for ; Wed, 24 Jun 2020 01:25:32 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 70D472098B for ; Wed, 24 Jun 2020 01:25:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="JXNAQn0J" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 70D472098B 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 B9CE26B0002; Tue, 23 Jun 2020 21:25:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B4D8B6B0003; Tue, 23 Jun 2020 21:25:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A62FD6B0005; Tue, 23 Jun 2020 21:25:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0117.hostedemail.com [216.40.44.117]) by kanga.kvack.org (Postfix) with ESMTP id 905196B0002 for ; Tue, 23 Jun 2020 21:25:31 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 231B3180AD83A for ; Wed, 24 Jun 2020 01:25:31 +0000 (UTC) X-FDA: 76962362862.23.mark52_1317d6926e40 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin23.hostedemail.com (Postfix) with ESMTP id EE05537608 for ; Wed, 24 Jun 2020 01:25:30 +0000 (UTC) X-HE-Tag: mark52_1317d6926e40 X-Filterd-Recvd-Size: 4527 Received: from mail-lj1-f195.google.com (mail-lj1-f195.google.com [209.85.208.195]) by imf30.hostedemail.com (Postfix) with ESMTP for ; Wed, 24 Jun 2020 01:25:30 +0000 (UTC) Received: by mail-lj1-f195.google.com with SMTP id e4so719479ljn.4 for ; Tue, 23 Jun 2020 18:25:30 -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=9ym1pbvhecpjgkqBUHdG2jngAamnO8ZMTgtaxvGC8kU=; b=JXNAQn0JgEi7NOj8FqP/q4K0S7NkS/7ef+DDatTkE/hHyxYAHbsVnDE9mzYrDs+hkX 9mShn9ffdkCCu8/U3QYDZ+AkPv/hOUT7dkhFN+JNrX65Y3wgHYGxm9j3jfBnnzUviybW Qbd44IEqMk4ZbczoGYdgIRY7AKtpbZwFEwNBsU5KGhdAPtEEq4JpdZvun7UaUALWah7K dviUIzGiwghBvkwszBPYodKzZwZ2MVz4LtcTxn82VoX6li+iuQ8nzjiwuVW8U1Ki+jRG BUZxhJQdzxCHoJW1sCDSuKGmOxKI0EJiEUeCJZRjk4mDCR4iC5G34i8WC//S/aIqzdde y1FQ== 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=9ym1pbvhecpjgkqBUHdG2jngAamnO8ZMTgtaxvGC8kU=; b=LufH3bYIGK9SOIGad5OpI2T3X6oi15LnjaBpAIqlN/A3wlfi/8CV2vTMy7QrLibrkD qhdesCOIJAmGi3WumkT8+itF6xgTMsItF+b0y4aABG+GiZ49VxH8RxXURNA8TAnR+DhD SxgOpimm687KxrNcjb2hElsULO1Gmlv+bGoL6P5aePpwAqIOOQjGU3Az8BW6R+1yam6V /mFKlQnWm+kiXk91qrgG3TM4EToo98uX2XKxCroE/kajBo1aH+hrBppKfC3+2yZA/2bt Tf6FJam3HklTg0Pw+RxTyDkKervy8r8HtnvjYPLvN+usuHhwXceCFPEZJMyJO+9NntXi l+VQ== X-Gm-Message-State: AOAM533cY0KHU4mjQoTQpLFoM+TQSxSRaXqG6UERqP8wHICKUdNTrLrh 7vEXkYuvF8sBDML1FljAwAzayNmQl4DEkrwCJw9UsA== X-Google-Smtp-Source: ABdhPJyiAww+T1xHD4MOi+PiWUrYgooq+GRv77kONhLFxcRkhWS52y+8FVIf38NqpOBPsQVKcRktXBbVVST6VNDh0MM= X-Received: by 2002:a2e:960b:: with SMTP id v11mr12741935ljh.77.1592961928783; Tue, 23 Jun 2020 18:25:28 -0700 (PDT) MIME-Version: 1.0 References: <20200623184515.4132564-1-guro@fb.com> <20200623184515.4132564-3-guro@fb.com> In-Reply-To: <20200623184515.4132564-3-guro@fb.com> From: Shakeel Butt Date: Tue, 23 Jun 2020 18:25:17 -0700 Message-ID: Subject: Re: [PATCH v3 2/5] mm: memcg/percpu: account percpu memory to memory cgroups To: Roman Gushchin Cc: Andrew Morton , Dennis Zhou , Tejun Heo , Christoph Lameter , Johannes Weiner , Michal Hocko , Linux MM , Kernel Team , LKML Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: EE05537608 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 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 Tue, Jun 23, 2020 at 11:47 AM Roman Gushchin wrote: > > Percpu memory is becoming more and more widely used by various subsystems, > and the total amount of memory controlled by the percpu allocator can make > a good part of the total memory. > > As an example, bpf maps can consume a lot of percpu memory, and they are > created by a user. Also, some cgroup internals (e.g. memory controller > statistics) can be quite large. On a machine with many CPUs and big > number of cgroups they can consume hundreds of megabytes. > > So the lack of memcg accounting is creating a breach in the memory > isolation. Similar to the slab memory, percpu memory should be accounted > by default. > > To implement the perpcu accounting it's possible to take the slab memory > accounting as a model to follow. Let's introduce two types of percpu > chunks: root and memcg. What makes memcg chunks different is an > additional space allocated to store memcg membership information. If > __GFP_ACCOUNT is passed on allocation, a memcg chunk should be be used. > If it's possible to charge the corresponding size to the target memory > cgroup, allocation is performed, and the memcg ownership data is recorded. > System-wide allocations are performed using root chunks, so there is no > additional memory overhead. > > To implement a fast reparenting of percpu memory on memcg removal, we > don't store mem_cgroup pointers directly: instead we use obj_cgroup API, > introduced for slab accounting. > > Signed-off-by: Roman Gushchin > Acked-by: Dennis Zhou Reviewed-by: Shakeel Butt