Re: Suggestion for laptop suspension

From: Richard Gooch (rgooch@ras.ucalgary.ca)
Date: Wed Aug 30 2000 - 10:34:18 EDT

  • Next message: justin: "Re: 2.2.16 & unresolved symbols in modules"

    Stephen Rothwell writes:
    > Hi Richard,
    >
    > Richard Stallman <rms@gnu.org> writes:
    > > On my laptop, suspending to disk is slow. It takes a whole minute, and
    > > another minute to unsuspend--if all of core is in use. But it is much
    > > faster when I do it not too long after the system was booted, when it has
    > > not yet managed to use up most of core.
    > >
    > > This suggests that it could be nice to make the kernel empty its caches, and
    > > mark all that core "unused", when a suspend is about to happen. I don't
    > > know the details of how suspension works, so I am not sure this is possible,
    > > but I think there are hooks for doing something in the kernel before a
    > > suspend.
    >
    > Just to try something, could you please take the program below and change
    > the 172 to be about 15-20 less that then number of MB of physical RAM
    > you have, then compile and run it and then try to suspend to disk
    > and see how long it takes. On my Thinkpad 600E, it changes the time
    > to suspend from ~30 seconds to < 10 seconds.
    >
    > This is an experiment to see if your BIOS is faster to suspend
    > when most of memory is zero'd.

    Interesting. I've just tried this on my Dell Inspiron 3200 (144
    MBytes) with a 110 MByte block of zeroes. The time went from 47
    seconds (filled with 1s) to 20 seconds (filled with 0s).

    Filling programme appended.

                                    Regards,

                                            Richard....
    Permanent: rgooch@atnf.csiro.au
    Current: rgooch@ras.ucalgary.ca
    ===============================================================================
    /* memfill.c

        Source file for memfill (fill memory with pattern and wait).

        Copyright (C) 2000 Richard Gooch

        This program is free software; you can redistribute it and/or modify
        it under the terms of the GNU General Public License as published by
        the Free Software Foundation; either version 2 of the License, or
        (at your option) any later version.

        This program is distributed in the hope that it will be useful,
        but WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
        GNU General Public License for more details.

        You should have received a copy of the GNU General Public License
        along with this program; if not, write to the Free Software
        Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

        Richard Gooch may be reached by email at rgooch@atnf.csiro.au
        The postal address is:
          Richard Gooch, c/o ATNF, P. O. Box 76, Epping, N.S.W., 2121, Australia.
    */

    /* This programme will fill memory with a specified pattern and wait.

        Written by Richard Gooch 30-AUG-2000

        Last updated by Richard Gooch 30-AUG-2000

    */
    #include <unistd.h>
    #include <stdio.h>
    #include <stdlib.h>

    int main (int argc, char **argv)
    {
        char length_modifier;
        signed long size_bytes, count, size_multiplier;
        unsigned char pattern;
        char *size_ptr;
        unsigned char *array;
        static char usage_string[] = "Usage:\tmemfill length[b|k|m] value";

        if (argc != 3)
        {
            fprintf (stderr, "%s\n", usage_string);
            exit (1);
        }
        size_ptr = argv[1];
        length_modifier = size_ptr[strlen (size_ptr) - 1];
        if ( isdigit (length_modifier) )
        {
            size_bytes = strtol (size_ptr, NULL, 0);
        }
        else
        {
            switch (length_modifier)
            {
              case 'b':
              case 'B':
                size_multiplier = 1;
                break;
              case 'k':
              case 'K':
                size_multiplier = 1024;
                break;
              case 'm':
              case 'M':
                size_multiplier = 1024 * 1024;
                break;
              default:
                fprintf (stderr, "%s\n", usage_string);
                exit (1);
            }
            size_ptr[strlen (size_ptr) - 1] = '\0';
            size_bytes = strtol (size_ptr, NULL, 0) * size_multiplier;
        }
        pattern = strtol (argv[2], NULL, 0);
        if ( ( array = malloc (size_bytes) ) == NULL )
        {
            fprintf (stderr, "Error allocating %ld bytes\n", size_bytes);
            exit (1);
        }
        fprintf (stderr, "Filling...");
        for (count = 0; count < size_bytes; ++count) *array++ = pattern;
        fprintf (stderr, "\tfilled. Press control-C to stop\n");
        while (1) pause ();
        return (0);
    } /* End Function main */
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    Please read the FAQ at http://www.tux.org/lkml/



    This archive was generated by hypermail 2b29 : Wed Aug 30 2000 - 10:35:21 EDT