Received: by 2002:a25:2c96:0:0:0:0:0 with SMTP id s144csp134061ybs; Tue, 26 May 2020 05:36:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzK1wp2WxA6p+fjMkputjd1YWbZQP6t5zcdDgLGjLCrPYpemBWXVS2Ye9cVeA3zpESvkMea X-Received: by 2002:a17:906:7146:: with SMTP id z6mr960824ejj.315.1590496574501; Tue, 26 May 2020 05:36:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590496574; cv=none; d=google.com; s=arc-20160816; b=bh9H8ZrqduPTleOIgp2LX6kwsMxaoT70pKmQnOGdf+qrKQDNd+PCHP6UEG1rj0V6+W hczwsEPqT11C1ezRipE4afFNtl3k+H8TOtZg5f+DCO2e/Co+EGA/EN89cARU3/8UhENb BZfI3AiqWX1L98oTb84EoxFt0y8b+OgN1SCQaJbmFieUjyhX6HeuWztZH7jl/6I51F9e 8hFNjC9CmIMhnqF5GmgW0aZhNM3xJmyuWlxTi/MyCn5MLShSguHewe8XpKikHQiFutd/ ART2+9Hr53Kr6flqKP/CFRxIF9FWQNWnjbWMJ9D3kha+FGbcd7tbsvS1XjZHytFEpPgp 3xRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=jOaedyDbiTLgZ7Qzr+5Uu0Vpf+eJRJvvUlCuze6Idds=; b=koHOAm0nPUAJCBYOsSW9ejHgFoaEskV6MXne8IGGEh0GpGgUAruf+T6VakzShoykKL jorrReC02oMKttidrteckaPjj6Bipy7jaBDucvDLbTLLLus15S4tzM7+J64WCIjQhFG3 spxdl9uwq9lvq26MBWViEu905x0vSRzQFcrEBLSZZD/NM1veBfv5iddtir698un5eLDA WMsrGkIkqMo6nGGhIymFvkxToDuUnzxC3Mz11YH/UNhAYV6tx/IXauydvenuIPvZzfIT 5IPHmJx8TBPU/DRCtowFW4B1boAoWEhShPkxjn/xD8POFw+pWCHajp+ABvLbi/gj0kEW W6OQ== ARC-Authentication-Results: i=1; mx.google.com; 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 p90si2513024edd.284.2020.05.26.05.35.49; Tue, 26 May 2020 05:36:14 -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; 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 S2388497AbgEZKND (ORCPT + 99 others); Tue, 26 May 2020 06:13:03 -0400 Received: from mx2.suse.de ([195.135.220.15]:36132 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388339AbgEZKNC (ORCPT ); Tue, 26 May 2020 06:13:02 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 39E51B1C1; Tue, 26 May 2020 10:13:04 +0000 (UTC) Subject: Re: [PATCH v3 12/19] mm: memcg/slab: use a single set of kmem_caches for all accounted allocations To: Roman Gushchin , Andrew Morton Cc: Johannes Weiner , Michal Hocko , linux-mm@kvack.org, kernel-team@fb.com, linux-kernel@vger.kernel.org References: <20200422204708.2176080-1-guro@fb.com> <20200422204708.2176080-13-guro@fb.com> From: Vlastimil Babka Message-ID: <4d9e18ea-3100-8311-e969-a376096a0b60@suse.cz> Date: Tue, 26 May 2020 12:12:59 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <20200422204708.2176080-13-guro@fb.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/22/20 10:47 PM, Roman Gushchin wrote: > This is fairly big but mostly red patch, which makes all accounted > slab allocations use a single set of kmem_caches instead of > creating a separate set for each memory cgroup. > > Because the number of non-root kmem_caches is now capped by the number > of root kmem_caches, there is no need to shrink or destroy them > prematurely. They can be perfectly destroyed together with their > root counterparts. This allows to dramatically simplify the > management of non-root kmem_caches and delete a ton of code. > > This patch performs the following changes: > 1) introduces memcg_params.memcg_cache pointer to represent the > kmem_cache which will be used for all non-root allocations > 2) reuses the existing memcg kmem_cache creation mechanism > to create memcg kmem_cache on the first allocation attempt > 3) memcg kmem_caches are named -memcg, > e.g. dentry-memcg > 4) simplifies memcg_kmem_get_cache() to just return memcg kmem_cache > or schedule it's creation and return the root cache > 5) removes almost all non-root kmem_cache management code > (separate refcounter, reparenting, shrinking, etc) > 6) makes slab debugfs to display root_mem_cgroup css id and never > show :dead and :deact flags in the memcg_slabinfo attribute. > > Following patches in the series will simplify the kmem_cache creation. > > Signed-off-by: Roman Gushchin > --- > include/linux/memcontrol.h | 5 +- > include/linux/slab.h | 5 +- > mm/memcontrol.c | 163 +++----------- > mm/slab.c | 16 +- > mm/slab.h | 145 ++++--------- > mm/slab_common.c | 426 ++++--------------------------------- > mm/slub.c | 38 +--- > 7 files changed, 128 insertions(+), 670 deletions(-) Nice stats. Reviewed-by: Vlastimil Babka > @@ -548,17 +502,14 @@ static __always_inline int charge_slab_page(struct page *page, > gfp_t gfp, int order, > struct kmem_cache *s) > { > -#ifdef CONFIG_MEMCG_KMEM Ah, indeed. Still, less churn if ref manipulation was done in memcg_alloc/free_page_obj() ? > if (!is_root_cache(s)) { > int ret; > > ret = memcg_alloc_page_obj_cgroups(page, gfp, objs_per_slab(s)); > if (ret) > return ret; > - > - percpu_ref_get_many(&s->memcg_params.refcnt, 1 << order); > } > -#endif > + > mod_node_page_state(page_pgdat(page), cache_vmstat_idx(s), > PAGE_SIZE << order); > return 0;