Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp157337iog; Sun, 12 Jun 2022 22:39:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwCvXxT1/d/mHWeacnqb/XhrQ+2MvV0mciu0G6Db1ECgwwhtqVXfaC073ZfdM0U5oqLajif X-Received: by 2002:a62:f846:0:b0:51c:17b2:60de with SMTP id c6-20020a62f846000000b0051c17b260demr40383667pfm.76.1655098781721; Sun, 12 Jun 2022 22:39:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655098781; cv=none; d=google.com; s=arc-20160816; b=vH6FascFqj/pcizm3niAdbgq0K+AoTjkhmq/6lBqvigSMjtS97Jgpsljd8kfypT975 mWg5Eq+AcK9iTQV0sxxC23q3b13x6k4nn6XGl+ANzn4X7vKeHoe09TmwOOk1h/p8WKNB QURhz8kRaiQdpFEF49KtnHR1QmJc6ktbbVaqTUxewPu9hP9H6gjjRacGAI/oyFNMuyOU uNC0OMvL89Ru9PXHMV0eUPR7XW1bXa6xNARw6HCoAaOhL2jl1JzDOtLG5GC3zUNdW5iM I7QtsTYm8birHmzgtQrht3MPuz5PD5goaJHOoHH8tKTFTERDeUXhRO4WHdz07IIxkmqI PLGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :content-language:references:cc:to:subject:from:user-agent :mime-version:date:message-id:dkim-signature; bh=B3zm8wtF1vA2GYm2+mdF7egB2sMmmpE2kcaPBaO2eto=; b=kSFQ+vyjpJy4295319eFzVzQdIhQYGnhxcCCABA88xY0N3yVPDVHGvTQfhTfc80Fne jISpa7aJcsV9VtWlhSywAX9g6YHUab42eNJmuRF1Fv9mu+rUAyEP2AN1yUA982+kZUaS hkahW5Gsyyc0ijdoJkLeFQkreAQsUi2FG3odS8ERtYunmks63wu6bzQZaJgXc/kNdwsg oloVkkXB+SsnLU4zeJn0AxwJKs3cnTjd/yneb7RW3ye6unqoR5k7bjWEHzxIUkvdHaNW nyEPSepoLN83b2lTi0vVRuVyRFNcY32u2d/kTV1rJkURJU3YiARbvu5/7YK69/Knh/6w LL1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@openvz-org.20210112.gappssmtp.com header.s=20210112 header.b=aNTN9ecS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=openvz.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d16-20020a170902ced000b00168aa4e0428si9013577plg.155.2022.06.12.22.39.28; Sun, 12 Jun 2022 22:39:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@openvz-org.20210112.gappssmtp.com header.s=20210112 header.b=aNTN9ecS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=openvz.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231854AbiFMFg1 (ORCPT + 99 others); Mon, 13 Jun 2022 01:36:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229799AbiFMFf4 (ORCPT ); Mon, 13 Jun 2022 01:35:56 -0400 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C36F811151 for ; Sun, 12 Jun 2022 22:35:19 -0700 (PDT) Received: by mail-lf1-x12c.google.com with SMTP id a29so7142137lfk.2 for ; Sun, 12 Jun 2022 22:35:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz-org.20210112.gappssmtp.com; s=20210112; h=message-id:date:mime-version:user-agent:from:subject:to:cc :references:content-language:in-reply-to:content-transfer-encoding; bh=B3zm8wtF1vA2GYm2+mdF7egB2sMmmpE2kcaPBaO2eto=; b=aNTN9ecStVPQ2d3BHO8r2ERVbHTttzP8TpBGu400gwgeTcHpH5cOc8cGKcJF5B4VSG Pl404daaNaSR+XfYhnMPIJuJDZNnXll9sSKc8Bl7DpIBinOElRj9Cdogfo8nhbIPgz6H LEhnRv6PLI/1q4OQhQVbZHRXsvpYNjKANwS6bgzq+oxPSUzB7Oijv5PyZP6r2dUx8G0b 5/U0JAHLUzb4KnI6Ev9AKyFvBj77iQEV+KqIkwQ1NbPYXEy0SxOYw8Yaln47mLwPQ3Ko TdBRQtjCGU4GK/9EIclgy8Gop96FJszFi5oVXiUUTrnqwe52akMXbhog8arLPS0+Gyux fXRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:from :subject:to:cc:references:content-language:in-reply-to :content-transfer-encoding; bh=B3zm8wtF1vA2GYm2+mdF7egB2sMmmpE2kcaPBaO2eto=; b=4lWfaxcQMmE/r5zgNxarulPq2jwnRqqMH9zXUXglNM9T4zMxsPCZKksUjHlejEGdJg MeIBgxYiJxYA6hlseadcxjCAKdGxadr1BqfYCCjm3RfAX+JOw4D/6ix67x82aEIENFfl ni0lKt4cvMnXDE+4vYue2DXkz0Ck2Fx6RmUS8nbnp0Ch1baq1QiUEHTkTJFVIqfOJACB MkFoW4AC6quxwl4rqxyvB0XSFZKyOwpnOQWi0QpbZbPx2uXKf2J+BlFuvQzPzW0JEJvD vnmzBxmfgXdyikjk9YEbZ0QfWnklB/AYn9ntTaNWVR+G6kyr6yjrdId3p1OEAg6cL20g WP0A== X-Gm-Message-State: AOAM531K4O+UcB72gvzcHKyxjPdKIsn43UvbYpQYQyIbcrbKYNrNs91E YIB6zwk2gXQ9bJl3fnKai/Nqlg== X-Received: by 2002:a05:6512:1595:b0:479:1e0a:283b with SMTP id bp21-20020a056512159500b004791e0a283bmr28839782lfb.141.1655098518177; Sun, 12 Jun 2022 22:35:18 -0700 (PDT) Received: from [192.168.1.65] ([46.188.121.129]) by smtp.gmail.com with ESMTPSA id s7-20020a2eb8c7000000b002556a17e193sm875735ljp.38.2022.06.12.22.35.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 12 Jun 2022 22:35:17 -0700 (PDT) Message-ID: <33151594-4168-d01b-56b6-dc996d226a7d@openvz.org> Date: Mon, 13 Jun 2022 08:35:17 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 From: Vasily Averin Subject: [PATCH mm v4 5/9] memcg: enable accounting for percpu allocation of struct psi_group_cpu To: Andrew Morton Cc: kernel@openvz.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Shakeel Butt , Roman Gushchin , =?UTF-8?Q?Michal_Koutn=c3=bd?= , Vlastimil Babka , Michal Hocko , Muchun Song , cgroups@vger.kernel.org References: <3e1d6eab-57c7-ba3d-67e1-c45aa0dfa2ab@openvz.org> Content-Language: en-US In-Reply-To: <3e1d6eab-57c7-ba3d-67e1-c45aa0dfa2ab@openvz.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org struct pci_group_cpu is percpu allocated for each new cgroup and can consume a significant portion of all allocated memory on nodes with a large number of CPUs. Common part of the cgroup creation: Allocs Alloc $1*$2 Sum Allocation number size -------------------------------------------- 16 ~ 352 5632 5632 KERNFS 1 + 4096 4096 9728 (cgroup_mkdir+0xe4) 1 584 584 10312 (radix_tree_node_alloc.constprop.0+0x89) 1 192 192 10504 (__d_alloc+0x29) 2 72 144 10648 (avc_alloc_node+0x27) 2 64 128 10776 (percpu_ref_init+0x6a) 1 64 64 10840 (memcg_list_lru_alloc+0x21a) percpu: 1 + 192 192 192 call_site=psi_cgroup_alloc+0x1e 1 + 96 96 288 call_site=cgroup_rstat_init+0x5f 2 12 24 312 call_site=percpu_ref_init+0x23 1 6 6 318 call_site=__percpu_counter_init+0x22 '+' -- to be accounted, '~' -- partially accounted Signed-off-by: Vasily Averin Acked-by: Shakeel Butt Reviewed-by: Muchun Song Acked-by: Roman Gushchin --- kernel/sched/psi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c index ec66b40bdd40..c95e87269fc5 100644 --- a/kernel/sched/psi.c +++ b/kernel/sched/psi.c @@ -957,11 +957,12 @@ int psi_cgroup_alloc(struct cgroup *cgroup) if (static_branch_likely(&psi_disabled)) return 0; - cgroup->psi = kmalloc(sizeof(struct psi_group), GFP_KERNEL); + cgroup->psi = kmalloc(sizeof(struct psi_group), GFP_KERNEL_ACCOUNT); if (!cgroup->psi) return -ENOMEM; - cgroup->psi->pcpu = alloc_percpu(struct psi_group_cpu); + cgroup->psi->pcpu = alloc_percpu_gfp(struct psi_group_cpu, + GFP_KERNEL_ACCOUNT); if (!cgroup->psi->pcpu) { kfree(cgroup->psi); return -ENOMEM; -- 2.36.1