Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2901412pxb; Tue, 12 Jan 2021 01:06:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJyRTyc6fHroth+ZXPiPxjHNefrNTMXhizLdSISgPzxtt5BqoZtHKAIpTGohxW/y0QYZfcdk X-Received: by 2002:a17:906:4bc5:: with SMTP id x5mr2538771ejv.55.1610442374033; Tue, 12 Jan 2021 01:06:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610442374; cv=none; d=google.com; s=arc-20160816; b=nsjig9DPtMkYYtlHF0Gzzw5cIJQqPOYMkN63oHS3di755FAdEy0QNyWAL3K0qGIrhe I2Nhiw+1A9DhFs974sG3lmFqrsdpXME8RaVH68FVLDTPpyrNQ7Y5EMAZ/V5BeE7Py2sL 4+8xVjBb2tXkP/N23VyxM1byOo7wbAuRuN9HD/rMuoMKCzdo6ktxLdhzn+0TyXpfBiOb t7kPcGf06RkGNX+hamC5Qr7TPkczddN+6kZ9pXJXyV0i1GLC7YO/r51ufqUmAfRxO4iR qp9JIm/JrsCwhYsUW3S8n9quVhk0+ivE0cro19FfmJXy8ivxKawezm4tO6MA9qT/Bxxy RuHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:references:cc :to:subject:from; bh=8O8DFSDTD3QKV6tIEdYjInZ8FkDzBX8Ap9JLXfmEP+c=; b=gmBPreU3YWP3GnD5+r21hXvPFs3VRFt0iwDWQJfSTJx71iFC4CL0LcCYzjEoycvVc6 EghasFofdYO3zPra1zv+v9YezA7HGnfVd4o7gP1lvRODGVnnDFYBeKD3MdNSebbJOSRh Vi1QqkStN3Z6/ZRdq7m6UvWHF+YLnYnIg0c0XHjmlef+i+nCVNOhHad7WVJvfGGwzzbT hkQUeCKB47KsmUBUE2HeuyaKf0fpEjjUixsFyV0YxxVnzBuYDtC40BaP59pxnXmc/Bcu Cgp3xxF1+1Lrw/EE4fcS7NQm3qCTWTf41IBN1iHyPsFwmAdA8vK/8b3Ew6VfjtPoyU8L m17w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y25si832670ejb.595.2021.01.12.01.05.50; Tue, 12 Jan 2021 01:06:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389493AbhAKR4J (ORCPT + 99 others); Mon, 11 Jan 2021 12:56:09 -0500 Received: from mx2.suse.de ([195.135.220.15]:40940 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727658AbhAKR4I (ORCPT ); Mon, 11 Jan 2021 12:56:08 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 10C21AB3E; Mon, 11 Jan 2021 17:55:27 +0000 (UTC) From: Vlastimil Babka Subject: Re: [RFC 0/3] mm, slab, slub: remove cpu and memory hotplug locks To: Christoph Lameter Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Pekka Enberg , David Rientjes , Joonsoo Kim , Vladimir Davydov , Qian Cai , David Hildenbrand , Michal Hocko References: <20210106174029.12654-1-vbabka@suse.cz> Message-ID: <91f48b11-b6ff-39ab-947e-341920771e0f@suse.cz> Date: Mon, 11 Jan 2021 18:55:26 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/6/21 8:09 PM, Christoph Lameter wrote: > On Wed, 6 Jan 2021, Vlastimil Babka wrote: > >> rather accept some wasted memory in scenarios that should be rare anyway (full >> memory hot remove), as we do the same in other contexts already. It's all RFC >> for now, as I might have missed some reason why it's not safe. > > Looks good to me. My only concern is the kernel that has hotplug disabled. > Current code allows the online/offline checks to be optimized away. > > Can this patch be enhanced to do the same? Thanks, indeed I didn't think about that. But on closer inspection, there doesn't seem to be need for such enhancement: - Patch 1 adds the new slab_nodes nodemask, which is basically a copy of N_NORMAL_MEMORY. Without memory hotplug, the callbacks that would update it don't occur (maybe are even eliminated as dead code?), other code that uses the nodemask is unaffected wtf performance, it's just using a different nodemask for the same operations. The extra memory usage of adding the nodemask is negligible and not worth complicating the code to distinguish between the new nodemask and N_NORMAL_MEMORY depending on hotplug being disabled or enabled. - Patch 1 also restores slab_mutex lock in kmem_cache_shrink(). Commit 03afc0e25f7f removed it because the memory hotplug lock was deemed to be sufficient replacement, but probably didn't consider the case where hotplug is disabled and thus the hotplug lock is no-op. Maybe it's safe not to take slab_mutex in kmem_cache_shrink() in that case, but kmem_cache_shrink() is only called from a sysfs handler, thus a very cold path anyway. But, I found out that lockdep complains about it, so I have to rethink this part anyway... (when kmem_cache_shrink() is called from write to the 'shrink' file we already have kernfs lock "kn->active#28" and try to lock slab_mutex, but there's existing dependency in reverse order where in kmem_cache_create() we start with slab_mutex and sysfs_slab_add takes the kernfs lock, I wonder how this wasn't a problem before 03afc0e25f7f) - Patch 2 purely just removes calls to cpu hotplug lock. - Patch 3 only affects memory hotplug callbacks so nothing to enhance if hotplug is disabled