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 20ABAC433EF for ; Tue, 7 Dec 2021 23:45:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 732EC6B0072; Tue, 7 Dec 2021 18:44:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6ECD96B0073; Tue, 7 Dec 2021 18:44:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5A9AB6B0074; Tue, 7 Dec 2021 18:44:56 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0251.hostedemail.com [216.40.44.251]) by kanga.kvack.org (Postfix) with ESMTP id 485F86B0072 for ; Tue, 7 Dec 2021 18:44:56 -0500 (EST) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id F02501839449F for ; Tue, 7 Dec 2021 23:44:45 +0000 (UTC) X-FDA: 78892630572.28.96A1227 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf10.hostedemail.com (Postfix) with ESMTP id 597536001988 for ; Tue, 7 Dec 2021 23:44:45 +0000 (UTC) Received: from mail.kernel.org (unknown [198.145.29.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 7E9DACE1ECA; Tue, 7 Dec 2021 23:44:42 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 5D4C660E98; Tue, 7 Dec 2021 23:44:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1638920680; bh=BEwEUCLZRSg2aVfAnY3W95UfGY4Oj5ctvBxKSFO7qgc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=iYskK9Zu/idmCtyqe71iiLRVLganSC9yWh7Xeb/20f5UDuoW3vHTjkwx6Pu8oH7bm diddNxpbzyHanek/5Cyc4Jsyk0Qpu5ZExDIl16LGSpHg6lG1uhmJvwipx9cqAOmIj0 1DopsKnJNabNwgBfaLWocXqyUrzT7szk+qVxT5Ho= Date: Tue, 7 Dec 2021 15:44:38 -0800 From: Andrew Morton To: Nico Pache Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, shakeelb@google.com, ktkhai@virtuozzo.com, shy828301@gmail.com, guro@fb.com, vbabka@suse.cz, vdavydov.dev@gmail.com, raquini@redhat.com, mhocko@suse.com, david@redhat.com Subject: Re: [PATCH v2 1/1] mm/vmscan.c: Prevent allocating shrinker_info on offlined nodes Message-Id: <20211207154438.c1e49a3f0b5ebc9245aac61b@linux-foundation.org> In-Reply-To: <20211207224013.880775-2-npache@redhat.com> References: <20211207224013.880775-1-npache@redhat.com> <20211207224013.880775-2-npache@redhat.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 597536001988 X-Stat-Signature: 3au355kgsfw1xn96393rj4tu8isuxi1d Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=iYskK9Zu; dmarc=none; spf=pass (imf10.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org X-HE-Tag: 1638920685-135015 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, 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? > --- 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?