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 D6E04C433EF for ; Wed, 8 Dec 2021 00:40:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4885B6B0072; Tue, 7 Dec 2021 19:40:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4367E6B0073; Tue, 7 Dec 2021 19:40:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2B0256B0074; Tue, 7 Dec 2021 19:40:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0243.hostedemail.com [216.40.44.243]) by kanga.kvack.org (Postfix) with ESMTP id 1963A6B0072 for ; Tue, 7 Dec 2021 19:40:49 -0500 (EST) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id D05F08248D52 for ; Wed, 8 Dec 2021 00:40:38 +0000 (UTC) X-FDA: 78892771356.20.C285459 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf05.hostedemail.com (Postfix) with ESMTP id 3F317100006 for ; Wed, 8 Dec 2021 00:40:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1638924037; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=I5eY0me2wOSy2UVkmg3afLHAZnrnZAUcXyHGjuGOesc=; b=hhcNL0kr4o0J+wt7+2dGL9J2pndkTFTYvGEjYhLITS0T4gMmdcRAor8n9vdX/vOxXon6qo EpiUl/3f4guz76SyxcZWICZCVIroQdd0gfjrLiZk1Ugaw7onSdmEp4fW0wnanriPFGK50T 5XTX1i8ZBplfRFCnNS9k8OLIa8/o2jU= Received: from mail-il1-f199.google.com (mail-il1-f199.google.com [209.85.166.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-260-pt41V8fmP4SSbfvXgZB3Uw-1; Tue, 07 Dec 2021 19:40:36 -0500 X-MC-Unique: pt41V8fmP4SSbfvXgZB3Uw-1 Received: by mail-il1-f199.google.com with SMTP id j1-20020a056e02154100b002a181a1ce89so1026397ilu.10 for ; Tue, 07 Dec 2021 16:40:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=I5eY0me2wOSy2UVkmg3afLHAZnrnZAUcXyHGjuGOesc=; b=tjTMNkK74Y5KhNGTMLAn9auqL6PDna0qWtEBD9E6BdNM7SOUHE0EGDTBqqHoGwA+9J tk0wHkWOP7LLmwb8TWw71mfA3x35hCpdr9avtXoXSn+x1E3FUp2R6P1HxBKMVooKCu/6 pHrsWAeAvnZ7u8kYfafr0AYe6ekxwKJdFqtZHSxtYFBciIEpbQzKRvd/5lEXYB0s+S/X 7o5puTY6TapKZpthFUv26SDpZ6VlAfnchAETJqtk/5uW4hB+JTOhRla/izSV5dMtKrXJ cQQy2bcLHyg0A6t8gQm6uA3rJmF3sevhvyOoTmxW+yH+XehkUbSEgS42gNgXs8HgTaSi K+Vw== X-Gm-Message-State: AOAM5329QmH8yTM2KjGa0F6yB/6GE9GHyIDy24GXZnz5hDVUh+i/D3J5 38aPVnZEX9Az+dgx6Y2aYRASHuPY+EG0zFf3kD4Wy/JHATOmJ7oCsKc5na43IxbwHS+WPFR2I65 IMgOp9iipEek= X-Received: by 2002:a05:6638:2512:: with SMTP id v18mr53173322jat.22.1638924035641; Tue, 07 Dec 2021 16:40:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJwjIKfcGrLuNYNhWA+x0K0f3bghJsRqm7e/4zb9+yPA9WYo7XgEUAmx9G3AFdnuu/7SxsdU4Q== X-Received: by 2002:a05:6638:2512:: with SMTP id v18mr53173290jat.22.1638924035075; Tue, 07 Dec 2021 16:40:35 -0800 (PST) Received: from ?IPV6:2601:280:4400:a2e0:7336:512c:930d:4f0e? ([2601:280:4400:a2e0:7336:512c:930d:4f0e]) by smtp.gmail.com with ESMTPSA id b6sm819791ilq.18.2021.12.07.16.40.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 07 Dec 2021 16:40:34 -0800 (PST) Message-ID: <4c4b4db2-27b9-6001-5bae-ccc500695b42@redhat.com> Date: Tue, 7 Dec 2021 19:40:33 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 Subject: Re: [PATCH v2 1/1] mm/vmscan.c: Prevent allocating shrinker_info on offlined nodes To: Andrew Morton 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 References: <20211207224013.880775-1-npache@redhat.com> <20211207224013.880775-2-npache@redhat.com> <20211207154438.c1e49a3f0b5ebc9245aac61b@linux-foundation.org> From: Nico Pache In-Reply-To: <20211207154438.c1e49a3f0b5ebc9245aac61b@linux-foundation.org> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=hhcNL0kr; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf05.hostedemail.com: domain of npache@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=npache@redhat.com X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 3F317100006 X-Stat-Signature: 5zn99txjcad83bh3h5n8yh1ucpq5yjid X-HE-Tag: 1638924038-892228 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 12/7/21 18:44, 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). Thanks for the review! I took your changes below into consideration for my V3. My knowledge of offlined/onlined nodes is quite limited but after looking into it it doesnt seem like anything clears the state of NODE_DATA(nid) after a try_offline_node is attempted. So theoretically the panic we saw would not happen. What is the expected behavior of trying to allocate a page on a offline node? > > 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? >