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=-8.6 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable 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 E409BC43215 for ; Thu, 14 Nov 2019 19:40:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B7B1020724 for ; Thu, 14 Nov 2019 19:40:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573760450; bh=wRSk6zN4gGPIMefOaJzZohmA+Tnc0uZpsyfQcMnFKuk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=OoZpS0GfMTh8+18EWgTJ8E+Q2nl5sJlsPPgecE6sDweBuUWFijUumnAdyJ1nVI2rJ BLeTGxCQKSOt+6s+kqJBDtwYRlfxeM4rUYllsgrEpKER+lpesZn6+jw8IRfNeaUesn PKWPlWrD85rfoCyykaFChCfmd+QMHpaGJtVuDGew= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726991AbfKNTkt (ORCPT ); Thu, 14 Nov 2019 14:40:49 -0500 Received: from mx2.suse.de ([195.135.220.15]:58084 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726289AbfKNTkt (ORCPT ); Thu, 14 Nov 2019 14:40:49 -0500 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 34F55B2AF; Thu, 14 Nov 2019 19:40:46 +0000 (UTC) Date: Thu, 14 Nov 2019 20:40:44 +0100 From: Michal Hocko To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, Andrew Morton , Oscar Salvador , Anshuman Khandual , Qian Cai , Pingfan Liu , Stephen Rothwell , Dan Williams , Pavel Tatashin , Vlastimil Babka , Mel Gorman , Mike Rapoport , Wei Yang , Alexander Duyck , Alexander Potapenko , Arun KS , Michael Ellerman Subject: Re: [PATCH v2 2/2] mm: remove "count" parameter from has_unmovable_pages() Message-ID: <20191114194044.GC24848@dhcp22.suse.cz> References: <20191114131911.11783-1-david@redhat.com> <20191114131911.11783-3-david@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191114131911.11783-3-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 Thu 14-11-19 14:19:11, David Hildenbrand wrote: > Now that the memory isolate notifier is gone, the parameter is always 0. > Drop it and cleanup has_unmovable_pages(). > > Cc: Michal Hocko > Cc: Andrew Morton > Cc: Oscar Salvador > Cc: Anshuman Khandual > Cc: Qian Cai > Cc: Pingfan Liu > Cc: Stephen Rothwell > Cc: Dan Williams > Cc: Pavel Tatashin > Cc: Vlastimil Babka > Cc: Mel Gorman > Cc: Mike Rapoport > Cc: Wei Yang > Cc: Alexander Duyck > Cc: Alexander Potapenko > Cc: Arun KS > Cc: Michael Ellerman > Signed-off-by: David Hildenbrand yay again! I have to say that this was a head scratcher when I've seen that for the first time. It is really great to see it go Acked-by: Michal Hocko Thanks! > --- > include/linux/page-isolation.h | 4 ++-- > mm/memory_hotplug.c | 2 +- > mm/page_alloc.c | 21 +++++++-------------- > mm/page_isolation.c | 2 +- > 4 files changed, 11 insertions(+), 18 deletions(-) > > diff --git a/include/linux/page-isolation.h b/include/linux/page-isolation.h > index 6861df759fad..148e65a9c606 100644 > --- a/include/linux/page-isolation.h > +++ b/include/linux/page-isolation.h > @@ -33,8 +33,8 @@ static inline bool is_migrate_isolate(int migratetype) > #define MEMORY_OFFLINE 0x1 > #define REPORT_FAILURE 0x2 > > -bool has_unmovable_pages(struct zone *zone, struct page *page, int count, > - int migratetype, int flags); > +bool has_unmovable_pages(struct zone *zone, struct page *page, int migratetype, > + int flags); > void set_pageblock_migratetype(struct page *page, int migratetype); > int move_freepages_block(struct zone *zone, struct page *page, > int migratetype, int *num_movable); > diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c > index 3b5cee4d3f4e..f06d33748607 100644 > --- a/mm/memory_hotplug.c > +++ b/mm/memory_hotplug.c > @@ -1158,7 +1158,7 @@ static bool is_pageblock_removable_nolock(unsigned long pfn) > if (!zone_spans_pfn(zone, pfn)) > return false; > > - return !has_unmovable_pages(zone, page, 0, MIGRATE_MOVABLE, > + return !has_unmovable_pages(zone, page, MIGRATE_MOVABLE, > MEMORY_OFFLINE); > } > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index f5ecbacb0e04..e4d8f3a1a6b6 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -8270,17 +8270,15 @@ void *__init alloc_large_system_hash(const char *tablename, > > /* > * This function checks whether pageblock includes unmovable pages or not. > - * If @count is not zero, it is okay to include less @count unmovable pages > * > * PageLRU check without isolation or lru_lock could race so that > * MIGRATE_MOVABLE block might include unmovable pages. And __PageMovable > * check without lock_page also may miss some movable non-lru pages at > * race condition. So you can't expect this function should be exact. > */ > -bool has_unmovable_pages(struct zone *zone, struct page *page, int count, > - int migratetype, int flags) > +bool has_unmovable_pages(struct zone *zone, struct page *page, int migratetype, > + int flags) > { > - unsigned long found; > unsigned long iter = 0; > unsigned long pfn = page_to_pfn(page); > const char *reason = "unmovable page"; > @@ -8306,13 +8304,11 @@ bool has_unmovable_pages(struct zone *zone, struct page *page, int count, > goto unmovable; > } > > - for (found = 0; iter < pageblock_nr_pages; iter++) { > - unsigned long check = pfn + iter; > - > - if (!pfn_valid_within(check)) > + for (; iter < pageblock_nr_pages; iter++) { > + if (!pfn_valid_within(pfn + iter)) > continue; > > - page = pfn_to_page(check); > + page = pfn_to_page(pfn + iter); > > if (PageReserved(page)) > goto unmovable; > @@ -8361,11 +8357,9 @@ bool has_unmovable_pages(struct zone *zone, struct page *page, int count, > if ((flags & MEMORY_OFFLINE) && PageHWPoison(page)) > continue; > > - if (__PageMovable(page)) > + if (__PageMovable(page) || PageLRU(page)) > continue; > > - if (!PageLRU(page)) > - found++; > /* > * If there are RECLAIMABLE pages, we need to check > * it. But now, memory offline itself doesn't call > @@ -8379,8 +8373,7 @@ bool has_unmovable_pages(struct zone *zone, struct page *page, int count, > * is set to both of a memory hole page and a _used_ kernel > * page at boot. > */ > - if (found > count) > - goto unmovable; > + goto unmovable; > } > return false; > unmovable: > diff --git a/mm/page_isolation.c b/mm/page_isolation.c > index 21af88b718aa..1f8b9dfecbe8 100644 > --- a/mm/page_isolation.c > +++ b/mm/page_isolation.c > @@ -37,7 +37,7 @@ static int set_migratetype_isolate(struct page *page, int migratetype, int isol_ > * FIXME: Now, memory hotplug doesn't call shrink_slab() by itself. > * We just check MOVABLE pages. > */ > - if (!has_unmovable_pages(zone, page, 0, migratetype, isol_flags)) { > + if (!has_unmovable_pages(zone, page, migratetype, isol_flags)) { > unsigned long nr_pages; > int mt = get_pageblock_migratetype(page); > > -- > 2.21.0 -- Michal Hocko SUSE Labs 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=-8.5 required=3.0 tests=INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=unavailable 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 18FE6C432C3 for ; Thu, 14 Nov 2019 19:44:00 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CC28520723 for ; Thu, 14 Nov 2019 19:43:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CC28520723 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 47DX3d3S2pzF7br for ; Fri, 15 Nov 2019 06:43:57 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=softfail (domain owner discourages use of this host) smtp.mailfrom=kernel.org (client-ip=195.135.220.15; helo=mx1.suse.de; envelope-from=mhocko@kernel.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=fail (p=none dis=none) header.from=kernel.org Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 47DX016Bl2zF7pr for ; Fri, 15 Nov 2019 06:40:49 +1100 (AEDT) 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 34F55B2AF; Thu, 14 Nov 2019 19:40:46 +0000 (UTC) Date: Thu, 14 Nov 2019 20:40:44 +0100 From: Michal Hocko To: David Hildenbrand Subject: Re: [PATCH v2 2/2] mm: remove "count" parameter from has_unmovable_pages() Message-ID: <20191114194044.GC24848@dhcp22.suse.cz> References: <20191114131911.11783-1-david@redhat.com> <20191114131911.11783-3-david@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191114131911.11783-3-david@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stephen Rothwell , Pavel Tatashin , Anshuman Khandual , Mel Gorman , Alexander Duyck , linux-kernel@vger.kernel.org, Pingfan Liu , linux-mm@kvack.org, Mike Rapoport , Qian Cai , Wei Yang , Arun KS , Alexander Potapenko , Andrew Morton , linuxppc-dev@lists.ozlabs.org, Dan Williams , Vlastimil Babka , Oscar Salvador Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Thu 14-11-19 14:19:11, David Hildenbrand wrote: > Now that the memory isolate notifier is gone, the parameter is always 0. > Drop it and cleanup has_unmovable_pages(). > > Cc: Michal Hocko > Cc: Andrew Morton > Cc: Oscar Salvador > Cc: Anshuman Khandual > Cc: Qian Cai > Cc: Pingfan Liu > Cc: Stephen Rothwell > Cc: Dan Williams > Cc: Pavel Tatashin > Cc: Vlastimil Babka > Cc: Mel Gorman > Cc: Mike Rapoport > Cc: Wei Yang > Cc: Alexander Duyck > Cc: Alexander Potapenko > Cc: Arun KS > Cc: Michael Ellerman > Signed-off-by: David Hildenbrand yay again! I have to say that this was a head scratcher when I've seen that for the first time. It is really great to see it go Acked-by: Michal Hocko Thanks! > --- > include/linux/page-isolation.h | 4 ++-- > mm/memory_hotplug.c | 2 +- > mm/page_alloc.c | 21 +++++++-------------- > mm/page_isolation.c | 2 +- > 4 files changed, 11 insertions(+), 18 deletions(-) > > diff --git a/include/linux/page-isolation.h b/include/linux/page-isolation.h > index 6861df759fad..148e65a9c606 100644 > --- a/include/linux/page-isolation.h > +++ b/include/linux/page-isolation.h > @@ -33,8 +33,8 @@ static inline bool is_migrate_isolate(int migratetype) > #define MEMORY_OFFLINE 0x1 > #define REPORT_FAILURE 0x2 > > -bool has_unmovable_pages(struct zone *zone, struct page *page, int count, > - int migratetype, int flags); > +bool has_unmovable_pages(struct zone *zone, struct page *page, int migratetype, > + int flags); > void set_pageblock_migratetype(struct page *page, int migratetype); > int move_freepages_block(struct zone *zone, struct page *page, > int migratetype, int *num_movable); > diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c > index 3b5cee4d3f4e..f06d33748607 100644 > --- a/mm/memory_hotplug.c > +++ b/mm/memory_hotplug.c > @@ -1158,7 +1158,7 @@ static bool is_pageblock_removable_nolock(unsigned long pfn) > if (!zone_spans_pfn(zone, pfn)) > return false; > > - return !has_unmovable_pages(zone, page, 0, MIGRATE_MOVABLE, > + return !has_unmovable_pages(zone, page, MIGRATE_MOVABLE, > MEMORY_OFFLINE); > } > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index f5ecbacb0e04..e4d8f3a1a6b6 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -8270,17 +8270,15 @@ void *__init alloc_large_system_hash(const char *tablename, > > /* > * This function checks whether pageblock includes unmovable pages or not. > - * If @count is not zero, it is okay to include less @count unmovable pages > * > * PageLRU check without isolation or lru_lock could race so that > * MIGRATE_MOVABLE block might include unmovable pages. And __PageMovable > * check without lock_page also may miss some movable non-lru pages at > * race condition. So you can't expect this function should be exact. > */ > -bool has_unmovable_pages(struct zone *zone, struct page *page, int count, > - int migratetype, int flags) > +bool has_unmovable_pages(struct zone *zone, struct page *page, int migratetype, > + int flags) > { > - unsigned long found; > unsigned long iter = 0; > unsigned long pfn = page_to_pfn(page); > const char *reason = "unmovable page"; > @@ -8306,13 +8304,11 @@ bool has_unmovable_pages(struct zone *zone, struct page *page, int count, > goto unmovable; > } > > - for (found = 0; iter < pageblock_nr_pages; iter++) { > - unsigned long check = pfn + iter; > - > - if (!pfn_valid_within(check)) > + for (; iter < pageblock_nr_pages; iter++) { > + if (!pfn_valid_within(pfn + iter)) > continue; > > - page = pfn_to_page(check); > + page = pfn_to_page(pfn + iter); > > if (PageReserved(page)) > goto unmovable; > @@ -8361,11 +8357,9 @@ bool has_unmovable_pages(struct zone *zone, struct page *page, int count, > if ((flags & MEMORY_OFFLINE) && PageHWPoison(page)) > continue; > > - if (__PageMovable(page)) > + if (__PageMovable(page) || PageLRU(page)) > continue; > > - if (!PageLRU(page)) > - found++; > /* > * If there are RECLAIMABLE pages, we need to check > * it. But now, memory offline itself doesn't call > @@ -8379,8 +8373,7 @@ bool has_unmovable_pages(struct zone *zone, struct page *page, int count, > * is set to both of a memory hole page and a _used_ kernel > * page at boot. > */ > - if (found > count) > - goto unmovable; > + goto unmovable; > } > return false; > unmovable: > diff --git a/mm/page_isolation.c b/mm/page_isolation.c > index 21af88b718aa..1f8b9dfecbe8 100644 > --- a/mm/page_isolation.c > +++ b/mm/page_isolation.c > @@ -37,7 +37,7 @@ static int set_migratetype_isolate(struct page *page, int migratetype, int isol_ > * FIXME: Now, memory hotplug doesn't call shrink_slab() by itself. > * We just check MOVABLE pages. > */ > - if (!has_unmovable_pages(zone, page, 0, migratetype, isol_flags)) { > + if (!has_unmovable_pages(zone, page, migratetype, isol_flags)) { > unsigned long nr_pages; > int mt = get_pageblock_migratetype(page); > > -- > 2.21.0 -- Michal Hocko SUSE Labs