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 12B8DC433EF for ; Wed, 8 Dec 2021 01:27:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 75F426B0071; Tue, 7 Dec 2021 20:26:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6E7AE6B0073; Tue, 7 Dec 2021 20:26:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 561C06B0074; Tue, 7 Dec 2021 20:26:56 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 415556B0071 for ; Tue, 7 Dec 2021 20:26:56 -0500 (EST) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id EF83F87CBC for ; Wed, 8 Dec 2021 01:26:45 +0000 (UTC) X-FDA: 78892887570.25.B7B9A1F Received: from mail-ed1-f44.google.com (mail-ed1-f44.google.com [209.85.208.44]) by imf25.hostedemail.com (Postfix) with ESMTP id A069BB000181 for ; Wed, 8 Dec 2021 01:26:45 +0000 (UTC) Received: by mail-ed1-f44.google.com with SMTP id x6so2922453edr.5 for ; Tue, 07 Dec 2021 17:26:45 -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=UhJ4UcLzq8BcFK+gzuERcPjWwXUL7IwpOkKpmgGdQW8=; b=j3CUCAS4OURie4o1zBZLLvnq9DOvnNvxs5enL68rI2toyO2fyZCY40H7s/8OnO3XIi dfSmbxfwqWHYm1+bG88OJhqtfRWpm10CJFp1+WEZDfY+q+gBHllCO7dbuhzH5oI8Cas3 aWKVtqwNjZ+GCqhs2DGkFPpiLM/UeEknRrNbXAgpXNBGbG7y5zf/4P7aczFNxQ2jAai0 ixzJXi8QNfKmri7QBUwXvUdVs+xTT/SsCXK1utainTV7vqaloh4GadavR81NCJmxPKxl kG0exhLVVEGU18ikyV/NQtiFBSRWhxgBSBDFIvD/MTcBzvFijudxgu+WFhnCE0mPqdDw OUYA== 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=UhJ4UcLzq8BcFK+gzuERcPjWwXUL7IwpOkKpmgGdQW8=; b=UBhQP1d2NxdXNFhDyInbz8qvFpoTUhU2HUMuJ+UofCzldwzu1wylNNwczg2zwH9v42 fXLaEvjl26/NC8S1z/yrKX7qgCO2NW2dlbCyADpTAgBj0NTf28UHyJD6BixtvLuK4LLH BMRffZjq552TrWmgafREejPvwKHJP/SORqL/0DoC5Pq9NWUon5WKStEwEcjN0rc9W+Fi LnWzyR8/cy/mndwMzfJLP1XEqIaxvjScQhoF3gjK4/Cy/OrgauemEVdK8jJI7yVBmkji LKS8ZxU3a0IHQzYGtWf2Yf7C4iM9jEFzq9qT8VJ4VMHq4c8KMIVreAuCU5yiDTHOZCPl nfUQ== X-Gm-Message-State: AOAM5336VhmTK5FzonzO5GnkmtxfZgir5LH3Q0EX+drrGi4kXX5c5FCf B3ex5Q94GiykmiJLFY9Ld/yvn7ylMRD62C49lKQ= X-Google-Smtp-Source: ABdhPJyPXcD60/YewvO1HLrGeJs0m6UgRqQp+o87fQpON7pCEIVaT1cbPKkiZw5ySSLGQVboEGu8SnDdwg9s3sQWCKo= X-Received: by 2002:a17:907:dab:: with SMTP id go43mr3523717ejc.537.1638926804347; Tue, 07 Dec 2021 17:26:44 -0800 (PST) MIME-Version: 1.0 References: <20211207224013.880775-1-npache@redhat.com> <20211207224013.880775-2-npache@redhat.com> <20211207154438.c1e49a3f0b5ebc9245aac61b@linux-foundation.org> <17a7d9e4-5ebc-1160-1e5e-97707b6e5286@redhat.com> In-Reply-To: From: Yang Shi Date: Tue, 7 Dec 2021 17:26:32 -0800 Message-ID: Subject: Re: [PATCH v2 1/1] mm/vmscan.c: Prevent allocating shrinker_info on offlined nodes To: Nico Pache Cc: Andrew Morton , Linux Kernel Mailing List , Linux MM , Shakeel Butt , Kirill Tkhai , Roman Gushchin , Vlastimil Babka , Vladimir Davydov , raquini@redhat.com, Michal Hocko , David Hildenbrand Content-Type: text/plain; charset="UTF-8" Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=j3CUCAS4; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf25.hostedemail.com: domain of shy828301@gmail.com designates 209.85.208.44 as permitted sender) smtp.mailfrom=shy828301@gmail.com X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: A069BB000181 X-Stat-Signature: pfq3ogdmtwpnpyxsdpz3qoomq536ejha X-HE-Tag: 1638926805-237503 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 Tue, Dec 7, 2021 at 5:23 PM Yang Shi wrote: > > On Tue, Dec 7, 2021 at 4:33 PM Nico Pache wrote: > > > > > > > > On 12/7/21 19:26, Yang Shi wrote: > > > On Tue, Dec 7, 2021 at 3:44 PM Andrew Morton wrote: > > >> > > >> On Tue, 7 Dec 2021 17:40:13 -0500 Nico Pache wrote: > > >> > > >>> We have run into a panic caused by a shrinker allocation being attempted > > >>> on an offlined node. > > >>> > > >>> Our crash analysis has determined that the issue originates from trying > > >>> to allocate pages on an offlined node in expand_one_shrinker_info. This > > >>> function makes the incorrect assumption that we can allocate on any node. > > >>> To correct this we make sure the node is online before tempting an > > >>> allocation. If it is not online choose the closest node. > > >> > > >> This isn't fully accurate, is it? We could allocate on a node which is > > >> presently offline but which was previously onlined, by testing > > >> NODE_DATA(nid). > > >> > > >> It isn't entirely clear to me from the v1 discussion why this approach > > >> isn't being taken? > > >> > > >> AFAICT the proposed patch is *already* taking this approach, by having > > >> no protection against a concurrent or subsequent node offlining? > > > > > > AFAICT, we have not reached agreement on how to fix it yet. I saw 3 > > > proposals at least: > > > > > > 1. From Michal, allocate node data for all possible nodes. > > > https://lore.kernel.org/all/Ya89aqij6nMwJrIZ@dhcp22.suse.cz/T/#u > > > > > > 2. What this patch does. Proposed originally from > > > https://lore.kernel.org/all/20211108202325.20304-1-amakhalov@vmware.com/T/#u > > > > Correct me if im wrong, but isn't that a different caller? This patch fixes the > > issue in expand_one_shrinker_info. > > Yes, different caller, but same approach. The cons with this approach And the same underlying problem. > is we have to fix all the places. It seems Michal and David are not > fans for this approach IIRC. > > > > > > 3. From David, fix in node_zonelist(). > > > https://lore.kernel.org/all/51c65635-1dae-6ba4-daf9-db9df0ec35d8@redhat.com/T/#u > > > > > >> > > >>> --- a/mm/vmscan.c > > >>> +++ b/mm/vmscan.c > > >>> @@ -222,13 +222,16 @@ static int expand_one_shrinker_info(struct mem_cgroup *memcg, > > >>> int size = map_size + defer_size; > > >>> > > >>> for_each_node(nid) { > > >>> + int tmp = nid; > > >> > > >> Not `tmp', please. Better to use an identifier which explains the > > >> variable's use. target_nid? > > >> > > >> And a newline after defining locals, please. > > >> > > >>> 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)) > > >> > > >> s/if(/if (/ > > >> > > >>> + tmp = numa_mem_id(); > > >>> + new = kvmalloc_node(sizeof(*new) + size, GFP_KERNEL, tmp); > > >>> if (!new) > > >>> return -ENOMEM; > > >>> > > >> > > >> And a code comment fully explaining what's going on here? > > > > >