Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4782948ybl; Tue, 4 Feb 2020 01:48:12 -0800 (PST) X-Google-Smtp-Source: APXvYqx5bzYeCj9eivozCOCpI6IBBX770R7c2zdRCFruDx71unWk9HDrHV8mvfETVP8D5vre3IZv X-Received: by 2002:a9d:6a4f:: with SMTP id h15mr21733189otn.86.1580809692014; Tue, 04 Feb 2020 01:48:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580809692; cv=none; d=google.com; s=arc-20160816; b=AmGYr1CnUBqGA7IJZ+M2WepcUreRYJHGrqPtl3eBwU5TswqqvKxacTsFlTNNugzpVF wpbrX7A4X3A5AeyWExzxasOXfl1qlP6tieiY0sSNoPg9qASw0vqejFlyaQhdGWZMXgTn 2YLOoHAHRA9ChniUpT94/X+3ElRLc6gU6vCgoGMd2S+2MhQHPy0POc1uhOZ87jywEkAo KTb/b/2DfjC68CNUxqgS9vIUT/1jrHFcaO+HO2eZtsNHVjR0nCZbk1BFMU0XkIkXT2gW gQlXvdAWieZ/AsaS9XH0H7ahPZypD0kDsgTXzkgxquTzfbCMxxrmxqiEX1NDY/HqYABE /Vqw== 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=fyGxvp4Ic9MSDFOf8tOxkvWIdiyocFAtpTy1njlSDpM=; b=Pz3blwsPmak+m5Bocazia7yiA0lsHSsUXqfriAzjGqtySKLIX4FRx3R4yr2t44iWPN YvIcSFMcLL6+c/qH+oG406R80n/5w6T+ZqYpBkwQ0Kr4SdslquAqEab3XqQYMPQ+lk4l wJvpMlJG0UDuJE1OKF8jC/r/VFXxZzM4mw3sJeqDAvvimds8BlT9yCN9MPSEBQtCE+yP P/ThbxkT05qeBXO+N7brLBrr5V5I7+vza7xf4OP2+BeBeboCIUl8nyHu3OuEAJTJxa08 48LdPs4v5FbMxC25i4+WB4vJgwaEJ04QyjSESA5i+ywwBjmD3bhHlmwArDCn6sbjlmm4 PFSA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e64si10607694oib.4.2020.02.04.01.48.00; Tue, 04 Feb 2020 01:48:12 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726992AbgBDJq6 (ORCPT + 99 others); Tue, 4 Feb 2020 04:46:58 -0500 Received: from mx2.suse.de ([195.135.220.15]:40210 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726329AbgBDJq6 (ORCPT ); Tue, 4 Feb 2020 04:46:58 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id BC651ABF4; Tue, 4 Feb 2020 09:46:55 +0000 (UTC) Date: Tue, 4 Feb 2020 10:46:53 +0100 From: Oscar Salvador To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, x86@kernel.org, Andrew Morton , Michal Hocko , Pavel Tatashin , Dan Williams , Wei Yang Subject: Re: [PATCH v6 10/10] mm/memory_hotplug: Cleanup __remove_pages() Message-ID: <20200204094652.GE6494@linux> References: <20191006085646.5768-1-david@redhat.com> <20191006085646.5768-11-david@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191006085646.5768-11-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 Sun, Oct 06, 2019 at 10:56:46AM +0200, David Hildenbrand wrote: > Let's drop the basically unused section stuff and simplify. > > Also, let's use a shorter variant to calculate the number of pages to > the next section boundary. > > Cc: Andrew Morton > Cc: Oscar Salvador > Cc: Michal Hocko > Cc: Pavel Tatashin > Cc: Dan Williams > Cc: Wei Yang > Signed-off-by: David Hildenbrand I have to confess that it took me while to wrap around my head with the new min() change, but looks ok: Reviewed-by: Oscar Salvador > --- > mm/memory_hotplug.c | 17 ++++++----------- > 1 file changed, 6 insertions(+), 11 deletions(-) > > diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c > index 843481bd507d..2275240cfa10 100644 > --- a/mm/memory_hotplug.c > +++ b/mm/memory_hotplug.c > @@ -490,25 +490,20 @@ static void __remove_section(unsigned long pfn, unsigned long nr_pages, > void __remove_pages(unsigned long pfn, unsigned long nr_pages, > struct vmem_altmap *altmap) > { > + const unsigned long end_pfn = pfn + nr_pages; > + unsigned long cur_nr_pages; > unsigned long map_offset = 0; > - unsigned long nr, start_sec, end_sec; > > map_offset = vmem_altmap_offset(altmap); > > if (check_pfn_span(pfn, nr_pages, "remove")) > return; > > - start_sec = pfn_to_section_nr(pfn); > - end_sec = pfn_to_section_nr(pfn + nr_pages - 1); > - for (nr = start_sec; nr <= end_sec; nr++) { > - unsigned long pfns; > - > + for (; pfn < end_pfn; pfn += cur_nr_pages) { > cond_resched(); > - pfns = min(nr_pages, PAGES_PER_SECTION > - - (pfn & ~PAGE_SECTION_MASK)); > - __remove_section(pfn, pfns, map_offset, altmap); > - pfn += pfns; > - nr_pages -= pfns; > + /* Select all remaining pages up to the next section boundary */ > + cur_nr_pages = min(end_pfn - pfn, -(pfn | PAGE_SECTION_MASK)); > + __remove_section(pfn, cur_nr_pages, map_offset, altmap); > map_offset = 0; > } > } > -- > 2.21.0 > > -- Oscar Salvador SUSE L3