Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp4038283pxb; Mon, 27 Sep 2021 08:08:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJygNuVtWa6TqVj1e5pXJ3OZmQ3CkY7iUL/3zIFLm/fWkMzd1mRSfzqAtckEBigfhvLUULqn X-Received: by 2002:a62:3102:0:b0:44b:63db:fc88 with SMTP id x2-20020a623102000000b0044b63dbfc88mr462931pfx.75.1632755290107; Mon, 27 Sep 2021 08:08:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632755290; cv=none; d=google.com; s=arc-20160816; b=ZBZq8XRPOce7BtQ6E2CBJHzB+CpKxWI1HTyVRb6WZx/dBuiumZ3HYITnmquA1CVs7Y dMuHJZ9QMV4h2GyUVunsKuqPl23HyYJ5p2jsV7cUh3nLgubmoJfw6EZYyOZWkky3Q3iN zrHaRuP5Gf4eNtitDMU7559N4AQBd1FGl6HWVHTtTeGsK+i7AaU7gS73HnXdTjJw31uu e2FOXIdntMnWLaIE3HP2arcJ+OskouJU1Lmkv+Ll77Jh9kc89araYusHJGTDnKPfrAoh h816q5/FpN6m+nXsA1iCNgy49JdF5K05N8TN2BTokv+yv1+J/vAMDrsgqxpNIAAmHP/L ZIlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=76mZg+E3RG88YQfrtX8VX08A90LrtCPW8/rlR6y2h7s=; b=SSiIKhRCkUeXhAZrIsUriPMnsawg4//Hb/VhzxJll5xPQvPFD6KbeKA8tOJHu/6HNL mRn1dat4vW7KA+XzRl7LwWvUWvORMl7FM5LtVrIemjf4XcKPoPUXaQVGuwqCbLmRe88h 158SVo+R1ZN3GaAVa2LdQJ8cmB9VDtzNXVjyPhj2FnJ7SpcQJNL7dbpuXzK1t1Nb0Yrl xJ3L0FI40KWkwBUFIB2qFf+m2bq6GsTkrOeC1mwK9RWVKSXlDoA/6DVYDvKkISqeFw4y iGm2290pY7Ps8eHZNPQPcluuyLyB+HBF5DJRh4cXvFTxX9IES6XGQ+QLaT9n53kenvxt 6l0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=brnaidzZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w13si20927085pjc.153.2021.09.27.08.07.57; Mon, 27 Sep 2021 08:08:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=brnaidzZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234832AbhI0PH0 (ORCPT + 99 others); Mon, 27 Sep 2021 11:07:26 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:41414 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235018AbhI0PHY (ORCPT ); Mon, 27 Sep 2021 11:07:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632755146; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=76mZg+E3RG88YQfrtX8VX08A90LrtCPW8/rlR6y2h7s=; b=brnaidzZ7Uh2AskYE65E5fbsj+fqmnHKSAgwNPp2r8NL4PzUjlA6/JaYquzHGDC4RTc82p zWacTjFFjRSlaAimRz2lcPQiZnlQoFii1zXIp+N1LROg9ypaNvpnGX4aknSDwsNe1fhmmm CmxZg0dObAAWWgpsE5R8JVMaz9Aco0E= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-510-UR-QvHE9NJ2R30KJjIlaVA-1; Mon, 27 Sep 2021 11:05:44 -0400 X-MC-Unique: UR-QvHE9NJ2R30KJjIlaVA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 87DA21015208; Mon, 27 Sep 2021 15:05:41 +0000 (UTC) Received: from t480s.redhat.com (unknown [10.39.193.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id E2FE160C7F; Mon, 27 Sep 2021 15:05:36 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: David Hildenbrand , Andrew Morton , Mike Rapoport , Michal Hocko , Oscar Salvador , Jianyong Wu , "Aneesh Kumar K . V" , Vineet Gupta , Geert Uytterhoeven , Huacai Chen , Jiaxun Yang , Thomas Bogendoerfer , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Eric Biederman , Arnd Bergmann , linux-snps-arc@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-s390@vger.kernel.org, linux-mm@kvack.org, kexec@lists.infradead.org Subject: [PATCH v1 1/4] mm/memory_hotplug: handle memblock_add_node() failures in add_memory_resource() Date: Mon, 27 Sep 2021 17:05:15 +0200 Message-Id: <20210927150518.8607-2-david@redhat.com> In-Reply-To: <20210927150518.8607-1-david@redhat.com> References: <20210927150518.8607-1-david@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If memblock_add_node() fails, we're most probably running out of memory. While this is unlikely to happen, it can happen and having memory added without a memblock can be problematic for architectures that use memblock to detect valid memory. Let's fail in a nice way instead of silently ignoring the error. Signed-off-by: David Hildenbrand --- mm/memory_hotplug.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 9fd0be32a281..917b3528636d 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1384,8 +1384,11 @@ int __ref add_memory_resource(int nid, struct resource *res, mhp_t mhp_flags) mem_hotplug_begin(); - if (IS_ENABLED(CONFIG_ARCH_KEEP_MEMBLOCK)) - memblock_add_node(start, size, nid); + if (IS_ENABLED(CONFIG_ARCH_KEEP_MEMBLOCK)) { + ret = memblock_add_node(start, size, nid); + if (ret) + goto error_mem_hotplug_end; + } ret = __try_online_node(nid, false); if (ret < 0) @@ -1458,6 +1461,7 @@ int __ref add_memory_resource(int nid, struct resource *res, mhp_t mhp_flags) rollback_node_hotadd(nid); if (IS_ENABLED(CONFIG_ARCH_KEEP_MEMBLOCK)) memblock_remove(start, size); +error_mem_hotplug_end: mem_hotplug_done(); return ret; } -- 2.31.1