Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp999419ybl; Wed, 14 Aug 2019 09:09:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqxuaGM4lnlnjhhBt21/I+r+gsQ3RKTv3WgBKTQL4+fu3BnA6k/+7MgxOFGHFGBZABRI3e0N X-Received: by 2002:a17:90a:35e3:: with SMTP id r90mr519737pjb.34.1565798978579; Wed, 14 Aug 2019 09:09:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565798978; cv=none; d=google.com; s=arc-20160816; b=IMT7bie/yfelBV8/wb3S1fB4WzVtVqcZ+ySKdyUyfppi4jO17HyTbAKsyI8kKpA64Q zz2n/PRFZljg9i5IGfHagHQpVXniwYeHcqvKCng9JE4cDZOsdTu64r9jI3XXybxdUWmn l+3NPz2wQ5qOULQu9Q/xIKlpyFiLdn0vimVI7VO6PTz2c0Z9HONg8Fqxkf5Bzw0awDsN xeAcQC8ptyBySwft5DJ5j8YoqWEyMHUw0eATN8fgNF8RQ+rfU2JSbfC9TDEktyZTulSW FFpHobob5o6oipJOxUi+NlVk6YioPp8KYKS4syh3hL12J0Q/0j0MMFbieMO9QocJ3oeS w2NQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=08CZm3wGNzdgqMYbFfuRKOZSY7fsbiUaNMstwNYM8XM=; b=I0BpYJ9LL9XElz3EFxZpQ/z2X1VtVN3C2zWX0zdKMw4y/BtOrUO0wbd3zAND8EI0mD LYG0Kt9AB8C9dvMRNsiRF1P/CGqWSclR6iv6fXvE6F8Ih/35Ey110OUZOzoFSXBqr+kK /Z+vYo76l0h9TQJJYTX1LShoB7zIblbTKq6Al/T5Dl677/LqRcSxHCvWNRDw+hwmsjYt oTLQciHRKKhqjndFbicwSE4sr0Mq+2eaR7QvkfEvgd9ytZuq3pr17Andy/64+J7+zZuu BLe63wCSAM8xpxzK0y5paEjvUYNtxJGIzB1ct1LebEAi0wjefj/fbTAvB6YMVWFkk6vT MdEQ== 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a8si69754225pfc.176.2019.08.14.09.09.22; Wed, 14 Aug 2019 09:09:38 -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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728334AbfHNQHy (ORCPT + 99 others); Wed, 14 Aug 2019 12:07:54 -0400 Received: from mx2.suse.de ([195.135.220.15]:37950 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726047AbfHNQHy (ORCPT ); Wed, 14 Aug 2019 12:07:54 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 61C21AB92; Wed, 14 Aug 2019 16:07:53 +0000 (UTC) Date: Wed, 14 Aug 2019 18:07:51 +0200 From: Michal Hocko To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Andrew Morton , Oscar Salvador , Pavel Tatashin , Dan Williams Subject: Re: [PATCH v2 3/5] mm/memory_hotplug: Simplify online_pages_range() Message-ID: <20190814160751.GI17933@dhcp22.suse.cz> References: <20190814154109.3448-1-david@redhat.com> <20190814154109.3448-4-david@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190814154109.3448-4-david@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 14-08-19 17:41:07, David Hildenbrand wrote: > 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 Acked-by: Michal Hocko Thanks! > --- > 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 > -- Michal Hocko SUSE Labs