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 C03BFC433F5 for ; Wed, 8 Dec 2021 01:24:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E18BC6B0071; Tue, 7 Dec 2021 20:24:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DC7D36B0073; Tue, 7 Dec 2021 20:24:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C68AC6B0074; Tue, 7 Dec 2021 20:24:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0074.hostedemail.com [216.40.44.74]) by kanga.kvack.org (Postfix) with ESMTP id B73096B0071 for ; Tue, 7 Dec 2021 20:24:21 -0500 (EST) Received: from smtpin31.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 6ED5B181951DB for ; Wed, 8 Dec 2021 01:24:11 +0000 (UTC) X-FDA: 78892881102.31.A11239C Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) by imf31.hostedemail.com (Postfix) with ESMTP id 2DBD61046301 for ; Wed, 8 Dec 2021 01:24:11 +0000 (UTC) Received: by mail-ed1-f49.google.com with SMTP id x15so2976067edv.1 for ; Tue, 07 Dec 2021 17:24:10 -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=0xXQ8Z+aD37LV2ze3gAG6ixrya9vcE7/RlnSGWDE+C4=; b=KdqVRucWbgoRDwGAdXwrJam4dyvOrrXi22Z8iEJANkxDzxIZFpiO7xdmt6f4035yE6 4y38ieaIw62a1gRJPbnlRgv8frB7584T5MyNqD1BUUhdleEr4M/x4gsruq1kg85I7t5L Jj6UnbPgU5VZkIdxi83jDd3vhxg4/ye6mxFtaj+fxujqA6fLdJECFu20OBl7sAYa7K1P WNpR4XpQe/94liJim3TQ5m5MdtwWBl+AJzLu8KKOyiGlAqxVzi8yEld3TUcUYjxToV9v tchKSX9i5WmCfNKIEpI7XF9Ds7ejkjANttd0Osw5+W38ufIwAvx8aVi3I2RuFeH0Gx2N b52A== 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=0xXQ8Z+aD37LV2ze3gAG6ixrya9vcE7/RlnSGWDE+C4=; b=Opnln+Dj2zI5plwdr0RL/LancuWs1WpEn2ezZQmBJjX02agQ6a1d5GogMqC/sHFB7U LxHsYWQYDLTo6kANla3ictMla5a2tDw0bySr3EaRp3MTDbRKdAVL8tNIFvoFJJviKsSY t95fs6ZkRUdq4eUZdym//DqzkHtqfiGFTYuwaN2xq+9yo44MW3sOSoXiLrNpV7RAPi4D kea0YLwia/XUOOwOwMGlrPevMrKhX92dgMwwFZStr2F1d/5uPFfwNS6B+yNWyhOyRbW1 JdHXCpyMuRVQNc9q3W0YkQ2PGhlPCst+pJDI8jFJ3oraUaaIMe3RyUO4RXN8ufSoOcrR On8Q== X-Gm-Message-State: AOAM5334fUnvy4NmMgasoOF2KFOIRUX18BhRyrryBpw34C9QGeScmghI CT7TmIhFqqa53odfz17mhOvWRgIOAF8k38Y7HRo= X-Google-Smtp-Source: ABdhPJwz1tcfy+ztYvdslkEPv5S1d3kB2gZn44d4gMIXu3emj/ER2xK6DwrZ9m2zNEp+QDgC9H7h0A+1opeGFjOOXhA= X-Received: by 2002:a17:907:1b17:: with SMTP id mp23mr3453588ejc.521.1638926649838; Tue, 07 Dec 2021 17:24:09 -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: <17a7d9e4-5ebc-1160-1e5e-97707b6e5286@redhat.com> From: Yang Shi Date: Tue, 7 Dec 2021 17:23:57 -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" X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 2DBD61046301 X-Stat-Signature: ywkcf9qxs93jnxu4uskj4j5nnzw1xjs8 Authentication-Results: imf31.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=KdqVRucW; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf31.hostedemail.com: domain of shy828301@gmail.com designates 209.85.208.49 as permitted sender) smtp.mailfrom=shy828301@gmail.com X-HE-Tag: 1638926651-709440 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 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 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? > > >