Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp969138ybl; Wed, 14 Aug 2019 08:42:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqxzU9MTtNvfGAuDjrzIsDpiAGlVcpSLGhn/cTTPIxM4w6G/a9uGrxuXWZrzKn630LOfwOYP X-Received: by 2002:a62:5487:: with SMTP id i129mr576767pfb.69.1565797342627; Wed, 14 Aug 2019 08:42:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565797342; cv=none; d=google.com; s=arc-20160816; b=u1eJAndG9mnWvrYNdvPCHVs1DpomiTNUbwcSyJqV2dqqDzTJFEDv5tBQir9SQp2Pvb UExEoC7r3Eau1lfA78M1yY74dBFFHOv92Kg9M7kmvupIZisEDGjwiECLDTxDP4hBerk0 GDrYod5N0YSN/ioYFNl+Y9af2+Fgd8uOHSw+QsyEeRKa1ieFhsl+63W01U8xzeeAp4AO jJYo8NyicPYxPm6iHU+jOWejmDe/v6RuaOtJuv8JhrsQFpKVPsDBOD5AaA/CiutC/2GJ 43XzFV8npYgiXl5x1EOX3G35j7uHvsWWQxtEEmu/Bs/zLBgnmHIPyTh/84dhwNx3LmSi VZsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=k0kOxYSmc304yJQc2hLDkAO/q1/lLExrjIUj/JVKCZk=; b=QbBPC4d1DHN3pD0s1eFZkWaEOPMCFsjNbrxSD1A8TBgY3KiSSLtUyuMNfFopV0ykII oivw5Bv2RjTHGCpf3wEgiuJC26xamlSlQdEsoaCRcifAoMhwr8dCc2kkcSOmHU+fkyWV raX93GicpJbpwcvjTjzoGO+qe7mfJjEPzPcDnzXk5YSiaSlzJZ7MUKSSIOSoKLkINgXQ NpH0RweVZ82ZmwfyELeZ8I/85A4LOqEcGduOxBSR8g8CR5sKoqIulHsC22EcYWOIjEhT G7plgmR+whzvyVydaofv+fmHPbeTayVxpmKehbUce/MLT3T4vhnzMucrdU9c1W6EmARB UV7Q== ARC-Authentication-Results: i=1; mx.google.com; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v24si42396pgk.509.2019.08.14.08.42.06; Wed, 14 Aug 2019 08:42:22 -0700 (PDT) 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; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728169AbfHNPlZ (ORCPT + 99 others); Wed, 14 Aug 2019 11:41:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34010 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727791AbfHNPlW (ORCPT ); Wed, 14 Aug 2019 11:41:22 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 506C13CA0D; Wed, 14 Aug 2019 15:41:22 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-49.ams2.redhat.com [10.36.116.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id A660880A27; Wed, 14 Aug 2019 15:41:20 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , Oscar Salvador , Michal Hocko , Pavel Tatashin , Dan Williams Subject: [PATCH v2 3/5] mm/memory_hotplug: Simplify online_pages_range() Date: Wed, 14 Aug 2019 17:41:07 +0200 Message-Id: <20190814154109.3448-4-david@redhat.com> In-Reply-To: <20190814154109.3448-1-david@redhat.com> References: <20190814154109.3448-1-david@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 14 Aug 2019 15:41:22 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org online_pages always corresponds to nr_pages. Simplify the code, getting rid of online_pages_blocks(). Add some comments. Cc: Andrew Morton Cc: Oscar Salvador Cc: Michal Hocko Cc: Pavel Tatashin Cc: Dan Williams Signed-off-by: David Hildenbrand --- mm/memory_hotplug.c | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 10ad970f3f14..63b1775f7cf8 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -632,31 +632,27 @@ static void generic_online_page(struct page *page, unsigned int order) #endif } -static int online_pages_blocks(unsigned long start, unsigned long nr_pages) -{ - unsigned long end = start + nr_pages; - int order, onlined_pages = 0; - - while (start < end) { - order = min(MAX_ORDER - 1, - get_order(PFN_PHYS(end) - PFN_PHYS(start))); - (*online_page_callback)(pfn_to_page(start), order); - - onlined_pages += (1UL << order); - start += (1UL << order); - } - return onlined_pages; -} - static int online_pages_range(unsigned long start_pfn, unsigned long nr_pages, void *arg) { - unsigned long onlined_pages = *(unsigned long *)arg; + const unsigned long end_pfn = start_pfn + nr_pages; + unsigned long pfn; + int order; + + /* + * 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"). + */ + for (pfn = start_pfn; pfn < end_pfn; pfn += 1ul << order) { + order = min(MAX_ORDER - 1, get_order(PFN_PHYS(end_pfn - pfn))); + (*online_page_callback)(pfn_to_page(pfn), order); + } - onlined_pages += online_pages_blocks(start_pfn, nr_pages); - online_mem_sections(start_pfn, start_pfn + nr_pages); + /* mark all involved sections as online */ + online_mem_sections(start_pfn, end_pfn); - *(unsigned long *)arg = onlined_pages; + *(unsigned long *)arg += nr_pages; return 0; } -- 2.21.0