Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753480AbdHWIBD (ORCPT ); Wed, 23 Aug 2017 04:01:03 -0400 Received: from mail-eopbgr30134.outbound.protection.outlook.com ([40.107.3.134]:17389 "EHLO EUR03-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753386AbdHWIBB (ORCPT ); Wed, 23 Aug 2017 04:01:01 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=ktkhai@virtuozzo.com; Subject: Re: [PATCH 3/3] mm: Count list_lru_one::nr_items lockless To: Vladimir Davydov Cc: apolyakov@beget.ru, linux-kernel@vger.kernel.org, linux-mm@kvack.org, aryabinin@virtuozzo.com, akpm@linux-foundation.org References: <150340381428.3845.6099251634440472539.stgit@localhost.localdomain> <150340497499.3845.3045559119569209195.stgit@localhost.localdomain> <20170822194725.ik3xwxu67wcthisb@esperanza> From: Kirill Tkhai Message-ID: Date: Wed, 23 Aug 2017 11:00:56 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20170822194725.ik3xwxu67wcthisb@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: VI1P18901CA0004.EURP189.PROD.OUTLOOK.COM (2603:10a6:801::14) To DB6PR0801MB1333.eurprd08.prod.outlook.com (2603:10a6:4:a::27) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 83e6d035-91f1-4f92-c719-08d4e9fd169d X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:DB6PR0801MB1333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Q4e3JnzuXDPdWVPbsfOiFV57NSEulJGgj4FZUAg9PPX9dv5JKUqJNJIt1zEEQiRZhBunAzaFoW2g/K4t2mCLBfjCvcgbznSMP9rVLIqMqzHX7aUMJedlzYBvY6oe7DXp9WRSH7mQeVN1nqdVgPSjL50dh94BkdwvIfIPgJGn20MagqNNl+TZUK46cQnMGVJrSv7jUIHlKouwVE7+UmyPKLlas1lqzenaXpkfzi7nTS3wVaulkL7lhoIpXszyF7QDi/jmM4e0Io2l2vtQb6RWlhOeAPnT/77753HSAysyaglSoc2dFkf4nqQ=;4:5AItYNPppdwgxF2JHShceeH2SvWWLLg7sLhF8B24BYA72yYZefpl5V4UT2tU/LPhkh4qxTBO4XW0UmDtyQCG/bHk4luEm8pgbxWr5zxESBWYxIKXM6hZu7iXXYeb478XP4SyDAQCbX2qRwHgl7dahoIAOCGyCrEDQ1P86pVk7zexdR4nQWBzVoiV5KN9NyM0C8Q9xY5iEt95vZ4eapsCgREZmZ35UdOmFyrKASztaViRKXGDbbNz8+C29M5JuSBDKcOMP33sNp7V1sMVQOC+c8nMRZCjvpFGNlPmijBYJOxinral5mWM7Eickl+jfJpHSfY7LQhvHG8QdlCk3yyWug== X-Exchange-Antispam-Report-Test: UriScan:(190756311086443)(215187933766430); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(100000703101)(100105400095)(3002001)(10201501046)(93006095)(93001095)(6041248)(20161123562025)(20161123558100)(20161123564025)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:DB6PR0801MB1333;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:DB6PR0801MB1333; X-Forefront-PRVS: 040866B734 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(7370300001)(4630300001)(6009001)(6049001)(199003)(189002)(24454002)(25786009)(478600001)(83506001)(2906002)(3846002)(4326008)(7736002)(305945005)(106356001)(105586002)(36756003)(97736004)(4001350100001)(7350300001)(6306002)(966005)(65826007)(5660300001)(6116002)(6246003)(110136004)(68736007)(86362001)(230700001)(53936002)(53546010)(31696002)(76176999)(54356999)(229853002)(2950100002)(31686004)(101416001)(6916009)(6486002)(77096006)(50986999)(23676002)(189998001)(64126003)(4477795004)(66066001)(65956001)(65806001)(42186005)(33646002)(50466002)(47776003)(81156014)(81166006)(8676002);DIR:OUT;SFP:1102;SCL:1;SRVR:DB6PR0801MB1333;H:[172.16.24.149];FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtEQjZQUjA4MDFNQjEzMzM7MjM6VHNUcy9JOGlZYng1Vm5ENWU0MytBaTBy?= =?utf-8?B?bTZuSnpLTGh4MUdFek9PamREZzhORkhlbHEzbmhQODhUUUh2M1FjdEd6L28z?= =?utf-8?B?aGwzcnUzMHNRSzVtTFJ0S2VuN2VIc1N0OVlMU3ZoL3dEdkM4azk1OHY2cFZr?= =?utf-8?B?OHcvZzdmY016SlZDcGhqUE1wT2VicFA4UDc3UmFWN2RlanlaVnFxcUtEK1Zx?= =?utf-8?B?UXRMSnRCS3BRdkpZMk1WUUNlU2orK1g0K1RzZXh1SnExMG5rRVZpdjByVGxQ?= =?utf-8?B?ZjY3aW5GdXR0UmhqT3AyLzdKdnFBdUE3TGpIbEkrU284VHFyWVdjQ0cwWkg5?= =?utf-8?B?bXBCRW9WMVp3TjkrU1pKK1A1TkpYZERKUmFtTVRzb3E1Z0xiclBvckMxMy9p?= =?utf-8?B?c2o2RTYyemdnNEVxTE9zTndydGlKL0FKWWdLZStmK0srV0l5cGVZTkNoc3RT?= =?utf-8?B?b1FYN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LWLIm8rZ/VzJo6JJzd3d617H9eBIVMzcRpZt868Aw0DJ2zXkKSP3w4q4dI3Q6th1jRGIKzSlgYn5eA==;24:pSv+J81DiPHIgC+K9lTr5JzStNdOLdyOycl8p2Gxixj3og7cxd5S8SWRIaPkcIxgOX3a/GulIuDFb+PH4GPjl4IhS4Dxp5NQYxf9Amcav2w=;7:re1gZ2Yo5gAsppaX3xjq5rqGdrPr8p3RhNEcajp7svTn4NS3wQQoi/oNhk8ySMCcScvnlLhPNR89sLWAlRc+GzJ2EFrfpIGHjkMzVdTheRpGHrJeMJpRgcuqsNnG4j24jfzdTBQOH/I2xmoxdMbDWdgtJhTbpXI66xPTG/W7BKqaJEd83a6Bbw2lhZPAEwy/5rxqUgHkdPH3DXAmappyVyFBYWzOLc2a9DcyUaAqOUs= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;DB6PR0801MB1333;20:wK4FjgEp807CK6mbMgWoVV6YZrP8ek0845Jvav20nYD3PJw+aXj7bXm7I2JmMEDK86PvqZpFIIyG11nrLrL9hNpT2KPbDhuJuZHGdfE6LdnI6LRcTRRlDwS9+q1aE21K4Qp0b01Ix7z7hYeQPPEzYJEuK8KJQbaBBeK6Xj3AEVQ= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2017 08:00:57.3550 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0801MB1333 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2670 Lines: 48 On 22.08.2017 22:47, Vladimir Davydov wrote: > On Tue, Aug 22, 2017 at 03:29:35PM +0300, Kirill Tkhai wrote: >> During the reclaiming slab of a memcg, shrink_slab iterates >> over all registered shrinkers in the system, and tries to count >> and consume objects related to the cgroup. In case of memory >> pressure, this behaves bad: I observe high system time and >> time spent in list_lru_count_one() for many processes on RHEL7 >> kernel (collected via $perf record --call-graph fp -j k -a): >> >> 0,50% nixstatsagent [kernel.vmlinux] [k] _raw_spin_lock [k] _raw_spin_lock >> 0,26% nixstatsagent [kernel.vmlinux] [k] shrink_slab [k] shrink_slab >> 0,23% nixstatsagent [kernel.vmlinux] [k] super_cache_count [k] super_cache_count >> 0,15% nixstatsagent [kernel.vmlinux] [k] __list_lru_count_one.isra.2 [k] _raw_spin_lock >> 0,15% nixstatsagent [kernel.vmlinux] [k] list_lru_count_one [k] __list_lru_count_one.isra.2 >> >> 0,94% mysqld [kernel.vmlinux] [k] _raw_spin_lock [k] _raw_spin_lock >> 0,57% mysqld [kernel.vmlinux] [k] shrink_slab [k] shrink_slab >> 0,51% mysqld [kernel.vmlinux] [k] super_cache_count [k] super_cache_count >> 0,32% mysqld [kernel.vmlinux] [k] __list_lru_count_one.isra.2 [k] _raw_spin_lock >> 0,32% mysqld [kernel.vmlinux] [k] list_lru_count_one [k] __list_lru_count_one.isra.2 >> >> 0,73% sshd [kernel.vmlinux] [k] _raw_spin_lock [k] _raw_spin_lock >> 0,35% sshd [kernel.vmlinux] [k] shrink_slab [k] shrink_slab >> 0,32% sshd [kernel.vmlinux] [k] super_cache_count [k] super_cache_count >> 0,21% sshd [kernel.vmlinux] [k] __list_lru_count_one.isra.2 [k] _raw_spin_lock >> 0,21% sshd [kernel.vmlinux] [k] list_lru_count_one [k] __list_lru_count_one.isra.2 > > It would be nice to see how this is improved by this patch. > Can you try to record the traces on the vanilla kernel with > and without this patch? Sadly, the talk is about a production node, and it's impossible to use vanila kernel there. >> >> This patch aims to make super_cache_count() more effective. It >> makes __list_lru_count_one() count nr_items lockless to minimize >> overhead introducing by locking operation, and to make parallel >> reclaims more scalable. >> >> The lock won't be taken on shrinker::count_objects(), >> it would be taken only for the real shrink by the thread, >> who realizes it. >> > >> https://jira.sw.ru/browse/PSBM-69296 > > Not relevant. >