Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp135242ybf; Wed, 26 Feb 2020 10:10:41 -0800 (PST) X-Google-Smtp-Source: APXvYqxCYnRhg42sGgXxL1K5lsdOODsYCT7ZRktCxzR6d4USEy3Ewbr9y+s0jFArQGsGVXxNLqCA X-Received: by 2002:aca:cf12:: with SMTP id f18mr188488oig.81.1582740641258; Wed, 26 Feb 2020 10:10:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582740641; cv=none; d=google.com; s=arc-20160816; b=pR6FFxdruSBBDcIHDnLYUTJlfBKXdhFNZDnraxqciHrfdWR2iTvcJwEGEwCs35i2NB /OFNkG173vk571gFxNvgamML4hLuKIYAw+ApUkS1Fnomgrb8s5aNqx0ZEAFzQJr6ob3/ kqQqsKSIPBVrVcbQ9drPA38U/Il6sI2ytYLHlcjSEh0TMQSlW+OCinO64jd1ufTRAWRf Wx7mue1XHDXUzY4vJtNqtd6ZfaQyO4cP4LpDkm2m2dF62op9ZvTRWZoC9pkpwGYEfVW/ zdnz39wVwwosrdd/soXJdjuPrMX5RbX0Kpxxz372LWMamDftfznpWYFY4ULwa4+MaAF7 WPGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=e/1VSrHV/eL0yjS7JzLq6CkDS40xQ5EKyFULmMfEARM=; b=KYft3BoZUE2f+KH78GgbUz4dW9D9xhCTkrZuuUrC799bkkyY81T4+H4EGP70LmXW3E csydfkZ8V67oFdAV/yQxq/7KthiGckOTn5MFv/EbgDHXW78P0IU2nBVNMOZGWEhF/wyF 2WNrvacIFFFmIBV92d1Y0QKwQQdoqpWbUW5esyfdzvu5JVIyLh+d4jpBgJK2qq6Xs6RU YmhoVlbOFFsl3CJp+7G8EVEvfI+b0CZ/rkqsgwIeGTkekuimdVyyW8ISeag/U3lMub7e chIi0O1gpRbhvkblIWyoO3NFYN/m8QN21UpJBuvRfIxuiAaCdgo6EZmFJ6d00I/6FPp/ 3NJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=kyRX5Cn0; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s22si30575oij.35.2020.02.26.10.10.25; Wed, 26 Feb 2020 10:10:41 -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=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=kyRX5Cn0; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727282AbgBZSJ2 (ORCPT + 99 others); Wed, 26 Feb 2020 13:09:28 -0500 Received: from mail-ot1-f65.google.com ([209.85.210.65]:42207 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727222AbgBZSJ1 (ORCPT ); Wed, 26 Feb 2020 13:09:27 -0500 Received: by mail-ot1-f65.google.com with SMTP id 66so282813otd.9 for ; Wed, 26 Feb 2020 10:09:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=e/1VSrHV/eL0yjS7JzLq6CkDS40xQ5EKyFULmMfEARM=; b=kyRX5Cn0P/ON9gnA/ScfZ7oJkXAhWPXVLNx+beL35VdYa4shGdzN7u2FcFsUM++b2n lhoSm+twMkJopIMCGGM6P0DGpCliQXivQ8UpJyka/vhLBPkgOCPJDP/s+V9fbFyvQJE4 xo6pmVrTBkETwSWsQy8QMmWmUnhGOxr9bgYfeRj/XsqigRK7XQJDhsIPziELekou41N9 iN+TTGLkjTU4S70vyvb2VpcHy6jjx9Ds4AIgYEFIvD1CR50wVHkNf6Y2mEJ4MK+nNgCT RdvdyuO737GSlyOH6abS0gvyNKu+23jdoYyLCrOrolzytxlbMhwTO1Sy6CanmAKvf9UB Zcog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=e/1VSrHV/eL0yjS7JzLq6CkDS40xQ5EKyFULmMfEARM=; b=Xow3GD1iSGTezGJX1d8s/JL29QWsMZeMxR1Uytck56SC877/2GNIgoVzarODs67fdw VTsPRc6ua2xspCYyKD7BxvJFFII6yMgHvjLfm00BN4GZhLW3BkpnoqugrW79ORhnNsT7 pcXkNhwwJhuMEOGx4abz5FQ/PJMwJXKm6aZ3jna4lVSpreinpD2kbUm35PZB/NBEwZyp F/E1SNVcMaC3ryoXnL9QL4zrWD3KJUDC3K5JFCOzhOulXBA49o65GwBDLccmygmzcOoN yhQHhczHOhIinJ5Qbmf/1BUR/8ZoH+FfpPV5gcXS9visztrkVpZxrpu3+18iVLVEe61M vl9w== X-Gm-Message-State: APjAAAVEfNdkYZ4KUPQPuAoOAUXGCDM0hSevSFxkwBshb+wyPwu5cq+T Rm9IClKmuhPWhucE8i0Rtyw8geEmCDRBrv1U0CwOWg== X-Received: by 2002:a9d:7852:: with SMTP id c18mr3941574otm.247.1582740565960; Wed, 26 Feb 2020 10:09:25 -0800 (PST) MIME-Version: 1.0 References: <20200220043316.19668-1-bhe@redhat.com> <20200220043316.19668-2-bhe@redhat.com> In-Reply-To: <20200220043316.19668-2-bhe@redhat.com> From: Dan Williams Date: Wed, 26 Feb 2020 10:09:15 -0800 Message-ID: Subject: Re: [PATCH v2 1/7] mm/hotplug: fix hot remove failure in SPARSEMEM|!VMEMMAP case To: Baoquan He Cc: Linux Kernel Mailing List , Linux MM , Andrew Morton , Wei Yang , David Hildenbrand , Oscar Salvador , Michal Hocko , Mike Rapoport , Robin Murphy Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 19, 2020 at 8:34 PM Baoquan He wrote: > > 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: > > 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 move 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 596b2a45b100..b8e52c8fed7f 100644 > --- a/mm/sparse.c > +++ b/mm/sparse.c > @@ -779,13 +779,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 (bitmap_empty(subsection_map, SUBSECTIONS_PER_SECTION)) > + ms->section_mem_map = (unsigned long)NULL; Looks good to me: Reviewed-by: Dan Williams