Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2998947imm; Tue, 4 Sep 2018 13:36:10 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYV7mpDhQLj3nsX+mxTierk10QF1gIyeKyk2mZjvyvm2BLvw7FctjByjf6dmzEVShL6ShVn X-Received: by 2002:a17:902:543:: with SMTP id 61-v6mr35707403plf.126.1536093369968; Tue, 04 Sep 2018 13:36:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536093369; cv=none; d=google.com; s=arc-20160816; b=mWIJPQyRFk/pIO+kpWbjXmSftZrZNePZx3xHQJjCnPS+VFSB5RUGWzio/cnVmYWeix 50cHyBdWvtCAhyTAwjgwGwFAaEwbbh7//8hLdq0x6KeNWZhXOxob0A2oilwTCz2AYM2F hB26sIlgdyKPBuN9PMQ382Ug+JcY9Y8DYsfVjwSp3/j0GSg1wOt7bEhmYVcq9wyafKiP 1Euv4t0tOi1Jed5jUqLPASfOQDU+hz9wE3+ADUnAoWzUofW68RBBmIOS+dOwShkbmaG4 uNNmPf3X96/FbpdCZIZ8ukpVz8Yb7V3IroygMyLhHSDutmnBG7C1YgWZ+QU0JyNzNfpn Ly7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:arc-authentication-results; bh=jdZPx2qgmld/MZFw3Y8fSyBtvI0SVpvEtYXr0Tb4ldM=; b=D4jTyF1eH9QjMe6CuKY3pZZh3FJAseHL7O8XTCnffPoB9re1vIF98Kfu6CXaD9M2y7 H1EY+YUvT/qQqgc0G6+IwfiznCOWA94aHk8+TfzC7x1lS148JuQ1sg5iqZSXuBknYeXE rHWC+ebHS57Q/hge6ZJfhTtrYG0U/7y0zhUbJVFf8PP7SsRGx+qm5HBdvWc3UO320+n2 Ab1Vt7FtgkP8Rb/2x9n3Z9qSsMVk0zepiUfnVll86lX67r/FmHRi8E0DO4jg1sEqGRMT EYTqpTaEavqeKRXmfM5lMxParwnfLNcsr2xiHMJp+VEMteZjHkfAGsUrzc2pI9VixQ3q UHlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bLxvnjJ5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y1-v6si21422631pgo.644.2018.09.04.13.35.54; Tue, 04 Sep 2018 13:36:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bLxvnjJ5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727495AbeIEBBB (ORCPT + 99 others); Tue, 4 Sep 2018 21:01:01 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:44439 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726284AbeIEBBB (ORCPT ); Tue, 4 Sep 2018 21:01:01 -0400 Received: by mail-lf1-f67.google.com with SMTP id g6-v6so4065185lfb.11 for ; Tue, 04 Sep 2018 13:34:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=jdZPx2qgmld/MZFw3Y8fSyBtvI0SVpvEtYXr0Tb4ldM=; b=bLxvnjJ5W+cOMslMeHF5UMEdjeMtUhYeqm5xFv8ntpSLjtSE4zpEdx5T1u5TcSxB2Q noTg4mLE/NbOLx2QLv9iHvdiwFlFbNNsnStDHBbqEj953s2m4zv/JCX9hKeA7IMIVOLT bC8d7rucA1ITr25N+aSlT7YYqRIQkgwRrWadJmSRWkDqJesyhqdXEOI2Zft7XjjjtOfu Ine6KIMSB9qSQZ+Sut5SQHku0inPtPHn3IimGgrzV9oKkNJkXtmKSgctI2va23NXyLpX pQ9TLuXSPfZyUCVpmPxOk4KY9+la5gnRV6TkTOKKGpR/jiBZOhv9nbYlL5QIpT/8VuCr 12iA== 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=jdZPx2qgmld/MZFw3Y8fSyBtvI0SVpvEtYXr0Tb4ldM=; b=Cj7Emtz7mtaJrUrAricDN5QQmZa/HPIhXmW1NptauUncUzXw02syvpp9NKPEWGkuSN USBK3T4WM/JOMXY+m39K0U9dJQpK9KVKdDlvQurFzMR7NHKSttVzjmkODr2ZSWsjl9e1 KwLFKWWvo/9yO+xkZz1Ma0ng75ycblqB2OJwoPzawueVb4gUQ3bmvyIUd6R17nPiwaB7 TJUowrh+8tgqIMxvLUqsgmbv9nP2lrctV9r4m97i0RhTmkYO/CG9XCnP5xSXCo7ul7ty kTcvQUE+6YaKTkEsj1HBVwDB6pFSMFeUgtU6uo+m8i2PRaa39JM/gcO+xX23wIVuHDuZ kL2w== X-Gm-Message-State: APzg51DSzXG5/Ixc1SRvEF8oylaF3IJd9U1U2vhEX23qNSqhoW174T5c r2Jj/ndiplOOCsuTocdq5o4= X-Received: by 2002:a19:f015:: with SMTP id p21-v6mr11153555lfc.56.1536093254617; Tue, 04 Sep 2018 13:34:14 -0700 (PDT) Received: from esperanza (81.5.110.43.dhcp.mipt-telecom.ru. [81.5.110.43]) by smtp.gmail.com with ESMTPSA id h16-v6sm4383533ljh.26.2018.09.04.13.34.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 04 Sep 2018 13:34:13 -0700 (PDT) Date: Tue, 4 Sep 2018 23:34:11 +0300 From: Vladimir Davydov To: Roman Gushchin Cc: Michal Hocko , Rik van Riel , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@fb.com, Josef Bacik , Johannes Weiner , Andrew Morton Subject: Re: [PATCH] mm: slowly shrink slabs with a relatively small number of objects Message-ID: <20180904203411.haiiy22ogpj77fvx@esperanza> References: <20180831203450.2536-1-guro@fb.com> <3b05579f964cca1d44551913f1a9ee79d96f198e.camel@surriel.com> <20180831213138.GA9159@tower.DHCP.thefacebook.com> <20180903182956.GE15074@dhcp22.suse.cz> <20180903202803.GA6227@castle.DHCP.thefacebook.com> <20180904070005.GG14951@dhcp22.suse.cz> <20180904153445.GA22328@tower.DHCP.thefacebook.com> <20180904161431.GP14951@dhcp22.suse.cz> <20180904175243.GA4889@tower.DHCP.thefacebook.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180904175243.GA4889@tower.DHCP.thefacebook.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 04, 2018 at 10:52:46AM -0700, Roman Gushchin wrote: > Reparenting of all pages is definitely an option to consider, Reparenting pages would be great indeed, but I'm not sure we could do that, because we'd have to walk over page lists of semi-active kmem caches and do it consistently while some pages may be freed as we go. Kmem caches are so optimized for performance that implementing such a procedure without impacting any hot paths would be nearly impossible IMHO. And there are two implementations (SLAB/SLUB), both of which we'd have to support. > but it's not free in any case, so if there is no problem, > why should we? Let's keep it as a last measure. In my case, > the proposed patch works perfectly: the number of dying cgroups > jumps around 100, where it grew steadily to 2k and more before. > > I believe that reparenting of LRU lists is required to minimize > the number of LRU lists to scan, but I'm not sure. AFAIR the sole purpose of LRU reparenting is releasing kmemcg_id as soon as a cgroup directory is deleted. If we didn't do that, dead cgroups would occupy slots in per memcg arrays (list_lru, kmem_cache) so if we had say 10K dead cgroups, we'd have to allocate 80 KB arrays to store per memcg data for each kmem_cache and list_lru. Back when kmem accounting was introduced, we used kmalloc() for allocating those arrays so growing the size up to 80 KB would result in getting ENOMEM when trying to create a cgroup too often. Now, we fall back on vmalloc() so may be it wouldn't be a problem... Alternatively, I guess we could "reparent" those dangling LRU objects not to the parent cgroup's list_lru_memcg, but instead to a special list_lru_memcg which wouldn't be assigned to any cgroup and which would be reclaimed ASAP on both global or memcg pressure.