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 X-Spam-Level: X-Spam-Status: No, score=-5.4 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AACF3C3B185 for ; Mon, 17 Feb 2020 10:17:54 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6BEB920725 for ; Mon, 17 Feb 2020 10:17:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="eDgPhFLZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6BEB920725 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 0C06F6B0005; Mon, 17 Feb 2020 05:17:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 071E46B0006; Mon, 17 Feb 2020 05:17:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EA2206B0007; Mon, 17 Feb 2020 05:17:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0214.hostedemail.com [216.40.44.214]) by kanga.kvack.org (Postfix) with ESMTP id D19F76B0005 for ; Mon, 17 Feb 2020 05:17:53 -0500 (EST) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 622A18248047 for ; Mon, 17 Feb 2020 10:17:53 +0000 (UTC) X-FDA: 76499218026.10.birds36_61f15dda20c52 X-HE-Tag: birds36_61f15dda20c52 X-Filterd-Recvd-Size: 5877 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by imf40.hostedemail.com (Postfix) with ESMTP for ; Mon, 17 Feb 2020 10:17:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581934672; 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=EABVpc7Prihs3tHNq1AXi9RfyZ/wvzMknEikwSkRzPo=; b=eDgPhFLZHxauCKqBw7IOs3SKCc1MDQaj44R9mYen3xU0WdRFhX3AK1AU8l6nQnHTyEJLz8 Wi4nMj2e14Zamv2FR5PwXHWHHx2mzrrATl49r+dYTyfDX55nGsQT2GNbxW7690yvFmja5g b9wCRYTosJMiHxI3pseeeKx6og0z8Sw= 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-375-U-LDcLzhPnKUZNVx48JJ2g-1; Mon, 17 Feb 2020 05:17:50 -0500 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 8E90F1005513; Mon, 17 Feb 2020 10:17:47 +0000 (UTC) Received: from localhost (ovpn-12-200.pek2.redhat.com [10.72.12.200]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F416010013A1; Mon, 17 Feb 2020 10:17:44 +0000 (UTC) Date: Mon, 17 Feb 2020 18:17:41 +0800 From: Baoquan He To: david@redhat.com, kkabe@vega.pgw.jp, Oscar Salvador Cc: bugzilla-daemon@bugzilla.kernel.org, akpm@linux-foundation.org, richardw.yang@linux.intel.com, mhocko@kernel.org, n-horiguchi@ah.jp.nec.com, linux-mm@kvack.org Subject: Re: [Bug 206401] kernel panic on Hyper-V after 5 minutes due to memory hot-add Message-ID: <20200217101741.GC19207@MiWiFi-R3L-srv> References: <20200212073123.GG8965@MiWiFi-R3L-srv> <200217144627.M0113305@vega.pgw.jp> <20200217093447.GA1139@linux> <20200217101318.GL26758@MiWiFi-R3L-srv> MIME-Version: 1.0 In-Reply-To: <20200217101318.GL26758@MiWiFi-R3L-srv> User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: U-LDcLzhPnKUZNVx48JJ2g-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Content-Disposition: inline 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 02/17/20 at 06:13pm, Baoquan He wrote: > On 02/17/20 at 10:34am, Oscar Salvador wrote: > > On Mon, Feb 17, 2020 at 02:46:27PM +0900, kkabe@vega.pgw.jp wrote: > > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > > struct page * __meminit populate_section_memmap(unsigned long pfn, > > > unsigned long nr_pages, int nid, struct vmem_altmap *= altmap) > > > { > > > struct page *page, *ret; > > > unsigned long memmap_size =3D sizeof(struct page) * PAGES_PER= _SECTION; > > >=20 > > > page =3D alloc_pages(GFP_KERNEL|__GFP_NOWARN, get_order(memma= p_size)); > > > if (page) { > > > goto got_map_page; > > > } > > > pr_info("%s: alloc_pages() returned 0x%p (should be 0), reverting to = vmalloc(memmap_size=3D%lu)\n", __func__, page, memmap_size); > > > BUG_ON(page !=3D 0); > > >=20 > > > ret =3D vmalloc(memmap_size); > > > pr_info("%s: vmalloc(%lu) returned 0x%p\n", __func__, memmap_size, re= t); > > > if (ret) { > > > goto got_map_ptr; > > > } > > >=20 > > > return NULL; > > > got_map_page: > > > ret =3D (struct page *)pfn_to_kaddr(page_to_pfn(page)); > > > pr_info("%s: allocated struct page *page=3D0x%p\n", __func__, page); > > > got_map_ptr: > > >=20 > > > pr_info("%s: returning struct page * =3D0x%p\n", __func__, ret); > > > return ret; > > > } > >=20 > > Could you please replace %p with %px. Wih the first, pointers are hashe= d so it is trickier > > to get an overview of the meaning. > >=20 > > David could be right about ZONE_NORMAL vs ZONE_HIGHMEM. > > IIUC, default_kernel_zone_for_pfn and default_zone_for_pfn seem to only= deal with > > (ZONE_DMA,ZONE_NORMAL] or ZONE_MOVABLE. >=20 > Ah, I think you both have spotted the problem. > =20 > In i386, if w/o momory hot add, normal memory will only include those > below 896M and they are added into normal zone. The left are added into > highmem zone. > =20 > How this influence the page allocation? > =20 > Very huge. As we know, in i386, normal memory can be accessed with > virt_to_phys, namely PAGE_OFFSET + phys. But highmem has to be accessed Hmm, here I mean __pa and __va. > with kmap. However, the later hot added memory are all put into normal > memmory, accessing into them will stump into vmalloc area, I would say. > =20 > So, i386 doesn't support memory hot add well. Not sure if below change > can make it work normally. > =20 > We can just adjus the hot adding code as we have done for boot memmory. > Iterate zone from highmem if allowed when hot add memory. > =20 > diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c > index 475d0d68a32c..1380392d9ef5 100644 > --- a/mm/memory_hotplug.c > +++ b/mm/memory_hotplug.c > @@ -716,7 +716,10 @@ static struct zone *default_kernel_zone_for_pfn(int = nid, unsigned long start_pfn > =09struct pglist_data *pgdat =3D NODE_DATA(nid); > =09int zid; > =20 > -=09for (zid =3D 0; zid <=3D ZONE_NORMAL; zid++) { > +=09for (zid =3D 0; zid < MAX_NR_ZONES; zid++) { > +=09=09if (zid =3D=3D ZONE_MOVABLE) > +=09=09=09continue; > + > =09=09struct zone *zone =3D &pgdat->node_zones[zid]; > =20 > =09=09if (zone_intersects(zone, start_pfn, nr_pages)) >=20 >=20