lkml.org 
[lkml]   [2005]   [Dec]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH][mm][Fix] swsusp: fix counting of highmem pages
    Hi!

    > The following patch fixes a problem with swsusp that causes suspend to
    > fail on systems with the highmem zone, if many highmem pages are in use.
    >
    > It makes swsusp count the non-free highmem pages in a correct way
    > and, consequently, release a sufficient amount of memory before suspend.
    >
    > Please apply (Pavel, please ack if you think the patch is ok).

    Please don't, it's way too complex in my eyes. Sorry, result of
    misscomunication between me and Rafael.

    > +static inline unsigned int get_kmalloc_size(void)
    > +{
    > +#define CACHE(x) \
    > + if (sizeof(struct highmem_page) <= x) \
    > + return x;
    > +#include <linux/kmalloc_sizes.h>
    > +#undef CACHE
    > + return sizeof(struct highmem_page);
    > +}
    > +

    Can we get rid of this uglyness...

    > @@ -437,8 +446,14 @@
    >
    > static int enough_free_mem(unsigned int nr_pages)
    > {
    > - pr_debug("swsusp: available memory: %u pages\n", nr_free_pages());
    > - return nr_free_pages() > (nr_pages + PAGES_FOR_IO +
    > + struct zone *zone;
    > + unsigned int n = 0;
    > +
    > + for_each_zone (zone)
    > + if (!is_highmem(zone))
    > + n += zone->free_pages;
    > + pr_debug("swsusp: available memory: %u pages\n", n);
    > + return n > (nr_pages + PAGES_FOR_IO +
    > (nr_pages + PBES_PER_PAGE - 1) / PBES_PER_PAGE);
    > }
    >

    And just use 2% approximation here, too?

    > Index: linux-2.6.15-rc3-mm1/kernel/power/swsusp.c
    > ===================================================================
    > --- linux-2.6.15-rc3-mm1.orig/kernel/power/swsusp.c 2005-12-03 00:14:49.000000000 +0100
    > +++ linux-2.6.15-rc3-mm1/kernel/power/swsusp.c 2005-12-03 21:25:07.000000000 +0100
    > @@ -635,7 +635,8 @@
    > printk("Shrinking memory... ");
    > do {
    > #ifdef FAST_FREE
    > - tmp = count_data_pages() + count_highmem_pages();
    > + tmp = 2 * count_highmem_pages();
    > + tmp += tmp / 50 + count_data_pages();
    > tmp += (tmp + PBES_PER_PAGE - 1) / PBES_PER_PAGE +
    > PAGES_FOR_IO;
    > for_each_zone (zone)

    This part is okay. Just make enough_free_mem use similar code. (If
    possible, share the code, it is really computing the same thing).

    Pavel
    --
    Thanks, Sharp!
    -
    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/

    \
     
     \ /
      Last update: 2005-12-03 22:42    [W:7.846 / U:0.012 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site