Received: by 10.213.65.68 with SMTP id h4csp1494923imn; Mon, 26 Mar 2018 08:36:17 -0700 (PDT) X-Google-Smtp-Source: AG47ELuxfrwGbpoD7dgFGsfXqRWVLh8LrGQ0/XkXqeo8VHBXu2DrXZMxz13fVqtPbPGG4immqnxf X-Received: by 10.98.236.220 with SMTP id e89mr27642252pfm.173.1522078577744; Mon, 26 Mar 2018 08:36:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522078577; cv=none; d=google.com; s=arc-20160816; b=Q0ad3wfN6JB9iFGN02pi+5Rvx1MjSmi1asS1JZfp+aiVyFI6bGIlSCbAU6ITzFw7jj 3NZKg8diupvL1ZSVmnRWv8iSF9FWK/3E5QpBxc8SpcUTt8URx932/I7akhctaWbWJnBy +1XnXTfNIC2Iw4jhiqxRMv6Yiql4mwamOaYSZFuCvoT6Iqrxl/c6vQuFHHMlYtOzaDop t1rexVifIekBNP0BPfV3y5IPWzeli+AYh7n7Lv8ml1siwD4lxK2/9RWtGBlEyo6MHitC LOJrXbtHud4rdJp9VX87IRY13Y3pfOz6EvCkeQaCrZCopgaR2gnRumeOiIO6SFFZ7T/j eMqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=OSw37RviY59NBqIWhTH+sjI/YRxxdUxRApxnUwKpvlo=; b=oGhg5162Axn35QUumDo884khUtRNlXzJFTG1fz9qD5HXBW99w1mP2I4+v8szuuvS7f 1b+aVE5g8TO3/I3zyWnDwnzt4KdjdvdngNHVAGs5R3WbnmAtvvZjnbCuXNawpj5wMS8z 89J8wkHJXPOkeQd2jwjEzSOgOtx13zhdkQpYqz3LkT5TlcEGRoKT2W+ct4tq+HLm/QQB l3GJmhPnQ8yo7U1YWa872UIP5yJmjYHwx23v4PZqnELma4GTEKgjFjf93/DpeGIUAQQ4 Bqae+huIOJYOtwmEe13xCw22y+urz0qC1OueXZw8gBfDQpY61KxAh8V03LMyrUY085AM B25g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=NixOKvd9; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d8si10361331pgt.246.2018.03.26.08.36.02; Mon, 26 Mar 2018 08:36:17 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=NixOKvd9; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752357AbeCZPfG (ORCPT + 99 others); Mon, 26 Mar 2018 11:35:06 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:51806 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751908AbeCZPfF (ORCPT ); Mon, 26 Mar 2018 11:35:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=OSw37RviY59NBqIWhTH+sjI/YRxxdUxRApxnUwKpvlo=; b=NixOKvd9XMx4mMw/Qt+xyKXSB ItIskHGGoA6pz0zY1GnsCUgjFkobeKtbePcG3Brshf4k0LoRzZjYuzC0oqCeTOeDlwbNeoyLbZBsc lu9mrMwybiM2YJLI84cQIcjnMCnOEK9PbILBI/pkyPA9dZdvnmzL9IV88RE7Lp49F5Tgr1pVGc7VS Y3bEWzUL57dICVi3NDV+Ooa4ziEoVS63hjKHPnm6CdRwGbfT6xI9FUTqFFlQrIwSGLwYHfl7i1IgG Qp9NA/6rpiBHUwdmny8suGnnRQx0oV8A5ZL9/1Me0YGDfXIgNFWH/R4uWNn8NwcHfi5PBL3XU783k ED9upAXDA==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1f0U8r-0004jD-Pz; Mon, 26 Mar 2018 15:34:37 +0000 Date: Mon, 26 Mar 2018 08:34:37 -0700 From: Matthew Wilcox To: Kirill Tkhai Cc: Vladimir Davydov , 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 Subject: Re: [PATCH 02/10] mm: Maintain memcg-aware shrinkers in mcg_shrinkers array Message-ID: <20180326153437.GF10912@bombadil.infradead.org> 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> User-Agent: Mutt/1.9.2 (2017-12-15) 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: > > 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). That would be true if you never wanted to resize the bitmap, but of course you do, so you have your own interactions with RCU to contend with. So you have the overhead of the RCU head, and you have your own code to handle resizing which may have subtle errors.