Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2591229ybv; Sun, 9 Feb 2020 02:52:33 -0800 (PST) X-Google-Smtp-Source: APXvYqxVqzZA0Blb8hlQQ5WaAim6yilRWsvcreobKL93x1I0LfmuCfHpwl7X5gDWVDQqSg2TNKRL X-Received: by 2002:a9d:1928:: with SMTP id j40mr6484409ota.68.1581245552987; Sun, 09 Feb 2020 02:52:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581245552; cv=none; d=google.com; s=arc-20160816; b=m0aaJ0XJYorvTzFA1p6B5LzNPXHPcp8V+FQzlismRukJ2K+PFcF0Eix+s5bRKe0bWR 7+FfuV47V/H3R7dKk0CzmaLO4Kw9WDk+IpXZ0qGhEnS3b3m0kbxA2GDfDCt89Szdbdjg uOvyTavB+uS3sbgEppAM6k49kB9RzRlN0XEbeq9ehCZJcUNa/nZX1sw9IQ8jO9Lv+3b4 DRxfJg0UrCWfY5MgygylC/N3Xz7lGSV0FC0ihvEpXSl+aUWk4t7fD9tBGOwxgAtECQYp vcAe7huLTN/6qDO2LaOEfqnWFqKzCxlzqFV+aIh8Ujuz0wCXJyJvXJ1C9VGTcJq5ukQR 4PXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=z6n+AuP+O2svMC+qLOpajdzRjteK4YpkRxZlBgrn3yM=; b=DUo5EDNYy1hwRAcda5wZljJILyEdofkpoz1yNN+IeB23B7Pytot73gwLu1CHP0IHlP HuSMVk7kHbBbps+aC2LcxYFdy8ppWNUrZL+UfvfgxxHVuIUfSiKzlTarSqBXB3i0vkMX 5z+Zaj4khTbzdSBXJ+7iZm9K0soiHtK9MAJnnYWxoCWQ5D/722Jt/0QKJdHp+4Kg637U tb3zTiEiTgqWJnwQn1jhcjLLfkN8XwvorZ4gFDuJ/lClUiWQ46wFCr6c/ERrA20TPIc4 W5yW1WN4QtJmc4q8tLxFwCTiHB/Qwnol4IiQ5XXCPsBuevULXBUV6/KBGgA4VybBCiOh 7psw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JCrrvn5W; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id t77si6659777oie.146.2020.02.09.02.52.22; Sun, 09 Feb 2020 02:52:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JCrrvn5W; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727804AbgBIKtH (ORCPT + 99 others); Sun, 9 Feb 2020 05:49:07 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:47836 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727800AbgBIKtG (ORCPT ); Sun, 9 Feb 2020 05:49:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581245345; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=z6n+AuP+O2svMC+qLOpajdzRjteK4YpkRxZlBgrn3yM=; b=JCrrvn5Wfq47/mk4yJUUIP04ep1hhvftSVkQLxjquJzJC/eyfnM/hcEyHD0IaabKsMnYnR 8+s2cnVPflRJFb45BoIeQNA741BTtU76nt8JDHTNeVhvRhKc8rG5Pwrj2BIRDjQJOaEcVS 4M/Fy2XY7RS9vsQNUcSd8FUrb8/8J/M= 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-223-6lR6WDWaM16ElUdnDR3Lyg-1; Sun, 09 Feb 2020 05:49:01 -0500 X-MC-Unique: 6lR6WDWaM16ElUdnDR3Lyg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8E8BE184AEA0; Sun, 9 Feb 2020 10:49:00 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-31.pek2.redhat.com [10.72.12.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id BC73010013A7; Sun, 9 Feb 2020 10:48:56 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, dan.j.williams@intel.com, richardw.yang@linux.intel.com, david@redhat.com, bhe@redhat.com Subject: [PATCH 7/7] mm/hotplug: fix hot remove failure in SPARSEMEM|!VMEMMAP case Date: Sun, 9 Feb 2020 18:48:26 +0800 Message-Id: <20200209104826.3385-8-bhe@redhat.com> In-Reply-To: <20200209104826.3385-1-bhe@redhat.com> References: <20200209104826.3385-1-bhe@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In section_deactivate(), pfn_to_page() doesn't work any more after ms->section_mem_map is resetting to NULL in SPARSEMEM|!VMEMMAP case. It caused hot remove failure, the trace is: kernel BUG at mm/page_alloc.c:4806! invalid opcode: 0000 [#1] SMP PTI CPU: 3 PID: 8 Comm: kworker/u16:0 Tainted: G W 5.5.0-next-20200205+ #340 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 0.0.0 02/06/2015 Workqueue: kacpi_hotplug acpi_hotplug_work_fn RIP: 0010:free_pages+0x85/0xa0 Call Trace: __remove_pages+0x99/0xc0 arch_remove_memory+0x23/0x4d try_remove_memory+0xc8/0x130 ? walk_memory_blocks+0x72/0xa0 __remove_memory+0xa/0x11 acpi_memory_device_remove+0x72/0x100 acpi_bus_trim+0x55/0x90 acpi_device_hotplug+0x2eb/0x3d0 acpi_hotplug_work_fn+0x1a/0x30 process_one_work+0x1a7/0x370 worker_thread+0x30/0x380 ? flush_rcu_work+0x30/0x30 kthread+0x112/0x130 ? kthread_create_on_node+0x60/0x60 ret_from_fork+0x35/0x40 Let's defer the ->section_mem_map resetting after depopulate_section_memmap() to fix it. Signed-off-by: Baoquan He --- mm/sparse.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mm/sparse.c b/mm/sparse.c index 623755e88255..345d065ef6ce 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -854,13 +854,15 @@ static void section_deactivate(unsigned long pfn, unsigned long nr_pages, ms->usage = NULL; } memmap = sparse_decode_mem_map(ms->section_mem_map, section_nr); - ms->section_mem_map = (unsigned long)NULL; } if (section_is_early && memmap) free_map_bootmem(memmap); else depopulate_section_memmap(pfn, nr_pages, altmap); + + if(!rc) + ms->section_mem_map = (unsigned long)NULL; } static struct page * __meminit section_activate(int nid, unsigned long pfn, -- 2.17.2