From: Mel Gorman <mel@csn.ul.ie>
To: Hiroyuki Kamezawa <kamezawa.hiroyuki@gmail.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Michal Hocko <mhocko@suse.cz>,
fengguang.wu@intel.com,
"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
andi.kleen@intel.com, Dave Hansen <dave@linux.vnet.ibm.com>,
stable@kernel.org
Subject: Re: [BUGFIX][PATCH 1/3] memory hotplug: fix next block calculation in is_removable
Date: Tue, 7 Sep 2010 10:30:44 +0100 [thread overview]
Message-ID: <20100907093044.GR8384@csn.ul.ie> (raw)
In-Reply-To: <AANLkTikPkKcxja4tqRPmJErEGs3YZ=NS4dBNyz1e--+d@mail.gmail.com>
On Tue, Sep 07, 2010 at 02:15:01AM +0900, Hiroyuki Kamezawa wrote:
> 2010/9/6 Mel Gorman <mel@csn.ul.ie>:
> > On Mon, Sep 06, 2010 at 02:42:28PM +0900, KAMEZAWA Hiroyuki wrote:
> >>
> >> From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
> >>
> >> next_active_pageblock() is for finding next _used_ freeblock. It skips
> >> several blocks when it finds there are a chunk of free pages lager than
> >> pageblock. But it has 2 bugs.
> >>
> >> 1. We have no lock. page_order(page) - pageblock_order can be minus.
> >> 2. pageblocks_stride += is wrong. it should skip page_order(p) of pages.
> >>
> >> CC: stable@kernel.org
> >> Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
> >> ---
> >> mm/memory_hotplug.c | 16 ++++++++--------
> >> 1 file changed, 8 insertions(+), 8 deletions(-)
> >>
> >> Index: kametest/mm/memory_hotplug.c
> >> ===================================================================
> >> --- kametest.orig/mm/memory_hotplug.c
> >> +++ kametest/mm/memory_hotplug.c
> >> @@ -584,19 +584,19 @@ static inline int pageblock_free(struct
> >> /* Return the start of the next active pageblock after a given page */
> >> static struct page *next_active_pageblock(struct page *page)
> >> {
> >> - int pageblocks_stride;
> >> -
> >> /* Ensure the starting page is pageblock-aligned */
> >> BUG_ON(page_to_pfn(page) & (pageblock_nr_pages - 1));
> >>
> >> - /* Move forward by at least 1 * pageblock_nr_pages */
> >> - pageblocks_stride = 1;
> >> -
> >> /* If the entire pageblock is free, move to the end of free page */
> >> - if (pageblock_free(page))
> >> - pageblocks_stride += page_order(page) - pageblock_order;
> >> + if (pageblock_free(page)) {
> >> + int order;
> >> + /* be careful. we don't have locks, page_order can be changed.*/
> >> + order = page_order(page);
> >> + if (order > pageblock_order)
> >> + return page + (1 << order);
> >> + }
> >
> > As you note in your changelog, page_order() is unsafe because we do not have
> > the zone lock but you don't check if order is somewhere between pageblock_order
> > and MAX_ORDER_NR_PAGES. How is this safer?
> >
> Ah, I missed that.
>
> if ((pageblock_order <= order) && (order < MAX_ORDER))
> return page + (1 << order);
> ok ?
>
Seems ok. There will still be some false usage of order but it should be
harmless.
--
Mel Gorman
Part-time Phd Student Linux Technology Center
University of Limerick IBM Dublin Software Lab
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2010-09-07 9:31 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-06 5:40 [PATCH 0/3] memory hotplug: updates and bugfix for is_removable KAMEZAWA Hiroyuki
2010-09-06 5:42 ` [BUGFIX][PATCH 1/3] memory hotplug: fix next block calculation in is_removable KAMEZAWA Hiroyuki
2010-09-06 13:39 ` Mel Gorman
2010-09-06 17:15 ` Hiroyuki Kamezawa
2010-09-07 9:30 ` Mel Gorman [this message]
2010-09-06 5:44 ` [PATCH 2/3] memory hotplug: fix set_migratetype_isolate wrong callback result check KAMEZAWA Hiroyuki
2010-09-06 5:47 ` [PATCH 3/3] memory hotplug: use unified logic for is_removable and offline_pages KAMEZAWA Hiroyuki
2010-09-06 9:30 ` Michal Hocko
2010-09-06 13:30 ` Hiroyuki Kamezawa
2010-09-07 13:16 ` Michal Hocko
2010-09-06 13:58 ` Mel Gorman
2010-09-06 23:58 ` KAMEZAWA Hiroyuki
2010-09-07 13:01 ` Mel Gorman
2010-09-07 1:28 ` [PATCH 0/3] memory hotplug: updates and bugfix for is_removable v3 KAMEZAWA Hiroyuki
2010-09-07 1:32 ` [PATCH 1/3] [BUGFIX] memory hotplug: fix next block calculation in is_removable KAMEZAWA Hiroyuki
2010-09-08 11:23 ` Mel Gorman
2010-09-07 1:34 ` [PATCH 2/3][BUGFIX] memory hotplug: fix notifier's return value check KAMEZAWA Hiroyuki
2010-09-07 1:36 ` [PATCH 3/3] memory hotplug: unify is_removable and offline detection code KAMEZAWA Hiroyuki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100907093044.GR8384@csn.ul.ie \
--to=mel@csn.ul.ie \
--cc=akpm@linux-foundation.org \
--cc=andi.kleen@intel.com \
--cc=dave@linux.vnet.ibm.com \
--cc=fengguang.wu@intel.com \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=kamezawa.hiroyuki@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.cz \
--cc=stable@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).