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 B98E1C433F5 for ; Wed, 8 Dec 2021 00:34:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 10CFD6B0072; Tue, 7 Dec 2021 19:33:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0BC4F6B0073; Tue, 7 Dec 2021 19:33:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E50AB6B0074; Tue, 7 Dec 2021 19:33:55 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0191.hostedemail.com [216.40.44.191]) by kanga.kvack.org (Postfix) with ESMTP id 6F3446B0072 for ; Tue, 7 Dec 2021 19:33:55 -0500 (EST) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 312AA1810613C for ; Wed, 8 Dec 2021 00:33:45 +0000 (UTC) X-FDA: 78892754010.08.9F80A16 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf26.hostedemail.com (Postfix) with ESMTP id 93E8120019C3 for ; Wed, 8 Dec 2021 00:33:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1638923624; 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=4wPqjo5XnKnLRGHjp53e4CWVRbk9N6dPooNDByxfzhI=; b=iOd71W4pYC6aPL2CPdvVK8mzUuhEPT6P+Btk7rdLaRtjXS19EGzS9x0oM/bXdFAee2NR10 djkvOkrx67rClJ1KjawFbrQkCwPh2J6GH16NPc9Q0Fhl+ttwXtLBbpMP7X+6p6OG+U1xz4 6JXiq54R3Md8QIGKLkXcS5KHwUyP8mg= 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-102-0DcUVr0xMsWGUFGXFVcXAA-1; Tue, 07 Dec 2021 19:33:43 -0500 X-MC-Unique: 0DcUVr0xMsWGUFGXFVcXAA-1 Received: by mail-il1-f199.google.com with SMTP id g14-20020a056e021e0e00b002a26cb56bd4so1006463ila.14 for ; Tue, 07 Dec 2021 16:33:43 -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=4wPqjo5XnKnLRGHjp53e4CWVRbk9N6dPooNDByxfzhI=; b=MXkoLYt5S7OIVcatH+8wdOQ3dhRxtE81z/tAOhDvTF3lr6nobYiCTk+EOyIuX3NQ0C OJfjZJJGjdCKYJfVZ9XGNrO23IgPjU6ZK3DoboNWZujYhOHlRvcfhq6GKncHMuwszfay ebv9XyLuedc3QW5wHzTQ5Ta8veIUXdOXzQeoluhbdLsjVEmeau9fPdNuR8ZbVbfIFP28 gWOffxo4RM67MYNNRzPv2xzk9jyJc+AeqnJ5MoVGXCLSBmJQs/gE0hJBEQw7hLcfMAeA TdFdYhl+P+LFcZT1PKwL7r/EBuSSYn0wLiPU2t5uJ+EFCZ1cKXp+L/fqYEJjlzNNQ1f0 qppg== X-Gm-Message-State: AOAM532CiyzGAemRhYKVtmpf06AaMWKIKpBuAD3DSNwH9qFflrdvkJqO cYoMvwpDrl66a9fWM7n6pwyuzVUW8dTYDwxLjYt//JIugrAVZDmI6cM/KmhzAwPNu1fk88j/ZWy Hpeki51tQfKI= X-Received: by 2002:a05:6e02:484:: with SMTP id b4mr2939556ils.173.1638923622388; Tue, 07 Dec 2021 16:33:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJzcpNBLoUE/608YuXdOGh8G2GYTZmVBtYT2FsOK4t+yc2CNgx6W/E8uV39KrC43r4IQoU1Wsg== X-Received: by 2002:a05:6e02:484:: with SMTP id b4mr2939530ils.173.1638923622148; Tue, 07 Dec 2021 16:33:42 -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 k13sm1191994iow.45.2021.12.07.16.33.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 07 Dec 2021 16:33:41 -0800 (PST) Message-ID: <17a7d9e4-5ebc-1160-1e5e-97707b6e5286@redhat.com> Date: Tue, 7 Dec 2021 19:33:40 -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: Yang Shi , Andrew Morton Cc: Linux Kernel Mailing List , Linux MM , Shakeel Butt , Kirill Tkhai , Roman Gushchin , Vlastimil Babka , Vladimir Davydov , raquini@redhat.com, Michal Hocko , David Hildenbrand References: <20211207224013.880775-1-npache@redhat.com> <20211207224013.880775-2-npache@redhat.com> <20211207154438.c1e49a3f0b5ebc9245aac61b@linux-foundation.org> From: Nico Pache In-Reply-To: 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: imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=iOd71W4p; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf26.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: 93E8120019C3 X-Stat-Signature: y5z894ajnzywf5qcmzynidw4k8fhgsz6 X-HE-Tag: 1638923624-160017 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 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. > 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? >