Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp77224imm; Mon, 21 May 2018 02:32:34 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq5M31WtNvmdu0A4I/lwdytMyD6NzaVj77wQIkLlwWSdjoL0U0RG0w71iSyNDoWucqM7Wez X-Received: by 2002:a17:902:9304:: with SMTP id bc4-v6mr19734773plb.189.1526895154533; Mon, 21 May 2018 02:32:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526895154; cv=none; d=google.com; s=arc-20160816; b=yko+6x94QlWrOjP9FZ8HHRavabKGwfYHfyvESWGR63+LcPDbteTJ4E8nnuMcnDlmX8 77dAnw9fE1LxO+JH6BOnw7Z9a5nNm+NViBpqdkMtBe8j2Qk3VA1lb4mX/HvcZiGChBqe 43f6Etg6/0T29lIFYzdnUvCrk8GdlVETnrnqlWdMe+4am97qJf55s9v/6crSJv2CCJVC Tybki856UJ59TUFCPEdqeselu9l4/qHiXLSHvdvbtdxhA6IDr36ZJ3YuH4wE1RYAhkW5 sH/tA5v8/DUS3TiWeX4YgsaADRAMwvYfkGFVgNx0+aJJzJmKR0nmgdpdELJ0R3iGL7JO tzDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature:arc-authentication-results; bh=lPih3JtozWrpsp0+0jYcM14icPgt8vnu9QFA3YLFIE0=; b=Qkg0dep1KUASUyWHeTK4CI4VQqVuORuOptHyDyRjm5b391j58l0KkOk3hWbEFZJNdq e4jggGhFcnefGdcwp7fPxtieW7w8xJq67dgQ6W/PjDBSifin8WDJmiBfmXv4/EfcOXLA dxj6cr32v1dCmrKT609NZmLMmD28sGU/HQ/OW/hUHUPRQF8cDL9H3o02H66wrrbqS5yw Y+W97JJtfqYN4LQmYiHSUjdMGHqXZEUNMU7BDW/PBcTmuJMxZcJxY1Se3fdlPeB4wep6 /Rm5FrKIZ34BH/FTW9w4nNsedIozPwJntOZ8vB/VrUgFKi2lAqXf1KNvBBn6X3rIIHWc YySg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=selector1 header.b=Tw3L49Yo; 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=NONE dis=NONE) header.from=virtuozzo.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 8-v6si14134455plc.444.2018.05.21.02.32.19; Mon, 21 May 2018 02:32:34 -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=@virtuozzo.com header.s=selector1 header.b=Tw3L49Yo; 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=NONE dis=NONE) header.from=virtuozzo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751141AbeEUJbo (ORCPT + 99 others); Mon, 21 May 2018 05:31:44 -0400 Received: from mail-he1eur01on0102.outbound.protection.outlook.com ([104.47.0.102]:23392 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750922AbeEUJbl (ORCPT ); Mon, 21 May 2018 05:31:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lPih3JtozWrpsp0+0jYcM14icPgt8vnu9QFA3YLFIE0=; b=Tw3L49YoN1Ew95Y1ytbvgOFJjDv812fJfPzAQqpNw/b1Ng5HzVkMkKw31xRuaHOZFBN7craF7esDnmFROPUDg2bB8Ib5ZR+hMmOzIf3hLGZHlGh6CkCYeA2n1Lh0hAb6Ta/U5lhUgf81Ih9sbPfUIniNu+MsP7yPHP8D6wZSZ3c= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=ktkhai@virtuozzo.com; Received: from [172.16.25.5] (195.214.232.6) by HE1PR0801MB1338.eurprd08.prod.outlook.com (2603:10a6:3:39::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.776.11; Mon, 21 May 2018 09:31:36 +0000 Subject: Re: [PATCH v6 12/17] mm: Set bit in memcg shrinker bitmap on first list_lru item apearance To: Vladimir Davydov Cc: akpm@linux-foundation.org, 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 References: <152663268383.5308.8660992135988724014.stgit@localhost.localdomain> <152663302275.5308.7476660277265020067.stgit@localhost.localdomain> <20180520075558.6ls4yzrkou63orkb@esperanza> From: Kirill Tkhai Message-ID: <2a0ca70d-12bb-8087-9897-9cb33f676177@virtuozzo.com> Date: Mon, 21 May 2018 12:31:34 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180520075558.6ls4yzrkou63orkb@esperanza> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [195.214.232.6] X-ClientProxiedBy: HE1PR0902CA0005.eurprd09.prod.outlook.com (2603:10a6:3:e5::15) To HE1PR0801MB1338.eurprd08.prod.outlook.com (2603:10a6:3:39::28) X-MS-PublicTrafficType: Email X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(5600026)(2017052603328)(7153060)(7193020);SRVR:HE1PR0801MB1338; X-Microsoft-Exchange-Diagnostics: 1;HE1PR0801MB1338;3:LDeLSg4g0Qesd9S+1YVO23bGvxZpwHzHwpuA748yVJV3v56gLXD+GRf8ofOHTdRLQtBEF5l9R+1uypvjZjaRimJhnATy+GY0hgDY+Iu29xVP0+KW7AgqIy41V/A7+o0Md/8YMRxzegMDTaZ0lSDmEIjYu5lxug0FDNeFAxUV+kvM81zTyqc1x4TU+5RtXFCcOm9ZOTtusoYe0E8carOOi5gasfudNcpPDwMUVBX0BldHwveR06dsM3lAfH6cZ7h8;25:8k+7eXuwQhRemVCSS+PGfiaw+nbQt+03eOzQSlN3qy1qpH7Ak/rnj9eCbB6mtMi1jI7xmGYsP1jYSPPV5jVFxxOOnLOJstgIZEYjM9/Rnm5fJheYiZF4m6s3RvFmSSUoBaT99CqxU1ELVIv8gS+poqm4YhbIk96mQxT65xY01uIQMwE4giOpAtQ+RAtjbsrYFgx00gAobW5EYoK5EMlOcwj90M1x6nyxoGYUVOj9ldZ968i154K1qYN3QJOiKVXnzSHil8bJ30nXknTa9O1iOvKhRpVtLSK3Hh3RfejAuBaeQiNLDARxwXz/B8O479KGMf0Qe3RaG+NQvwSoCox8rg==;31:6OE5B0H2Cb//iVJ3Woyf+cQ0rCZ8qAkIyig/WG0+zd44lgjA80sr7iLhRTnPqPqIQ6g6DF3XoUZPpIJfQsZg846rVjBt8C7PEtxVOvTjWtRElMyssxNTlEZFLwqn7yPfhCpjLJ4b5VY3Nr1Qy7U6uAaUAembRTaiStIHB8DyD/EOi620iTDknFcGeGnx5Ktzz2XThbxYQCj4i1OJ3MkpOlckIvPIiyoAO9tQoWYv02w= X-MS-TrafficTypeDiagnostic: HE1PR0801MB1338: X-Microsoft-Exchange-Diagnostics: 1;HE1PR0801MB1338;20:R15mPVDa/FbtPwdgFEIh301V7nZLK0+Pj9Z0zwCfNcITNh+8P/GdhPMNiAnp5iJFdzQwAp1cxHUo+BsUGH0/nhzPls3mH8dT+lKd34F8wmqgGticl4irKg/NC3OOmRog/Vd21xMTEDtEey7Tw0Vy1tSQmupypn7vK0BFyqJkbEUPg9MpSlH29Ks/6v4PPsDFgwA3fA8hZ4q5DBSC8iUo+gJJGgS+/41Nxp3Bk4onNeJFKXcyf1f8n+FDC4EAMB1nEkZb4Rq2v09cYKPPC1vjbTFJ6hyQgcXHlJBLDJN4XLti/iyGGdCMEzSmYdLz+xLCqsUqN8El8dvVPtDrmC0jCtJZFUy4ye7IP3ogjBniGJmdz/fjMtVRox/nFKotFZTYu7ZdPdlMJpj4wAMl3f2j665wlzIj2EGNiYyzcCiW648bO1PEMZPgr/zBkOd2Z05tu6iU8Sz9tEaXTfaS3SFd1uqrQHpR9R4kxpBdZJCaaqka3oZZZKCPgNxrT6YjU20a;4:Tnd+FPpK3mex1Wog0G7MsN8ee34qsafxSlMqArV8FP2f/CTjSgRM6sYFVl+q7ecSq+x9k3QvUunJLjjUULNVuWrw0+paEntfQ2hcD97xPDiMkTWuDLsknbOgnX+GtaAi0vuz7f/BYGiKj/U3g5lxGZmH3YT/GH2TbRBhleHkaBMO3YE5aHeTYGL0cKd7OIluFrmyuaiKMR0XsVOhcIcaTcCCD9Ozp7qOukRwAiDUb0CGv8Orewd29uraCP12V8GrHxVc9FKjsf0MnmtYSzaogQ== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(5005006)(8121501046)(3002001)(10201501046)(93006095)(93001095)(3231254)(944501410)(52105095)(149027)(150027)(6041310)(20161123564045)(20161123562045)(20161123558120)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016);SRVR:HE1PR0801MB1338;BCL:0;PCL:0;RULEID:;SRVR:HE1PR0801MB1338; X-Forefront-PRVS: 06793E740F X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6049001)(376002)(366004)(39840400004)(396003)(346002)(39380400002)(189003)(199004)(8676002)(2616005)(3846002)(105586002)(81166006)(6116002)(6486002)(81156014)(106356001)(68736007)(6916009)(25786009)(305945005)(36756003)(486006)(476003)(956004)(86362001)(23676004)(64126003)(2486003)(52116002)(11346002)(31696002)(31686004)(575784001)(52146003)(50466002)(446003)(39060400002)(2906002)(53936002)(5660300001)(76176011)(316002)(97736004)(7736002)(58126008)(6246003)(16576012)(107886003)(7416002)(478600001)(386003)(8936002)(53546011)(47776003)(65956001)(26005)(66066001)(65806001)(65826007)(4326008)(229853002)(230700001)(77096007)(16526019)(59450400001);DIR:OUT;SFP:1102;SCL:1;SRVR:HE1PR0801MB1338;H:[172.16.25.5];FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; Received-SPF: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtIRTFQUjA4MDFNQjEzMzg7MjM6VnYxWi9veDhIMEhhOUhpMUNOb3owZlFB?= =?utf-8?B?NjNPSVd4S1dGK2ZkRkxod0VrMjVCbVp0RFZsSWZqWXZlbzhHK0Mwa0RNZUM3?= =?utf-8?B?YTk5aGlReG0raUFjVEF2d2RkYVFJUU5pK1dyUEFCSENDc05nZmhzbTYrQ0F5?= =?utf-8?B?ak54MHJHYzhNVjYwSVN0bFhhOEhMNGtvTUR3L0prZUE3OGtwRG1PaWJsblVm?= =?utf-8?B?K25Jc0t4TkRUMktEMGdGeE5TZnJQZjE5QTBoRkdlR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801MB1338;7:K0mthkZQLr+Ub1DrKR0+1BQx5XLceadTNQTlAohVB3rNhcXRC+sVMS7iL5Y6hwNgI7vP/vt6AzH+IOmjKSMcvAok8ymcgaKiDyuIWqf4u+8mzI3rcbavx2kjqPzie7YtzmzFeoU1pV39BraziT3iunMUrkLJwQKkgjXPssOF0SQRmhC9ndJegqGTHHpzXNpUPVQLyq8wO+9KL3ANw2njwDhHogq/iWp769VVUsnasrko+4DdzS8EQPuuWk4H8DzC;20:gT33ga8G8UAFOznox3eM4ucUBm7sqEWAawuEA31BJRQVQUaIHHOvQsSkAOgO8ey95o+VEQoTFYQ//YVB6ee6gsEHGpr8cvUf627umhyN/dKdD0w3Btr9JYGhSHrmkbTKJSZjkpooYOmi853iKAsj93Bchwa3QkU0uVL2rkuv8/o= X-MS-Office365-Filtering-Correlation-Id: 62ea24b8-74e8-4960-9b92-08d5befda730 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 May 2018 09:31:36.8932 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 62ea24b8-74e8-4960-9b92-08d5befda730 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0801MB1338 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 20.05.2018 10:55, Vladimir Davydov wrote: > On Fri, May 18, 2018 at 11:43:42AM +0300, Kirill Tkhai wrote: >> Introduce set_shrinker_bit() function to set shrinker-related >> bit in memcg shrinker bitmap, and set the bit after the first >> item is added and in case of reparenting destroyed memcg's items. >> >> This will allow next patch to make shrinkers be called only, >> in case of they have charged objects at the moment, and >> to improve shrink_slab() performance. >> >> Signed-off-by: Kirill Tkhai >> --- >> include/linux/memcontrol.h | 14 ++++++++++++++ >> mm/list_lru.c | 22 ++++++++++++++++++++-- >> 2 files changed, 34 insertions(+), 2 deletions(-) >> >> diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h >> index e51c6e953d7a..7ae1b94becf3 100644 >> --- a/include/linux/memcontrol.h >> +++ b/include/linux/memcontrol.h >> @@ -1275,6 +1275,18 @@ static inline int memcg_cache_id(struct mem_cgroup *memcg) >> >> extern int memcg_expand_shrinker_maps(int new_id); >> >> +static inline void memcg_set_shrinker_bit(struct mem_cgroup *memcg, >> + int nid, int shrinker_id) >> +{ > >> + if (shrinker_id >= 0 && memcg && memcg != root_mem_cgroup) { > > Nit: I'd remove these checks from this function and require the caller > to check that shrinker_id >= 0 and memcg != NULL or root_mem_cgroup. > See below how the call sites would look then. > >> + struct memcg_shrinker_map *map; >> + >> + rcu_read_lock(); >> + map = rcu_dereference(memcg->nodeinfo[nid]->shrinker_map); >> + set_bit(shrinker_id, map->map); >> + rcu_read_unlock(); >> + } >> +} >> #else >> #define for_each_memcg_cache_index(_idx) \ >> for (; NULL; ) >> @@ -1297,6 +1309,8 @@ static inline void memcg_put_cache_ids(void) >> { >> } >> >> +static inline void memcg_set_shrinker_bit(struct mem_cgroup *memcg, >> + int nid, int shrinker_id) { } >> #endif /* CONFIG_MEMCG_KMEM */ >> >> #endif /* _LINUX_MEMCONTROL_H */ >> diff --git a/mm/list_lru.c b/mm/list_lru.c >> index cab8fad7f7e2..7df71ab0de1c 100644 >> --- a/mm/list_lru.c >> +++ b/mm/list_lru.c >> @@ -31,6 +31,11 @@ static void list_lru_unregister(struct list_lru *lru) >> mutex_unlock(&list_lrus_mutex); >> } >> >> +static int lru_shrinker_id(struct list_lru *lru) >> +{ >> + return lru->shrinker_id; >> +} >> + >> static inline bool list_lru_memcg_aware(struct list_lru *lru) >> { >> /* >> @@ -94,6 +99,11 @@ static void list_lru_unregister(struct list_lru *lru) >> { >> } >> >> +static int lru_shrinker_id(struct list_lru *lru) >> +{ >> + return -1; >> +} >> + >> static inline bool list_lru_memcg_aware(struct list_lru *lru) >> { >> return false; >> @@ -119,13 +129,17 @@ bool list_lru_add(struct list_lru *lru, struct list_head *item) >> { >> int nid = page_to_nid(virt_to_page(item)); >> struct list_lru_node *nlru = &lru->node[nid]; >> + struct mem_cgroup *memcg; >> struct list_lru_one *l; >> >> spin_lock(&nlru->lock); >> if (list_empty(item)) { >> - l = list_lru_from_kmem(nlru, item, NULL); >> + l = list_lru_from_kmem(nlru, item, &memcg); >> list_add_tail(item, &l->list); >> - l->nr_items++; >> + /* Set shrinker bit if the first element was added */ >> + if (!l->nr_items++) >> + memcg_set_shrinker_bit(memcg, nid, >> + lru_shrinker_id(lru)); > > This would turn into > > if (!l->nr_items++ && memcg) > memcg_set_shrinker_bit(memcg, nid, lru_shrinker_id(lru)); > > Note, you don't need to check that lru_shrinker_id(lru) is >= 0 here as > the fact that memcg != NULL guarantees that. Also, memcg can't be > root_mem_cgroup here as kmem objects allocated for the root cgroup go > unaccounted. > >> nlru->nr_items++; >> spin_unlock(&nlru->lock); >> return true; >> @@ -520,6 +534,7 @@ static void memcg_drain_list_lru_node(struct list_lru *lru, int nid, >> struct list_lru_node *nlru = &lru->node[nid]; >> int dst_idx = dst_memcg->kmemcg_id; >> struct list_lru_one *src, *dst; >> + bool set; >> >> /* >> * Since list_lru_{add,del} may be called under an IRQ-safe lock, >> @@ -531,7 +546,10 @@ static void memcg_drain_list_lru_node(struct list_lru *lru, int nid, >> dst = list_lru_from_memcg_idx(nlru, dst_idx); >> >> list_splice_init(&src->list, &dst->list); >> + set = (!dst->nr_items && src->nr_items); >> dst->nr_items += src->nr_items; >> + if (set) >> + memcg_set_shrinker_bit(dst_memcg, nid, lru_shrinker_id(lru)); > > This would turn into > > if (set && dst_idx >= 0) > memcg_set_shrinker_bit(dst_memcg, nid, lru_shrinker_id(lru)); > > Again, the shrinker is guaranteed to be memcg aware in this function and > dst_memcg != NULL. > > IMHO such a change would make the code a bit more straightforward. IMHO, this makes the code less readable. Using single generic function with generic check is easier, then using two different checks for different places. Next a person, who will modify the logic, does not have to think about particulars of strange checks in list_lru_add() and memcg_drain_list_lru_node(), if he/she does not involved in the change of maps logic. Memory cgroup is already fell into many corner cases, let's do not introduce them in new places. >> src->nr_items = 0; >> >> spin_unlock_irq(&nlru->lock); Kirill