Received: by 10.213.65.68 with SMTP id h4csp3349imn; Sat, 24 Mar 2018 11:42:19 -0700 (PDT) X-Google-Smtp-Source: AG47ELtMh3TD5dGYAE2Bv2DDKz4BrJaBlGZFfqnfiI5X7bPBQ2QaPwHqYROUuuTBDU2rVDrEfJWl X-Received: by 2002:a17:902:9009:: with SMTP id a9-v6mr33438704plp.272.1521916939173; Sat, 24 Mar 2018 11:42:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521916939; cv=none; d=google.com; s=arc-20160816; b=ddm6KAuAvLcGRhE216Xagdi4WZvHAxsov8w6PWPUBLBcYRYPHqn0zsMjB4EhqiUI+k 4x2V5MyMcVhIiu5nDlWYUBR6K5DlEcSY5MQ45Ixfcpk9itrJrW6pI3aE1FjRi7DTDuTb mFo68h1NFPAwrn7RVR8NvdzbfbGLRlSvkvkZD6RMvhsqZ/PizC2P35Zy9+zL9efdVrla My/AHIGW1vXiTl9GANoFpdOLX/t9etQgT6ssAKZ7TzMIKu7ljhrgA3LvsJzhhlsTXxTA L/7GJCYQK/GOnmedaxblczsJO8Ouo109A/TVPC29x3qg9PZWPhI/+kT0aY+1m64+loC4 ytTQ== 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=1x/XcgpwXhpYN+nX00iNI7leEvm3H4wtDC1RsvD4uf8=; b=xqQZIRXEImgLPrRXa5zZ81KQsmd5SYVUEoLe7HMtw+a6soDy7ZBsRPcljFp8FO4CoA /qBlG255un+UYgWJIbmmXZP+SHNZRmxURJJmp+qij/M5Ns1mJEhBorVc1qs7p64Fw8/G R1mx78DIBmIrCDv1Hahji8Wa9AZGisNpebRrVOJdsZVUQPI91HGKvbdkPofo7FaF8hJa wyABVEfifOgbTaw60lvliCB8l8qmxUF1kubnmCg6ML88mu7mDO1F8oqmvmumIzxoM+9z JB657ksZRMACsd7GAJed3KwHqazM5FJSbDYGctUTtBWaVZgFABvf9cJTP6xlvmpVXcQY rePg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=vJk5QqCq; 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 a33-v6si6175820pla.618.2018.03.24.11.41.53; Sat, 24 Mar 2018 11:42:19 -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=vJk5QqCq; 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 S1752709AbeCXSkP (ORCPT + 99 others); Sat, 24 Mar 2018 14:40:15 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:35161 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752579AbeCXSkN (ORCPT ); Sat, 24 Mar 2018 14:40:13 -0400 Received: by mail-lf0-f68.google.com with SMTP id t132-v6so22731035lfe.2 for ; Sat, 24 Mar 2018 11:40:13 -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=1x/XcgpwXhpYN+nX00iNI7leEvm3H4wtDC1RsvD4uf8=; b=vJk5QqCqtUhog71suHTALA3woU5xs81MnFz/aT6gBfEw8Xg9CVYA/nxvqVxv/Acst/ 3ERN4fTr/ZaB4Y5QLgPswLXeUcTz2NXDuHZQ9PZSWZV/zNHpYKNl5f+U8Yo63CyJ2Y9x dTiluR+KptP62KuUQBIOXZl3Yp3h+aMXMBFqxFfChN4Gmuqb7LgC6RjlAZm3RTqQ0cut KtzoNZ//u8vLv0sRNKKg9YYhgPCoO2qHackX/Ez9xiAHFDkM+9KpW402oRygoABytk8l SVUv4OTJnBPHsBeJwkqeIYOkZDAHAkGHEhZbRxHk+UOqpyvKe/QGcdeyUCBIATD97LJK r1ZQ== 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=1x/XcgpwXhpYN+nX00iNI7leEvm3H4wtDC1RsvD4uf8=; b=UuQx6l5zaId2QouMS9nkEW557eTh4J1PPE1Q/YqqknLLlPWr1Rz0IzBZU2id4a1vJ2 VFeMhuEj9AKu/axe31zpNMnDuXy1Z0di7XJ01fmGm8SCt1QS4bb86DtdKNbcKrEyP0qq vj6/PkpnMav0obPZpzVNOGO+TBfwRDh7Pe18FA9WJtt04uT24jLixWoCs9AuNM0wd48t z/ci95PbehyKgzYjC87MSSsdfN9YUEWT+kuKZsPtptKv8UDmvDuWcoSecbmPCjwMLDQ6 d5MaM/KGkp2KNrrrN69wrlTT/yYE9w05eu5ZMk10y8MF+YW+Nje2TAxvXhk2PV8QhhH7 fvhw== X-Gm-Message-State: AElRT7FrVKeniquvsiY0cka1o369zsLSJQeKc0TYutbUCWTpWMpJW2yP voHqDqRFC0d9EIfitxQ1bDE= X-Received: by 2002:a19:db94:: with SMTP id t20-v6mr22034248lfi.39.1521916812403; Sat, 24 Mar 2018 11:40:12 -0700 (PDT) Received: from esperanza (81.5.110.211.dhcp.mipt-telecom.ru. [81.5.110.211]) by smtp.gmail.com with ESMTPSA id 81sm2579555ljz.67.2018.03.24.11.40.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 24 Mar 2018 11:40:11 -0700 (PDT) Date: Sat, 24 Mar 2018 21:40:09 +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 01/10] mm: Assign id to every memcg-aware shrinker Message-ID: <20180324184009.dyjlt4rj4b6y6sz3@esperanza> References: <152163840790.21546.980703278415599202.stgit@localhost.localdomain> <152163847740.21546.16821490541519326725.stgit@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <152163847740.21546.16821490541519326725.stgit@localhost.localdomain> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Kirill, I don't have any objections to the idea behind this patch set. Well, at least I don't know how to better tackle the problem you describe in the cover letter. Please, see below for my comments regarding implementation details. On Wed, Mar 21, 2018 at 04:21:17PM +0300, Kirill Tkhai wrote: > The patch introduces shrinker::id number, which is used to enumerate > memcg-aware shrinkers. The number start from 0, and the code tries > to maintain it as small as possible. > > This will be used as to represent a memcg-aware shrinkers in memcg > shrinkers map. > > Signed-off-by: Kirill Tkhai > --- > include/linux/shrinker.h | 1 + > mm/vmscan.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 60 insertions(+) > > diff --git a/include/linux/shrinker.h b/include/linux/shrinker.h > index a3894918a436..738de8ef5246 100644 > --- a/include/linux/shrinker.h > +++ b/include/linux/shrinker.h > @@ -66,6 +66,7 @@ struct shrinker { > > /* These are for internal use */ > struct list_head list; > + int id; This definition could definitely use a comment. BTW shouldn't we ifdef it? > /* objs pending delete, per node */ > atomic_long_t *nr_deferred; > }; > diff --git a/mm/vmscan.c b/mm/vmscan.c > index 8fcd9f8d7390..91b5120b924f 100644 > --- a/mm/vmscan.c > +++ b/mm/vmscan.c > @@ -159,6 +159,56 @@ unsigned long vm_total_pages; > static LIST_HEAD(shrinker_list); > static DECLARE_RWSEM(shrinker_rwsem); > > +#if defined(CONFIG_MEMCG) && !defined(CONFIG_SLOB) > +static DEFINE_IDA(bitmap_id_ida); > +static DECLARE_RWSEM(bitmap_rwsem); Can't we reuse shrinker_rwsem for protecting the ida? > +static int bitmap_id_start; > + > +static int alloc_shrinker_id(struct shrinker *shrinker) > +{ > + int id, ret; > + > + if (!(shrinker->flags & SHRINKER_MEMCG_AWARE)) > + return 0; > +retry: > + ida_pre_get(&bitmap_id_ida, GFP_KERNEL); > + down_write(&bitmap_rwsem); > + ret = ida_get_new_above(&bitmap_id_ida, bitmap_id_start, &id); AFAIK ida always allocates the smallest available id so you don't need to keep track of bitmap_id_start. > + if (!ret) { > + shrinker->id = id; > + bitmap_id_start = shrinker->id + 1; > + } > + up_write(&bitmap_rwsem); > + if (ret == -EAGAIN) > + goto retry; > + > + return ret; > +}