Received: by 10.213.65.68 with SMTP id h4csp1356845imn; Wed, 21 Mar 2018 08:44:56 -0700 (PDT) X-Google-Smtp-Source: AG47ELuoXrWufu6dtjUxMfaB3ElvjrCCiVwamnyJ1dgay0ow2DbwVQdBjsspw52Vua3zFxNFeBJG X-Received: by 10.98.157.7 with SMTP id i7mr7589556pfd.85.1521647096172; Wed, 21 Mar 2018 08:44:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521647096; cv=none; d=google.com; s=arc-20160816; b=zqEUUZeYhUev/0D4CTKrJxAoUuUROersCXTyhu9OqUvjB6zoode1WGi+CXx2KkgCrw ec0P9l84DWLRU+wZHUX9vUVjpH6dTiCrR+nRkonGPMVNxW0mTKKC1A58qJP3eFdiJX5m zqQimTwOb5+NqtYxfoLvaw8gg2uTsko3H/m96lyUq792X4BIxSPBh56JkAFkZAJva+C2 vx3s6I/t60Qp4f/YdaV8ZCO7WTCxapW/D2lzTH/DbkrdLZkH4OLcaverWzw4azHVlJ14 OvTSHYW8rup5vEH8dL4/CF1t2Y9+V33VjwVcPc/bBTM8jEYjyDDvnVD+W2qgfwDAZ7vp 7Bow== 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=AQUk4ysoKR7TZHxhU0vlVz1f647BB093t+/qzj/cjdM=; b=znz48cLfWRcydrFw71my8bzgqAntdwQ7SuAGivK56Au9jzpzMufr3ZPqSCCaefqAju Le2KDEkbU0iDptMSr8yqaWUxnTF5QEO/kBwjsHpxlyBmdPsgZoZfdvHL/PKmP0A8AUNH WUjmYxLbRfwuhhDVAftipij25xJHnDT/7WneepyTD9BvXyib4qSLrLXs5MICxzEo/cba M6sd1ocGwoBm6Q0XCc3a3ki8JZBy1DenXXehbtyRiOL/Ea7dL+ly/yWy5Fcxr5kMo+Bq Mm6Ujz8KvQ96tRPeFua+tIDn2YeapcN7tdCU3awElEdgMJmiJJ3HF99tSJoQzLNsv2CQ 0xdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=selector1 header.b=DTDjSoCZ; 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 o191si174857pfo.56.2018.03.21.08.44.40; Wed, 21 Mar 2018 08:44:56 -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=DTDjSoCZ; 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 S1752533AbeCUPnZ (ORCPT + 99 others); Wed, 21 Mar 2018 11:43:25 -0400 Received: from mail-eopbgr20122.outbound.protection.outlook.com ([40.107.2.122]:45621 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752123AbeCUPnK (ORCPT ); Wed, 21 Mar 2018 11:43:10 -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; bh=AQUk4ysoKR7TZHxhU0vlVz1f647BB093t+/qzj/cjdM=; b=DTDjSoCZuuoOk9hdZym1pmHiPTsjcUe03vZPEHfDsMs7Xexyk7VNkYQtMPzMBxS1uawIRfbA1rJYCEvIdoq3owOcsgxrZ6dmrGeIJuI5v300KKR4XDDHk6DD8SmaDRUdskhpx6jIrlrgQdva5zTxMAzx4chVe5BkY1CzhfXK5t4= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=ktkhai@virtuozzo.com; Received: from [172.16.25.196] (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.588.14; Wed, 21 Mar 2018 15:43:03 +0000 Subject: Re: [PATCH 03/10] mm: Assign memcg-aware shrinkers bitmap to memcg To: Matthew Wilcox Cc: viro@zeniv.linux.org.uk, hannes@cmpxchg.org, mhocko@kernel.org, vdavydov.dev@gmail.com, 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 References: <152163840790.21546.980703278415599202.stgit@localhost.localdomain> <152163850081.21546.6969747084834474733.stgit@localhost.localdomain> <20180321145625.GA4780@bombadil.infradead.org> <20180321152647.GB4780@bombadil.infradead.org> From: Kirill Tkhai Message-ID: <638887a1-35f8-a71d-6e45-4e779eb62dc4@virtuozzo.com> Date: Wed, 21 Mar 2018 18:43:01 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180321152647.GB4780@bombadil.infradead.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [195.214.232.6] X-ClientProxiedBy: DB6PR07CA0021.eurprd07.prod.outlook.com (2603:10a6:6:2d::31) To HE1PR0801MB1338.eurprd08.prod.outlook.com (2603:10a6:3:39::28) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3952633d-2e4a-497e-ca84-08d58f4270dd X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(5600026)(4604075)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020);SRVR:HE1PR0801MB1338; X-Microsoft-Exchange-Diagnostics: 1;HE1PR0801MB1338;3:nYoXo0/Tu4HgZ1MLG6rr7MC+s3NoPE1GRLzesd1WHuTKKFMeQ5FdTaFJVugkPyP61MroBq/bXzJbADRtHDJli27vuzXGumtiOLFwkgKJtGDO6HeCbQK7rEY5aYrl8yGc+QzzT7iQMSWgxkVEm/a2spoWMkgK/Z/hy9w9T9zBmru73iEiiO8Gce16qARXT0LeIrMiCmN+NWHiyj8LPYqpSFgZIZJ8lt05nIqnVDnL9Jwqhxx+ZV3a4jNy3NIOJdhT;25:XDpfxkGgKZFnO9rQMy6coOMjLWj5Xxbwn3+GY+BV6cignQh996Rh9rP9n2j4szJpQFniKMuVLJbju1xhRg6YSrlxtrXzVZjZAYH+o36+0zTIcaP9T1XDYSMWZXPxcONdpeGfEjS6OjOvGZL5itJuAUNSD68/FFjbAm5QMRCvRml692tBq3Eb5cCq84c6+6VZyEPx4dGV+mFvzrWeEk4sHYYiRFF30YHFCT80mzOaild0Bez3/Y5zJ5nmx629fDjL1UF5sjQlnVFLqDASDLR9hLEOU8c+ad4d/QNados3IxaKU4p6LNAcge3LiTAT5fltjTAgQ7vUmHO2MyPuCPJH2w==;31:z2OGXBLR08rlLn9fjZMKjRkoQg2LA90NyjjuLiqVNqtURNEUwjD3Jm69ZXyJEe6Ue+1kkqxLZvkLegHnxDJHnFVfsYWC9I/LJu/GxG9iVKNfQHIIdHAf8Hwq8Y0/TNeSeCapFoIzlUIOYIjXJTz7YcuXzUOLnB48u/uD0ph4OkK2W/d6m4IuGfx8izsdrqEZSK9834EbgaLVPQuWoe78e1y2EXvy8V40ydKMINrX7X0= X-MS-TrafficTypeDiagnostic: HE1PR0801MB1338: X-Microsoft-Exchange-Diagnostics: 1;HE1PR0801MB1338;20:yXlFBVY2NL/9q1/vcFSBlHW27sD9qG/WSp1vp+sYUtNw3a+IIY9Ws8lUn7zphN7Uudg7nAf0ZphG7RZmYYReBs/jE4HN7lFSLwSDrk971uLZ1K1zcHa2kLcf4602aOP2+wFPT2kXHX8skkH9Xx15NawjZDabYywh7sOvydN5PJpCXUC7qq9CIn3HImL9FM5DV/Yv4PfkI2xPBlTa4vkUDjQx1jAAJWMeuzJx40qkLEaDPULgHvHLM8+yalSYQKZhvMNgLB/OjPmrEnSRL4ZQAOJ8Zqpr4xCM8pRhTZALzvPuRlvN1Owg0T90PWPCNlR82UJXjgDmmRTRFGyur0q0jPIf0X8OSicZol/YNwNYyjkG1aLbTpwoRRN3qPwde8EiD4h93nVxvpZ/zZmmLpYCVuv6b7IYJUNZsvbHXPBFDrSFX2ga56KgzN9kzASB8X/sYfEs3fJdx8KP6zct9tFyZcUlsR4poQJHQBeMDpFS1kX4Q8s2BK32p0aARLdKqt84;4:mrNtCBpHK2tEd8RaCC70T2DUdOf5o4mXq9JXqJ/XtRWgAmwngAWgX0Do7iNiPt81LAGaQH8xCZwIYXfl0h7rk9G+lt3ntzl2KYu6hF8t2Sj6BQ/HB4TNxj5eiIZdzi8pMjHar8Gm62KSVoIF7FDhle4zLwHoKWVCBjDgGBd6aW/S5sG4VeG3+TSyNDEsb4T2/NR8fMCDWM30NozdgnoyOWAGJt0s3HIW8AvQffSCAt6pcNFnI+HtWKB6kaMTpirkZGkAYqE6MgNfMWJHxj0OKA== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(8121501046)(5005006)(10201501046)(93006095)(93001095)(3231221)(944501324)(52105095)(3002001)(6041310)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:HE1PR0801MB1338;BCL:0;PCL:0;RULEID:;SRVR:HE1PR0801MB1338; X-Forefront-PRVS: 0618E4E7E1 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(979002)(6049001)(396003)(39850400004)(366004)(376002)(346002)(39380400002)(189003)(199004)(2906002)(47776003)(64126003)(106356001)(5660300001)(52116002)(478600001)(65806001)(25786009)(97736004)(66066001)(65956001)(31686004)(65826007)(39060400002)(105586002)(68736007)(230700001)(53546011)(386003)(3846002)(52146003)(23676004)(6116002)(2486003)(36756003)(76176011)(31696002)(8936002)(93886005)(16576012)(53936002)(2950100002)(55236004)(77096007)(58126008)(305945005)(26005)(86362001)(81156014)(8676002)(6486002)(7416002)(81166006)(50466002)(4326008)(16526019)(186003)(7736002)(6246003)(316002)(59450400001)(229853002)(6916009)(969003)(989001)(999001)(1009001)(1019001);DIR:OUT;SFP:1102;SCL:1;SRVR:HE1PR0801MB1338;H:[172.16.25.196];FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; Received-SPF: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtIRTFQUjA4MDFNQjEzMzg7MjM6SzJXQjZFakljelgrUHhUM0hkVXhVeGNW?= =?utf-8?B?MWZWS01zWGdRNW9UZXdpdzczWlRFa0VwbCtxQnhkRExFU1VDRkRyVitNaldQ?= =?utf-8?B?QXZVb0dWRjZkcVRvREUvSUxxSWl0T3pXK2RzMTJZL2NROFJwQVBhTWw1cDJZ?= =?utf-8?B?S3BYcUV6VUNHTEZJVDRzdFZQNktxbkhKVmZ5WVJRZzByY01GYWRlc0I1QmEw?= =?utf-8?B?QkkwO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HnIESkPLijHUubOrHoV8z/XAE5roZUad2FbhwmqZ6MQptRq+H+/9HWZUmoCDnT0DeRWSG5ySnl8prpg9TP2PM7/9gc6FCRc2wJDrBtr7Ceo1oFrRL7ja63gCz2qPicTDCi566J81Ex2k SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;HE1PR0801MB1338;20:7KuStK4oMIZmx60Ngts0AYs9BDR0/JzI6au+/lqxjwqTmDRiwgb4zvi8Gs/rXyrsgf3GVfedlq+KNp0FV/78BTrhG7nt49SdTN3zP0QwMVWPx43WvoC0xwy2bQ+ONH0a1T/+gkhB60bI7sNfBSDJf8dMwYO6+/jGOkHr2O6mOjI= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Mar 2018 15:43:03.6676 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3952633d-2e4a-497e-ca84-08d58f4270dd 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 21.03.2018 18:26, Matthew Wilcox wrote: > On Wed, Mar 21, 2018 at 06:12:17PM +0300, Kirill Tkhai wrote: >> On 21.03.2018 17:56, Matthew Wilcox wrote: >>> Why use your own bitmap here? Why not use an IDA which can grow and >>> shrink automatically without you needing to play fun games with RCU? >> >> Bitmap allows to use unlocked set_bit()/clear_bit() to maintain the map >> of not empty shrinkers. >> >> So, the reason to use IDR here is to save bitmap memory? Does this mean >> IDA works fast with sparse identifiers? It seems they require per-memcg >> lock to call IDR primitives. I just don't have information about this. >> >> If so, which IDA primitive can be used to set particular id in bitmap? >> There is idr_alloc_cyclic(idr, NULL, id, id+1, GFP_KERNEL) only I see >> to do that. > > You're confusing IDR and IDA in your email, which is unfortunate. > > You can set a bit in an IDA by calling ida_simple_get(ida, n, n, GFP_FOO); > You clear it by calling ida_simple_remove(ida, n); I moved to IDR in the message, since IDA uses global spinlock. It will be taken every time a first object is added to list_lru, or last is removed. These may be frequently called operations, and they may scale not good on big machines. Using IDR will allow us to introduce memcg-related locks, but I'm still not sure it's easy to introduce them in scalable-way. Simple set_bit()/clear_bit() do not require locks at all. > The identifiers aren't going to be all that sparse; after all you're > allocating them from a global IDA. Up to 62 identifiers will allocate > no memory; 63-1024 identifiers will allocate a single 128 byte chunk. > Between 1025 and 65536 identifiers, you'll allocate a 576-byte chunk > and then 128-byte chunks for each block of 1024 identifiers (*). One of > the big wins with the IDA is that it will shrink again after being used. > I didn't read all the way through your patchset to see if you bother to > shrink your bitmap after it's no longer used, but most resizing bitmaps > we have in the kernel don't bother with that part. > > (*) Actually it's more complex than that... between 1025 and 1086, > you'll have a 576 byte chunk, a 128-byte chunk and then use 62 bits of > the next pointer before allocating a 128 byte chunk when reaching ID > 1087. Similar things happen for the 62 bits after 2048, 3076 and so on. > The individual chunks aren't shrunk until they're empty so if you set ID > 1025 and then ID 1100, then clear ID 1100, the 128-byte chunk will remain > allocated until ID 1025 is cleared. This probably doesn't matter to you. Sound great, thanks for explaining this. The big problem I see is that IDA/IDR add primitives allocate memory, while they will be used in the places, where they mustn't fail. There is list_lru_add(), and it's called unconditionally in current kernel code. The patchset makes the bitmap be populated in this function. So, we can't use IDR there. Thanks, Kirill