Received: by 10.213.65.68 with SMTP id h4csp447530imn; Tue, 27 Mar 2018 02:20:53 -0700 (PDT) X-Google-Smtp-Source: AG47ELvfPB/SJovOOkV1frAbItsRSYdPqvSEWCL0Z0gX4+l7oJ1E5O43c4OZpIu7bLKIGc7XmKOR X-Received: by 2002:a17:902:102c:: with SMTP id b41-v6mr40304886pla.39.1522142453288; Tue, 27 Mar 2018 02:20:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522142453; cv=none; d=google.com; s=arc-20160816; b=ixLlvsg9k+8tvPa8J0IYgNeB6TSgEtuIINOsagSVScXWkB8GVxDtuxPO3Mv4CJ7Qiy RPWzmosFER3h7/ZokZTo3lKq5pY+uO6IvvNWQLpqoixAkDItBizpulotAQQ6vwjVI3dz bxzQ4elHuQJdghSDGmEk1srvWusJbwxTTPWuJUj+FKm29kZjXRXMZXkGs8uRqySygfG0 28LPaN0zqj9exbJAAKabdjM7xWBae/DJiC21NoyienO7gvopXOtGl0ETmmsyXlmuxSCI 3DhUeEbVFSGOHJbtbM7dCLLefgLhzr/EWYJuaAGe2ixVhQiItmRNeWsaW4rRfKXzXVh5 KTqA== 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=BpF04zaTlNbVRym7tLkTj8qkOruMPpVmqVX9zTgBMEs=; b=ao0GmznpEqhVeSDosvRwCeDlyeQ8bW85Qtds01U8Fu9+RXFwVtHTXqJKgIjmH83Pac 5LShMOmIRBe2gpQOw6+OOGNQ6A4c7pk375hm5iY7fG2MA9/jzAJhgIcohwxs32EW/jfR JWdon5fjBIb7aTnd9l2vTp0kxPmfi2mzO4THa/RPoTZCYmHklVolI+4AI9IqBNGYjGh1 4pj0xAWMCHjgbCl3CHRfpJ+DzLerHzY9edfqEbCPVNCtCrTNMbBgSLuHVZIS3BTLPkl4 o66TFF2MYdhMzgKHZ4tsovdPb15E8tb/DDpCTa2wIw1Cb0RW+ZVIgYJn/cs8WSth7H35 Jq4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=lg8mh/bZ; 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 d1si588145pgu.357.2018.03.27.02.20.39; Tue, 27 Mar 2018 02:20:53 -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=lg8mh/bZ; 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 S1752160AbeC0JS4 (ORCPT + 99 others); Tue, 27 Mar 2018 05:18:56 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:39169 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750993AbeC0JSz (ORCPT ); Tue, 27 Mar 2018 05:18:55 -0400 Received: by mail-lf0-f66.google.com with SMTP id p142-v6so32243687lfd.6 for ; Tue, 27 Mar 2018 02:18:54 -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=BpF04zaTlNbVRym7tLkTj8qkOruMPpVmqVX9zTgBMEs=; b=lg8mh/bZvFR21YDQGd7HMDP74ucTBIXrdkbZSmZCltEFzbB455RinBj3oECdaiQlXK RLHH0DRLKLX5RplNOyDN3lUMY0WcA471RSl0OqnxafIzF+RDuEVKX+Y2fhpt+PbiXOAL lV16CS0AtXDZv/GgTEr064P5vwnnZKsL8QghJNuOBJBoAxHzuxrwhKKIM48nAEf7mg38 YjzjUAn/7Ys9QEwUjtefeWH9FXhlVm0byJBgkThv1Kkz3/bGYPUQbWdCSMuL9jtI1NoV UTjKSMR3CLzKTQDt4JrHrXHb6HlJLK07qbr+xkFSeSEvCPvtIBrpOc1Rsz2PILNa1U3n 1d9Q== 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=BpF04zaTlNbVRym7tLkTj8qkOruMPpVmqVX9zTgBMEs=; b=sXd0xppFE6G3G2r3TUygXrBIqJosw37hpF1neTzd7dM0LumepepJzXS4ivxP9lTVeI NQnBI6lUUikPHNgmAOqwrnENC+4dn4EfT1R6xUXFtvNdLEvvyj5c8eX1xlSkKGgdSWex AUUz7oD57g0y8DrrguRYUt8Dh+xs+uPo74E8ttWkoeQ/0NSmoQbURKJffRY6pUxLVF2/ erwSsiyOLf1KXjdWpYWWw2Vq/XqIKr2L0PKZ47BKcf7Q3AC3JhQ6YKpjVKTabD9DHEkD Ryw9aCeiWVXvIMZvwI5FgccrqCnEbstG0BC3hPO5PszX2GGlmDJjo7lhrAHlkwLe8Z15 2+nQ== X-Gm-Message-State: AElRT7ENykCkZNw8V9WCX7yb28PWkPdkquohG5U0sglQR7kbw8mRIvZu mCntZQ03ElDALG3ZqwgBwRc= X-Received: by 2002:a19:53cf:: with SMTP id h76-v6mr28417231lfl.87.1522142333681; Tue, 27 Mar 2018 02:18:53 -0700 (PDT) Received: from esperanza ([185.6.245.156]) by smtp.gmail.com with ESMTPSA id j64sm140640ljb.61.2018.03.27.02.18.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 27 Mar 2018 02:18:53 -0700 (PDT) Date: Tue, 27 Mar 2018 12:18:50 +0300 From: Vladimir Davydov To: Kirill Tkhai Cc: viro@zeniv.linux.org.uk, hannes@cmpxchg.org, mhocko@kernel.org, akpm@linux-foundation.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, hillf.zj@alibaba-inc.com, ying.huang@intel.com, mgorman@techsingularity.net, shakeelb@google.com, jbacik@fb.com, linux@roeck-us.net, linux-kernel@vger.kernel.org, linux-mm@kvack.org, willy@infradead.org Subject: Re: [PATCH 02/10] mm: Maintain memcg-aware shrinkers in mcg_shrinkers array Message-ID: <20180327091850.ybql6l6gavhdieqg@esperanza> References: <152163840790.21546.980703278415599202.stgit@localhost.localdomain> <152163848990.21546.2153496613786165374.stgit@localhost.localdomain> <20180324184516.rogvydnnupr7ah2l@esperanza> <448bb904-a861-c2ae-0d3f-427e6a26f61e@virtuozzo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <448bb904-a861-c2ae-0d3f-427e6a26f61e@virtuozzo.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 26, 2018 at 06:20:55PM +0300, Kirill Tkhai wrote: > On 24.03.2018 21:45, Vladimir Davydov wrote: > > On Wed, Mar 21, 2018 at 04:21:29PM +0300, Kirill Tkhai wrote: > >> The patch introduces mcg_shrinkers array to keep memcg-aware > >> shrinkers in order of their shrinker::id. > >> > >> This allows to access the shrinkers dirrectly by the id, > >> without iteration over shrinker_list list. > > > > Why don't you simply use idr instead of ida? With idr you wouldn't need > > the array mapping shrinker id to shrinker ptr. AFAIU you need this > > mapping to look up the shrinker by id in shrink_slab. The latter doesn't > > seem to be a hot path so using idr there should be acceptable. Since we > > already have shrinker_rwsem, which is taken for reading by shrink_slab, > > we wouldn't even need any additional locking for it. > > The reason is ida may allocate memory, and since list_lru_add() can't fail, > we can't do that there. If we allocate all the ida memory at the time of > memcg creation (i.e., preallocate it), this is not different to the way > the bitmap makes. > > While bitmap has the agvantage, since it's simplest data structure (while > ida has some radix tree overhead). > > Also, bitmap does not require a lock, there is single atomic operation > to set or clear a bit, and it scales better, when anything. I didn't mean the per-memcg bitmaps - I think it's OK to use plain arrays for them and reallocate them with the aid of RCU. What I actually mean is the mapping shrink_id => shrinker. AFAIU it isn't accessed from list_lru, it is only needed to look up a shrinker by id from shrink_slab(). The latter is rather a slow path so I think we can use an IDR for this mapping instead of IDA + plain array.