Re: suspend-to-{RAM,disk} for 2.5.17

Pavel Machek (pavel@suse.cz)
Tue, 28 May 2002 23:34:08 +0200


Hi!

> >>> I had to add
> >>> if (!curr) break;
> >>> to fix the oops. It now looks way nicer. Thanx.
>
> At some point in the past, I wrote:
> >> It's pretty odd that this happens to the buddy lists. I guess if it's
> >> needed as a stopgap measure, I can't complain too much, but I'd suspect
> >> something's corrupting it or you're catching a buddy list operation in
> >> progress. I might be interested in taking a stab at finding out where
> >> the corruption happens if you also think that's what's going on.
>
> On Tue, May 28, 2002 at 11:11:20PM +0200, Pavel Machek wrote:
> > I think it is not a coruption, but something like
> > "not all list are valid on non-himem machine", or something like that.
> > Pavel
>
> d'oh! Sorry about that, I forgot about free_area_init_core() not fixing
> up zeroed-out list_heads for ZONE_HIGHMEM. I don't see any harm in
> doing INIT_LIST_HEAD() on them in free_area_init_core(), and it

Doing INIT_LIST_HEAD() on them would be certainly cleaner...

> seem to fix this boundary case, no? Alternatively, highmem zones on non-
> highmem machines can be skipped by the caller as well. Do you think
> either of these might be good ideas, or is it going too far out of one's
> way for marginal code prettiness benefits?
>
> Actually, I just thought of something that might be useful in addition,
> which is that it would probably only be necessary to search inside of
> page_zone(page), do you agree?

Hey, speeding this up is not a top priority. But.. if we can make it
simpler as well ... ;-).

#ifdef CONFIG_SOFTWARE_SUSPEND
int is_head_of_free_region(struct page *page)
{
zone_t *zone = page_zone(page);
unsigned long flags;
int order;
list_t *curr;

/*
* Should not matter as we need quiescent system for
* suspend anyway, but...
*/
spin_lock_irqsave(&zone->lock, flags);
for (order = MAX_ORDER - 1; order >= 0; --order)
list_for_each(curr, &zone->free_area[order].free_list){
if (!curr)
break;
if (page == list_entry(curr, struct page,list)) {
spin_unlock_irqrestore(&zone->lock,flags);
return 1 << order;
}
}
spin_unlock_irqrestore(&zone->lock, flags);
return 0;
}
#endif /* CONFIG_SOFTWARE_SUSPEND */

Does that look okay to you?

Pavel

-- 
Casualities in World Trade Center: ~3k dead inside the building,
cryptography in U.S.A. and free speech in Czech Republic.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/