Re: [PATCH 2/2] Make is_mem_section_removable more conformablewith offlining code v3
From: Wu Fengguang
Date: Fri Sep 03 2010 - 22:56:13 EST
On Fri, Sep 03, 2010 at 07:42:13PM +0800, Michal Hocko wrote:
> +/*
> + * A free or LRU pages block are removable
> + * Do not use MIGRATE_MOVABLE because it can be insufficient and
> + * other MIGRATE types are tricky.
> + * Do not hold zone->lock as this is used from user space by the
> + * sysfs interface.
> + */
> +bool is_page_removable(struct page *page)
> +{
> + int page_block = 1 << pageblock_order;
> +
> + /* All pages from the MOVABLE zone are movable */
> + if (zone_idx(page_zone(page)) == ZONE_MOVABLE)
> + return true;
> +
> + while (page_block > 0) {
> + int order = 0;
> +
> + if (pfn_valid_within(page_to_pfn(page))) {
> + if (!page_count(page) && PageBuddy(page)) {
PageBuddy() is true only for the head page and false for all tail
pages. So when is_page_removable() is given a random 4k page
(get_any_page() will exactly do that), the above test is not enough.
It's recommended to reuse is_free_buddy_page(). (Need to do some
cleanup work first: remove the "#ifdef CONFIG_MEMORY_FAILURE" and
abstract out an __is_free_buddy_page() that takes no lock.)
> @@ -5277,14 +5277,11 @@ int set_migratetype_isolate(struct page *page)
> struct memory_isolate_notify arg;
> int notifier_ret;
> int ret = -EBUSY;
> - int zone_idx;
>
> zone = page_zone(page);
> - zone_idx = zone_idx(zone);
>
> spin_lock_irqsave(&zone->lock, flags);
> - if (get_pageblock_migratetype(page) == MIGRATE_MOVABLE ||
> - zone_idx == ZONE_MOVABLE) {
> + if (is_page_removable(page)) {
> ret = 0;
> goto out;
The above check only applies to the first page in the page block.
The following "if (!page_count(curr_page) || PageLRU(curr_page))"
check in the same function should be converted too (and that's another
reason to use __is_free_buddy_page(): it will be tested for every 4k
pages, including both the head and tail pages).
Thanks,
Fengguang
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/