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=-9.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 CE77AC433DF for ; Wed, 19 Aug 2020 18:00:37 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 95F0A20674 for ; Wed, 19 Aug 2020 18:00:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="banZQlRD" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 95F0A20674 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 212348D0056; Wed, 19 Aug 2020 14:00:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1C0868D0002; Wed, 19 Aug 2020 14:00:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F2CE28D0057; Wed, 19 Aug 2020 14:00:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0156.hostedemail.com [216.40.44.156]) by kanga.kvack.org (Postfix) with ESMTP id D0BFC8D0056 for ; Wed, 19 Aug 2020 14:00:34 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 86F60181AC9BF for ; Wed, 19 Aug 2020 18:00:34 +0000 (UTC) X-FDA: 77168083188.29.cap72_3d108532702a Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin29.hostedemail.com (Postfix) with ESMTP id 0799A18086E4A for ; Wed, 19 Aug 2020 18:00:29 +0000 (UTC) X-HE-Tag: cap72_3d108532702a X-Filterd-Recvd-Size: 5955 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by imf29.hostedemail.com (Postfix) with ESMTP for ; Wed, 19 Aug 2020 18:00:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1597860027; 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=bTXMJdhZBiz5u+OdXZ8G7mp+us1mE5cHXQvWaF7Ctms=; b=banZQlRDZVm6Fnyi7KuWZM1swZmnaM+utiA+M63nTm26oWFC47gaemTvSNPTmgfPmleVZA utqFq4p5SNMHTg7pqsGDzikljEso00yxl7YHA34HBCEGcp77YaMdkIhTzBwnBAFJRhkSsC bFhTfLkYe/xf0TCVC5gSsa7n9ieuCts= 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-448-87jVByZNPiWTGCSPHgxHhA-1; Wed, 19 Aug 2020 14:00:23 -0400 X-MC-Unique: 87jVByZNPiWTGCSPHgxHhA-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 569C2186A562; Wed, 19 Aug 2020 18:00:22 +0000 (UTC) Received: from t480s.redhat.com (ovpn-114-11.ams2.redhat.com [10.36.114.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id A765110013C4; Wed, 19 Aug 2020 18:00:17 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Michal Hocko , Andrew Morton , Wei Yang , Baoquan He , Pankaj Gupta , Oscar Salvador Subject: [PATCH v2 07/10] mm/memory_hotplug: simplify page onlining Date: Wed, 19 Aug 2020 19:59:54 +0200 Message-Id: <20200819175957.28465-8-david@redhat.com> In-Reply-To: <20200819175957.28465-1-david@redhat.com> References: <20200819175957.28465-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Rspamd-Queue-Id: 0799A18086E4A X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 Content-Transfer-Encoding: quoted-printable 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: We don't allow to offline memory with holes, all boot memory is online, and all hotplugged memory cannot have holes. We can now simplify onlining of pages. As we only allow to online/offline full sections and sections always span full MAX_ORDER_NR_PAGES, we can ju= st process MAX_ORDER - 1 pages without further special handling. The number of onlined pages simply corresponds to the number of pages we were requested to online. While at it, refine the comment regarding the callback not exposing all pages to the buddy. Acked-by: Michal Hocko Cc: Andrew Morton Cc: Michal Hocko Cc: Wei Yang Cc: Baoquan He Cc: Pankaj Gupta Cc: Oscar Salvador Signed-off-by: David Hildenbrand --- mm/memory_hotplug.c | 38 ++++++++++---------------------------- 1 file changed, 10 insertions(+), 28 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 0011a1115381c..3aba0d956f9b1 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -617,31 +617,22 @@ void generic_online_page(struct page *page, unsigne= d int order) } EXPORT_SYMBOL_GPL(generic_online_page); =20 -static int online_pages_range(unsigned long start_pfn, unsigned long nr_= pages, - void *arg) +static void online_pages_range(unsigned long start_pfn, unsigned long nr= _pages) { const unsigned long end_pfn =3D start_pfn + nr_pages; unsigned long pfn; - int order; =20 /* - * Online the pages. The callback might decide to keep some pages - * PG_reserved (to add them to the buddy later), but we still account - * them as being online/belonging to this zone ("present"). + * Online the pages in MAX_ORDER - 1 aligned chunks. The callback might + * decide to not expose all pages to the buddy (e.g., expose them + * later). We account all pages as being online and belonging to this + * zone ("present"). */ - for (pfn =3D start_pfn; pfn < end_pfn; pfn +=3D 1ul << order) { - order =3D min(MAX_ORDER - 1, get_order(PFN_PHYS(end_pfn - pfn))); - /* __free_pages_core() wants pfns to be aligned to the order */ - if (WARN_ON_ONCE(!IS_ALIGNED(pfn, 1ul << order))) - order =3D 0; - (*online_page_callback)(pfn_to_page(pfn), order); - } + for (pfn =3D start_pfn; pfn < end_pfn; pfn +=3D MAX_ORDER_NR_PAGES) + (*online_page_callback)(pfn_to_page(pfn), MAX_ORDER - 1); =20 /* mark all involved sections as online */ online_mem_sections(start_pfn, end_pfn); - - *(unsigned long *)arg +=3D nr_pages; - return 0; } =20 /* check which state of node_states will be changed when online memory *= / @@ -795,7 +786,6 @@ int __ref online_pages(unsigned long pfn, unsigned lo= ng nr_pages, int online_type, int nid) { unsigned long flags; - unsigned long onlined_pages =3D 0; struct zone *zone; int need_zonelists_rebuild =3D 0; int ret; @@ -831,19 +821,11 @@ int __ref online_pages(unsigned long pfn, unsigned = long nr_pages, setup_zone_pageset(zone); } =20 - ret =3D walk_system_ram_range(pfn, nr_pages, &onlined_pages, - online_pages_range); - if (ret) { - /* not a single memory resource was applicable */ - if (need_zonelists_rebuild) - zone_pcp_reset(zone); - goto failed_addition; - } - - zone->present_pages +=3D onlined_pages; + online_pages_range(pfn, nr_pages); + zone->present_pages +=3D nr_pages; =20 pgdat_resize_lock(zone->zone_pgdat, &flags); - zone->zone_pgdat->node_present_pages +=3D onlined_pages; + zone->zone_pgdat->node_present_pages +=3D nr_pages; pgdat_resize_unlock(zone->zone_pgdat, &flags); =20 /* --=20 2.26.2