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 3605AC7619F for ; Mon, 17 Feb 2020 11:21:10 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E230D2070B for ; Mon, 17 Feb 2020 11:21:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="JF34M/HQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E230D2070B 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 721216B0005; Mon, 17 Feb 2020 06:21:09 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6D1D26B0006; Mon, 17 Feb 2020 06:21:09 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5E6916B0007; Mon, 17 Feb 2020 06:21:09 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0094.hostedemail.com [216.40.44.94]) by kanga.kvack.org (Postfix) with ESMTP id 441C86B0005 for ; Mon, 17 Feb 2020 06:21:09 -0500 (EST) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id EE1944417 for ; Mon, 17 Feb 2020 11:21:08 +0000 (UTC) X-FDA: 76499377416.14.goat98_4422d873a5b47 X-HE-Tag: goat98_4422d873a5b47 X-Filterd-Recvd-Size: 6604 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by imf03.hostedemail.com (Postfix) with ESMTP for ; Mon, 17 Feb 2020 11:21:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581938467; 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=5XVYC36ln0D4ujIhywDAzkRVYoE9aLV+kGZeJnFwoIs=; b=JF34M/HQzwifwUqNKmaC9X0Jg6CukztSojrKT2n/2XTGJ0hgi3EPDrv6o3nDDMB69pViFf 7T5hYQTRXxcNLRfIumFvQ//KOnNU6yn6Bum968nNywiJaxiymg7VpKv7aElfU/Bo1To38N TI4qXXIGoOhifMoYvyokSs704tDTbjQ= 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-351-nAp9tY2tMXKiPMsB6hZyEg-1; Mon, 17 Feb 2020 06:21:03 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 992DB801E72; Mon, 17 Feb 2020 11:21:01 +0000 (UTC) Received: from localhost (ovpn-12-200.pek2.redhat.com [10.72.12.200]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9923419757; Mon, 17 Feb 2020 11:20:57 +0000 (UTC) Date: Mon, 17 Feb 2020 19:20:54 +0800 From: Baoquan He To: David Hildenbrand Cc: kkabe@vega.pgw.jp, Oscar Salvador , 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: <20200217112054.GA9823@MiWiFi-R3L-srv> References: <20200212073123.GG8965@MiWiFi-R3L-srv> <200217144627.M0113305@vega.pgw.jp> <20200217093447.GA1139@linux> <20200217101318.GL26758@MiWiFi-R3L-srv> <383e5dbf-b402-575d-8dae-5e92b51e9834@redhat.com> <20200217103347.GM26758@MiWiFi-R3L-srv> MIME-Version: 1.0 In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: nAp9tY2tMXKiPMsB6hZyEg-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 11:38am, David Hildenbrand wrote: > On 17.02.20 11:33, Baoquan He wrote: > > On 02/17/20 at 11:24am, David Hildenbrand wrote: > >> On 17.02.20 11:13, 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_P= ER_SECTION; > >>>>> > >>>>> page =3D alloc_pages(GFP_KERNEL|__GFP_NOWARN, get_order(mem= map_size)); > >>>>> if (page) { > >>>>> goto got_map_page; > >>>>> } > >>>>> pr_info("%s: alloc_pages() returned 0x%p (should be 0), reverting t= o vmalloc(memmap_size=3D%lu)\n", __func__, page, memmap_size); > >>>>> BUG_ON(page !=3D 0); > >>>>> > >>>>> ret =3D vmalloc(memmap_size); > >>>>> pr_info("%s: vmalloc(%lu) returned 0x%p\n", __func__, memmap_size, = ret); > >>>>> if (ret) { > >>>>> goto got_map_ptr; > >>>>> } > >>>>> > >>>>> 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: > >>>>> > >>>>> pr_info("%s: returning struct page * =3D0x%p\n", __func__, ret); > >>>>> return ret; > >>>>> } > >>>> > >>>> Could you please replace %p with %px. Wih the first, pointers are ha= shed so it is trickier > >>>> to get an overview of the meaning. > >>>> > >>>> David could be right about ZONE_NORMAL vs ZONE_HIGHMEM. > >>>> IIUC, default_kernel_zone_for_pfn and default_zone_for_pfn seem to o= nly deal with > >>>> (ZONE_DMA,ZONE_NORMAL] or ZONE_MOVABLE. > >>> > >>> 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 in= to > >>> 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 access= ed > >>> with kmap. However, the later hot added memory are all put into norma= l > >>> memmory, accessing into them will stump into vmalloc area, I would sa= y. > >>> =20 > >>> So, i386 doesn't support memory hot add well. Not sure if below chan= ge > >>> can make it work normally. > >>> =20 Please try below code instead, see if it works. However, as David and and Michal said in other reply, if no real use case, we may not be so eager to support mem hotplug on i386.=20 diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 475d0d68a32c..9faf47bd026e 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -715,15 +715,20 @@ static struct zone *default_kernel_zone_for_pfn(int n= id, unsigned long start_pfn { =09struct pglist_data *pgdat =3D NODE_DATA(nid); =09int zid; +=09enum zone_type default_zone =3D ZONE_NORMAL; =20 -=09for (zid =3D 0; zid <=3D ZONE_NORMAL; zid++) { +#ifdef CONFIG_HIGHMEM +=09default_zone =3D ZONE_HIGHMEM; +#endif + +=09for (zid =3D 0; zid <=3D default_zone; zid++) { =09=09struct zone *zone =3D &pgdat->node_zones[zid]; =20 =09=09if (zone_intersects(zone, start_pfn, nr_pages)) =09=09=09return zone; =09} =20 -=09return &pgdat->node_zones[ZONE_NORMAL]; +=09return &pgdat->node_zones[default_zone]; } =20 static inline struct zone *default_zone_for_pfn(int nid, unsigned long sta= rt_pfn,