From: Pavel Machek <pavel@ucw.cz>
To: Erik Rigtorp <erik@rigtorp.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] make swsusp produce nicer screen output
Date: Sun, 29 Aug 2004 17:20:10 +0200 [thread overview]
Message-ID: <20040829152010.GC3046@elf.ucw.cz> (raw)
In-Reply-To: <20040829135403.GA8182@linux.nu>
Hi!
> > > > Well, it looks nice, be sure to submit smooth version :-).
> > > I'm working on it :).
> >
> > > > I'd leave dots here. Its usefull to see if it done something or not.
> > >
> > > Well, it will display a spinning thingy that is updated every time
> > > shrink_all_memory(10000) returns. Maybe you want to see how much memory was
> > > freed?
> >
> > Yes, it is quite important to see how many pages were freed even after
> > freeing stopped. "done (1234 pages freed)" would solve it...
> Added code for this in the new patch
>
> >
> > > And do we need to handle the case when nr_copy_pages < 100?
> >
> > It really should not crash. 100 pages is 4MB. Thats little low but
> > seems possible.
>
> Well it's probably best to handle this case, to be on the safe side.
>
> Here's a new version of the patch.
I like this patch. Can you add short description "better progress
reporting", say that I approved it and mail it to Andrew, Cc patrick
mochel?
Pavel
> diff -Nru linux-2.6.8.1-mm2/kernel/power/disk.c linux-2.6.8.1-mm2-erkki/kernel/power/disk.c
> --- linux-2.6.8.1-mm2/kernel/power/disk.c 2004-08-20 17:10:58.000000000 +0200
> +++ linux-2.6.8.1-mm2-erkki/kernel/power/disk.c 2004-08-29 14:16:53.000000000 +0200
> @@ -85,10 +85,20 @@
>
> static void free_some_memory(void)
> {
> - printk("Freeing memory: ");
> - while (shrink_all_memory(10000))
> - printk(".");
> - printk("|\n");
> + unsigned int i = 0;
> + unsigned int tmp;
> + unsigned long pages = 0;
> + char *p = "-\\|/";
> +
> + printk("Freeing memory... ");
> + while (tmp = shrink_all_memory(10000)) {
> + pages += tmp;
> + printk("\b%c", p[i]);
> + i++;
> + if (i > 3)
> + i = 0;
> + }
> + printk("\bdone (%li pages freed)\n", pages);
> }
>
>
> diff -Nru linux-2.6.8.1-mm2/kernel/power/swsusp.c linux-2.6.8.1-mm2-erkki/kernel/power/swsusp.c
> --- linux-2.6.8.1-mm2/kernel/power/swsusp.c 2004-08-20 17:10:58.000000000 +0200
> +++ linux-2.6.8.1-mm2-erkki/kernel/power/swsusp.c 2004-08-29 13:51:55.000000000 +0200
> @@ -296,15 +296,21 @@
> {
> int error = 0;
> int i;
> -
> - printk( "Writing data to swap (%d pages): ", nr_copy_pages );
> + unsigned int mod;
> +
> + if (nr_copy_pages < 100)
> + mod = 1;
> + else
> + mod = nr_copy_pages / 100;
> +
> + printk( "Writing data to swap (%d pages)... ", nr_copy_pages );
> for (i = 0; i < nr_copy_pages && !error; i++) {
> - if (!(i%100))
> - printk( "." );
> + if (!(i%mod))
> + printk( "\b\b\b\b%3d%%", i / mod );
> error = write_page((pagedir_nosave+i)->address,
> &((pagedir_nosave+i)->swap_address));
> }
> - printk(" %d Pages done.\n",i);
> + printk("\b\b\b\bdone\n");
> return error;
> }
>
> @@ -534,8 +540,6 @@
> if (!pfn_valid(pfn))
> return 0;
>
> - if (!(pfn%1000))
> - printk(".");
> page = pfn_to_page(pfn);
> BUG_ON(PageReserved(page) && PageNosave(page));
> if (PageNosave(page))
> @@ -556,15 +560,28 @@
> {
> struct zone *zone;
> unsigned long zone_pfn;
> + unsigned long mod;
> +
> + printk("Counting pages... ");
>
> nr_copy_pages = 0;
>
> for_each_zone(zone) {
> if (!is_highmem(zone)) {
> - for (zone_pfn = 0; zone_pfn < zone->spanned_pages; ++zone_pfn)
> + if (zone->spanned_pages < 100)
> + mod = 1;
> + else
> + mod = zone->spanned_pages / 100;
> +
> + for (zone_pfn = 0; zone_pfn < zone->spanned_pages; ++zone_pfn) {
> nr_copy_pages += saveable(zone, &zone_pfn);
> + if (!(zone_pfn % mod))
> + printk("\b\b\b\b%3ld%%", zone_pfn / mod);
> + }
> }
> }
> +
> + printk("\b\b\b\bdone\n");
> }
>
>
> @@ -573,9 +590,17 @@
> struct zone *zone;
> unsigned long zone_pfn;
> struct pbe * pbe = pagedir_nosave;
> + unsigned long mod;
>
> + printk("Copying pages... ");
> +
> for_each_zone(zone) {
> - if (!is_highmem(zone))
> + if (!is_highmem(zone)) {
> + if (zone->spanned_pages < 100)
> + mod = 1;
> + else
> + mod = zone->spanned_pages / 100;
> +
> for (zone_pfn = 0; zone_pfn < zone->spanned_pages; ++zone_pfn) {
> if (saveable(zone, &zone_pfn)) {
> struct page * page;
> @@ -584,9 +609,14 @@
> /* copy_page is no usable for copying task structs. */
> memcpy((void *)pbe->address, (void *)pbe->orig_address, PAGE_SIZE);
> pbe++;
> + if (!(zone_pfn % mod))
> + printk("\b\b\b\b%3ld%%", zone_pfn / mod);
> }
> }
> + }
> }
> +
> + printk("\b\b\b\bdone\n");
> }
>
>
> @@ -1150,14 +1180,20 @@
> struct pbe * p;
> int error;
> int i;
> -
> + int mod;
> +
> + if (nr_copy_pages < 100)
> + mod = 1;
> + else
> + mod = nr_copy_pages / 100;
> +
> if ((error = swsusp_pagedir_relocate()))
> return error;
>
> - printk( "Reading image data (%d pages): ", nr_copy_pages );
> + printk( "Reading image data (%d pages): ", nr_copy_pages );
> for(i = 0, p = pagedir_nosave; i < nr_copy_pages && !error; i++, p++) {
> - if (!(i%100))
> - printk( "." );
> + if (!(i%mod))
> + printk( "\b\b\b\b%3d%%", i / mod );
> error = bio_read_page(swp_offset(p->swap_address),
> (void *)p->address);
> }
--
People were complaining that M$ turns users into beta-testers...
...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!
next prev parent reply other threads:[~2004-08-29 15:21 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-08-20 15:23 [PATCH] make swsusp produce nicer screen output Erik Rigtorp
2004-08-21 23:42 ` Stefan Seyfried
2004-08-23 17:42 ` Pavel Machek
2004-08-23 20:08 ` Erik Rigtorp
2004-08-24 21:49 ` Pavel Machek
2004-08-27 10:55 ` Stefan Seyfried
2004-08-28 22:58 ` Pavel Machek
2004-08-29 13:54 ` Erik Rigtorp
2004-08-29 14:59 ` Stefan Seyfried
2004-08-29 15:20 ` Pavel Machek [this message]
2004-08-29 16:36 ` Pavel Machek
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=20040829152010.GC3046@elf.ucw.cz \
--to=pavel@ucw.cz \
--cc=erik@rigtorp.com \
--cc=linux-kernel@vger.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