From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A62FAC433FE for ; Mon, 6 Dec 2021 18:43:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 035F26B007B; Mon, 6 Dec 2021 13:43:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EFE976B007D; Mon, 6 Dec 2021 13:43:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D77646B007E; Mon, 6 Dec 2021 13:43:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0068.hostedemail.com [216.40.44.68]) by kanga.kvack.org (Postfix) with ESMTP id C2E4C6B007B for ; Mon, 6 Dec 2021 13:43:10 -0500 (EST) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 7DF398249980 for ; Mon, 6 Dec 2021 18:43:00 +0000 (UTC) X-FDA: 78888241320.22.C8B7AA5 Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.52]) by imf18.hostedemail.com (Postfix) with ESMTP id 1F882400208D for ; Mon, 6 Dec 2021 18:42:59 +0000 (UTC) Received: by mail-ed1-f52.google.com with SMTP id v1so46952733edx.2 for ; Mon, 06 Dec 2021 10:42:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=PUDt5s3yuSBQveVT1cZ1FoCgWl/bAqtAkIA9KkAetDM=; b=C80Rp8/K+bnXHiPfRxJQ2mTYHjKtvNQ10cnhRZ35QUWgxWI9N9ZDI5QSjQuh57Gs0m pWco7+93KyLC2lir/jwKaCzLea/mtUGnmJNDmB6hv69dP2saKYTPdYNlAMg+TVuJgfkx mht3PZFhid69rCWdZ+7JJkU211eaEIUyuwHBVvB6bwSs14fMR1Aem/ecWaDndjMFgtRz jAIRy8fYM4eoAFTXcbT+4X5nRKkjudpYozY2N0+yygjfEbLiVivsUCqau9D1GWyfqPkM QJkA5qdwYgbs6yFmtgbIHuuQNdlsYMytmsTDq5e90/E8+jFPOfAnkHwiWUAdk2UJba0O ScQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=PUDt5s3yuSBQveVT1cZ1FoCgWl/bAqtAkIA9KkAetDM=; b=fxT254cnL1p7sKbRGZ8xtpz4U3rF+zB89RvYYptgkZosHxcwSoZdGK7n7ijeLe2DYt UlZ1lg7VFhfNLcsLdR5GG+0F/Ek9Jo68wehNRysNid+/aBv3LHeS4BuQgTzD6tOnkAhR g9SugnFg4yUVtIQ5dKQP2h0dOZy0SxqWoyrTcApvCW11FLwUpWDv2+VsJ8ha0kgObaF7 5c9YrnY7GXNeUOzc6rCPWzG9fPP7+QoJ4PvZ3s2Ygpe9hBPXGhvGzvAyY1f0ibR8c3yg WqGThjGc1kyXsPpT7CWo85etGFLckwCcozDEuvLgCvg+9uWNo83TCnqpHQ//gtHIsZrH EL3A== X-Gm-Message-State: AOAM5308WeK7tKK3H4vdow8Zwzgni5zKlkvB8FyGXAQwsbf9HkXtDDxU FevSGMRTzywRdmS0u3tTj954aNGMhXosAwEImq0= X-Google-Smtp-Source: ABdhPJx7A/zcKRpwWEX7JqrJh6F7F6b/HCnn7W2yCUL4Uu0NagdU+gAY5vTIY4ymivNRS6hJU6ZxUdG/5TfNadP+P7Y= X-Received: by 2002:a50:c38c:: with SMTP id h12mr1337733edf.72.1638816178961; Mon, 06 Dec 2021 10:42:58 -0800 (PST) MIME-Version: 1.0 References: <20211206033338.743270-1-npache@redhat.com> <20211206033338.743270-3-npache@redhat.com> <24b4455c-aff9-ca9f-e29f-350833e7a0d1@virtuozzo.com> In-Reply-To: <24b4455c-aff9-ca9f-e29f-350833e7a0d1@virtuozzo.com> From: Yang Shi Date: Mon, 6 Dec 2021 10:42:47 -0800 Message-ID: Subject: Re: [RFC PATCH 2/2] mm/vmscan.c: Prevent allocating shrinker_info on offlined nodes To: Kirill Tkhai Cc: David Hildenbrand , Michal Hocko , Nico Pache , Linux Kernel Mailing List , Linux MM , Andrew Morton , Shakeel Butt , Roman Gushchin , Vlastimil Babka , Vladimir Davydov , raquini@redhat.com Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 1F882400208D X-Stat-Signature: 534phc8sbmbwdyr84cj646io7pz81wj4 Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="C80Rp8/K"; spf=pass (imf18.hostedemail.com: domain of shy828301@gmail.com designates 209.85.208.52 as permitted sender) smtp.mailfrom=shy828301@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-HE-Tag: 1638816179-849294 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, Dec 6, 2021 at 5:19 AM Kirill Tkhai wrote: > > On 06.12.2021 13:45, David Hildenbrand wrote: > >> This doesn't seen complete. Slab shrinkers are used in the reclaim > >> context. Previously offline nodes could be onlined later and this would > >> lead to NULL ptr because there is no hook to allocate new shrinker > >> infos. This would be also really impractical because this would have to > >> update all existing memcgs... > > > > Instead of going through the trouble of updating... > > > > ... maybe just keep for_each_node() and check if the target node is > > offline. If it's offline, just allocate from the first online node. > > After all, we're not using __GFP_THISNODE, so there are no guarantees > > either way ... > > Hm, can't we add shrinker maps allocation to __try_online_node() in addition > to this patch? I think the below fix (an example, doesn't cover all affected callsites) should be good enough for now? It doesn't touch the hot path of the page allocator. diff --git a/mm/vmscan.c b/mm/vmscan.c index fb9584641ac7..1252a33f7c28 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -222,13 +222,15 @@ static int expand_one_shrinker_info(struct mem_cgroup *memcg, int size = map_size + defer_size; for_each_node(nid) { + int tmp = nid; pn = memcg->nodeinfo[nid]; old = shrinker_info_protected(memcg, nid); /* Not yet online memcg */ if (!old) return 0; - - new = kvmalloc_node(sizeof(*new) + size, GFP_KERNEL, nid); + if (!node_online(nid)) + tmp = -1; + new = kvmalloc_node(sizeof(*new) + size, GFP_KERNEL, tmp); if (!new) return -ENOMEM; It used to use kvmalloc instead of kvmalloc_node(). The commit 86daf94efb11d7319fbef5e480018c4807add6ef ("mm/memcontrol.c: allocate shrinker_map on appropriate NUMA node") changed to use *_node() version. The justification was that "kswapd is always bound to specific node. So allocate shrinker_map from the related NUMA node to respect its NUMA locality." There is no kswapd for offlined node, so just allocate shrinker info on node 0. This is also what alloc_mem_cgroup_per_node_info() does. Making memcg per node data node allocation memory hotplug aware should be solved in a separate patchset IMHO.