Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp2048687imm; Fri, 6 Jul 2018 10:52:21 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfJouFcfe2R0X0WVx6/gukBv3iylWzIjdeVtqnO7eJ8dAyGCDp1k7umnukSLYImBLd2vzot X-Received: by 2002:a17:902:a581:: with SMTP id az1-v6mr11314175plb.61.1530899541008; Fri, 06 Jul 2018 10:52:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530899540; cv=none; d=google.com; s=arc-20160816; b=QR9uDENNmiRm0fhA6ZQq8H89Dv8QFXGnUa/37j1OsgG96zPcnyEkSiiK+OOoi2kOh2 dpedb9KYsZt18l3cfvK7gPV9MfeiTkmzexTqt/m0CX7BtC963UbAy592F8U6Lr/iOHAO dzMmWrOILi7pXgYUyTb8vGBiHfBVzEWKGzZoe/PdlfpRq+kdAjf3f9lg4d+V8Feq5Q0y jcMdRn5XVBDomAym4Ba/FuPNn+XwLyyPFsqjCXTaQyXjipkN/k2M6vJvSBcViUJJmouK GRbOfmN7PEEjDOhvLbEDGeHpDUpE9UxR3bOVUEDFPmEy2xts4XRvucJlEr9ew/XUADCh uJAA== 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=OkbqDxpMApogbWfgsRMKmScJD80hvoHW0nroC2QITLs=; b=d+s80Fzxd9PEzaF7/QQ6+87asEyAE0rnpFJGZQV916XHVtkPe8tgPaeI1rjHsn5bbW MeZu97/9N2/7sXCQ5V9E8bDjNQ41xoF25HxeEA9TqBDE6i9hnIvJhK8/yrRCFexcy0fb b3yyM/7RDWm0K8lUlzwXDMBErwh5nR9kuURHe9A39SA1p23xYUBFevTC+g89xncuuwJI BbvDB6Mwbhqi/rQtxg3Hb7IMNs+BrKJ3wzu5WdUvoaKlZu61KQ60VZXW5al6wvPR25Sq TjoX/PcaB5wAmeLhcL2Gc0NDFbTDUozx3EVKFZ4N8BVQVYj1AqykfUxzXfOZ59McnjBt /UpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=GBvalW9h; 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 b18-v6si8204532pge.666.2018.07.06.10.52.05; Fri, 06 Jul 2018 10:52:20 -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=GBvalW9h; 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 S933959AbeGFRum (ORCPT + 99 others); Fri, 6 Jul 2018 13:50:42 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:40558 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932895AbeGFRuk (ORCPT ); Fri, 6 Jul 2018 13:50:40 -0400 Received: by mail-lj1-f195.google.com with SMTP id a6-v6so9744124ljj.7 for ; Fri, 06 Jul 2018 10:50:39 -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=OkbqDxpMApogbWfgsRMKmScJD80hvoHW0nroC2QITLs=; b=GBvalW9hh9h3e8c7vBCkDdjvP8h76As1qLMSTDGyjJ2xjmkCYAl4vFI2om/NwwzyK1 z2wMKf1A8BuQ019e1VC0G/jLMepbF/uKEFaYv0ANUHsqgIVS5VG2g7aDQIi5eQOd10x9 wT/xbEzuJ8aWIR0mIFIe8OJwU+ysmIX97LLZZ6RDkL8/Nvj/KdMWnjVxxZp2llSsk0cf IbSDAnaCoIQ9gieu3PU97PvFMdG8NpPQIqlIomSSfYwzm8qwbWWv4m4f/kt1+aqR4TMj 0coAyIcD010+b7A1FOA62zRrHeXIPeZuTWf8x0M7ZVvqJO6UniLK0LS4vBqVVvvmV4ys TI/A== 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=OkbqDxpMApogbWfgsRMKmScJD80hvoHW0nroC2QITLs=; b=CpKmUo35qwC61f3KYcTlI76IG/Q/D9s5wpjPIWMHeX/wv2kH4YS/Wwi4y0XLygTKw8 USB2HYgZX0ZWfinq9CAm5OV9kGDNjrWfXXVp3NUJIZZgN0ol/znv0apmdt1sJCOvu6lv DU7xJiqTmtTvYR8/O64pDVL0gZAbdZwKrthOv0l2cDEbbluOGAkxtontWbkLVMCsrtcX Dxgq4ogz1S5ZbNcAqLyMPO+P5QIXwIK20fZejlAKRnU5AmhlSwUyMyq70PFpalltf2SU 7DEy1cBTmdgeabpwo/DXdStkcDHManeNryAj8tOEbfq16am3HzlUydJr53RuYaPPup43 ScGA== X-Gm-Message-State: APt69E0vOtu9NC6ijkapZFobjW9xTi3amG9yr3OjCHrtabNyVAgFJlAm myAmrTJW65f9pjuGs/DoACg= X-Received: by 2002:a2e:195c:: with SMTP id p89-v6mr7548610lje.138.1530899438918; Fri, 06 Jul 2018 10:50:38 -0700 (PDT) Received: from esperanza ([185.6.245.156]) by smtp.gmail.com with ESMTPSA id l20-v6sm2282035lfg.14.2018.07.06.10.50.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 06 Jul 2018 10:50:37 -0700 (PDT) Date: Fri, 6 Jul 2018 20:50:35 +0300 From: Vladimir Davydov To: Andrew Morton Cc: Kirill Tkhai , shakeelb@google.com, viro@zeniv.linux.org.uk, hannes@cmpxchg.org, mhocko@kernel.org, tglx@linutronix.de, pombredanne@nexb.com, stummala@codeaurora.org, gregkh@linuxfoundation.org, sfr@canb.auug.org.au, guro@fb.com, mka@chromium.org, penguin-kernel@I-love.SAKURA.ne.jp, chris@chris-wilson.co.uk, longman@redhat.com, minchan@kernel.org, ying.huang@intel.com, mgorman@techsingularity.net, jbacik@fb.com, linux@roeck-us.net, linux-kernel@vger.kernel.org, linux-mm@kvack.org, willy@infradead.org, lirongqing@baidu.com, aryabinin@virtuozzo.com Subject: Re: [PATCH v8 05/17] mm: Assign memcg-aware shrinkers bitmap to memcg Message-ID: <20180706175034.lptwrafs5iomb6jf@esperanza> References: <153063036670.1818.16010062622751502.stgit@localhost.localdomain> <153063056619.1818.12550500883688681076.stgit@localhost.localdomain> <20180703135000.b2322ae0e514f028e7941d3c@linux-foundation.org> <20180705151030.c67eb9a989c5f0023a53d415@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180705151030.c67eb9a989c5f0023a53d415@linux-foundation.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 05, 2018 at 03:10:30PM -0700, Andrew Morton wrote: > On Wed, 4 Jul 2018 18:51:12 +0300 Kirill Tkhai wrote: > > > > - why aren't we decreasing shrinker_nr_max in > > > unregister_memcg_shrinker()? That's easy to do, avoids pointless > > > work in shrink_slab_memcg() and avoids memory waste in future > > > prealloc_memcg_shrinker() calls. > > > > You sure, but there are some things. Initially I went in the same way > > as memcg_nr_cache_ids is made and just took the same x2 arithmetic. > > It never decreases, so it looked good to make shrinker maps like it. > > It's the only reason, so, it should not be a problem to rework. > > > > The only moment is Vladimir strongly recommends modularity, i.e. > > to have memcg_shrinker_map_size and shrinker_nr_max as different variables. > > For what reasons? Having the only global variable updated in vmscan.c and used in memcontrol.c or vice versa didn't look good to me. So I suggested to introduce two separate static variables: one for max shrinker id (local to vmscan.c) and another for max allocated size of per memcg shrinker maps (local to memcontrol.c). Having the two variables instead of one allows us to define a clear API between memcontrol.c and shrinker infrastructure without sharing variables, which makes the code easier to follow IMHO. It is also more flexible: with the two variables we can decrease shrinker_id_max when a shrinker is destroyed so that we can speed up shrink_slab - this is fairly easy to do - but leave per memcg shrinker maps the same size, because shrinking them is rather complicated and doesn't seem to be worthwhile - the workload is likely to use the same amount of memory again in the future. > > > After the rework we won't be able to have this anymore, since memcontrol.c > > will have to know actual shrinker_nr_max value and it will have to be exported. Not necessarily. You can pass max shrinker id instead of the new id to memcontrol.c in function arguments. But as I said before, I really don't think that shrinking per memcg maps would make much sense. > > > > Could this be a problem?