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=-0.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 0DFE9C3F68F for ; Mon, 3 Feb 2020 19:50:53 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BD58021582 for ; Mon, 3 Feb 2020 19:50:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=cmpxchg-org.20150623.gappssmtp.com header.i=@cmpxchg-org.20150623.gappssmtp.com header.b="D0HqVX8r" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BD58021582 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cmpxchg.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3F6E36B0006; Mon, 3 Feb 2020 14:50:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3A7016B0007; Mon, 3 Feb 2020 14:50:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2BC906B0008; Mon, 3 Feb 2020 14:50:52 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0250.hostedemail.com [216.40.44.250]) by kanga.kvack.org (Postfix) with ESMTP id 13B026B0006 for ; Mon, 3 Feb 2020 14:50:52 -0500 (EST) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id C53D68248047 for ; Mon, 3 Feb 2020 19:50:51 +0000 (UTC) X-FDA: 76449858702.07.iron78_41ab69d19dd42 X-HE-Tag: iron78_41ab69d19dd42 X-Filterd-Recvd-Size: 4461 Received: from mail-qv1-f68.google.com (mail-qv1-f68.google.com [209.85.219.68]) by imf30.hostedemail.com (Postfix) with ESMTP for ; Mon, 3 Feb 2020 19:50:51 +0000 (UTC) Received: by mail-qv1-f68.google.com with SMTP id l14so7383552qvu.12 for ; Mon, 03 Feb 2020 11:50:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=JkD/cmKgVjvJlz/chODMXHldUAezWfjEz1crchIilbE=; b=D0HqVX8rRbpc4IzpqW25Gk9bjTIyvGbGYetkvw/RwCmCIqfcOw8EVpr7YFX3GEFZcp 6ZS1B2GGkxKcJYrsn+Xq4k6aHTHS+HBr/qCyVhEaLF2AATpxfIJsee+0Nnv+NaAqxC4x N7C9I2+16X32dpCYRt1mBSH53WEUVpouETToOgMfYUQ4UfI4cmiTg7rZEdF7Ao39uKN4 4Id4zIGnV7kRpHUY1N7/Bh9XPiy66Vn/GJdDeTicwg77mbZfCttn2TcL3A/sAyUJEDPA yX576BqEXKqfp9KFDDKudOg1ZKdM4xjN6wSxswAZ3PdL6D4REh62T3oDqLyM8TQ22oEz KThQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=JkD/cmKgVjvJlz/chODMXHldUAezWfjEz1crchIilbE=; b=DI3o3FJAMLB1tq/oQyYNASz35VhzrlYCNeaMTDysEvAS6+gZP5uVXLhq5k7Fndz6Lk F6JbRDa3onmr2emYomVRhWhUMMaD2S7h//SOCDM655REAJjQDk8DzclXsgt/sIWNQ7Zg LSi32jrgsekDrYBSjxJ6hkry8P6/OAb5FgpJy91wswmX+Ivz9Itp3Z8SE64rn8/H+de/ S5d5xJiYplZmKoatYUmQh1iDskxeKKoxE2+/EBrPWG4rMYw2f1Lg8Jxe9MOBLzwIPCY8 Zv3+w1qCAOuOYxRK+TVJL+NhFmwrmXE5ugzxMNjXNs0+NoFDdhOMenvxAW9czwRVLokf tN7g== X-Gm-Message-State: APjAAAXXcb0yJAETn161hr7HWQ6Y4l23xH3a0MT0/Y4y6huyZ5ZGaHLk PtlRuoXvdDRQ8S6VgDpWL0rmkg== X-Google-Smtp-Source: APXvYqwbuIXO8OPwibdyKO2L/CKGknuXkY8tzebGCWk45IElHKm9B5GgSBi2flYSqXhDle/vy6Y+eQ== X-Received: by 2002:a0c:f485:: with SMTP id i5mr24637963qvm.8.1580759450480; Mon, 03 Feb 2020 11:50:50 -0800 (PST) Received: from localhost ([2620:10d:c091:500::2:6320]) by smtp.gmail.com with ESMTPSA id n4sm10348107qti.55.2020.02.03.11.50.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2020 11:50:49 -0800 (PST) Date: Mon, 3 Feb 2020 14:50:48 -0500 From: Johannes Weiner To: Roman Gushchin Cc: linux-mm@kvack.org, Andrew Morton , Michal Hocko , Shakeel Butt , Vladimir Davydov , linux-kernel@vger.kernel.org, kernel-team@fb.com, Bharata B Rao , Yafang Shao Subject: Re: [PATCH v2 21/28] mm: memcg/slab: use a single set of kmem_caches for all memory cgroups Message-ID: <20200203195048.GA4396@cmpxchg.org> References: <20200127173453.2089565-1-guro@fb.com> <20200127173453.2089565-22-guro@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200127173453.2089565-22-guro@fb.com> 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, Jan 27, 2020 at 09:34:46AM -0800, Roman Gushchin wrote: > This is fairly big but mostly red patch, which makes all non-root > 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 is definitely going in the right direction. But it doesn't quite explain why we still need two sets of kmem_caches? In the old scheme, we had completely separate per-cgroup caches with separate slab pages. If a cgrouped process wanted to allocate a slab object, we'd go to the root cache and used the cgroup id to look up the right cgroup cache. On slab free we'd use page->slab_cache. Now we have slab pages that have a page->objcg array. Why can't all allocations go through a single set of kmem caches? If an allocation is coming from a cgroup and the slab page the allocator wants to use doesn't have an objcg array yet, we can allocate it on the fly, no?