[uClibc] (offtopic) kswapd needed?

David Wuertele dave-gnus at bfnet.com
Sun Nov 23 00:19:25 UTC 2003


Sorry about the lack of uclibc content here, but since lots of you
guys are using uclibc on embedded systems, I thought I might find
experience with this linux-2.4.18 kernel problem.  My program:

  /* Malloc as much as possible, then return */
  #include <stdio.h>
  #define UNIT 1024		/* one kilobyte */
  int main ()
  {
    unsigned int j, totalmalloc=0, totalwrote=0, totalread=0;
    while (1) {
      unsigned char *buf = (unsigned char *) malloc (UNIT);
      if (!buf) return 0;
      totalmalloc += UNIT; fprintf (stderr, "%u ", totalmalloc);
      for (j=0; j<UNIT; j++) buf[j] = j % 256;
      totalwrote += UNIT; fprintf (stderr, "%u ", totalwrote);
      for (j=0; j<UNIT; j++) if (buf[j] != (j % 256)) return -1;
      totalread += UNIT; fprintf (stderr, "%u\n", totalread);
    }
  }

I expected this program to malloc most of my embedded MIPS's 32MB of
system RAM, then eventually return with a -1 or a -2.  Unfortunately,
it hangs having finally printed:

  M26916864
  W26916864
  R26916864

The malloc call isn't even returning.  What could explain that?

I don't have swap space configured, and I notice several kernel
threads that I figure might be assuming I have swap.  For example:

      3 root     S    [ksoftirqd_CPU0]
      4 root     S    [kswapd]
      5 root     S    [bdflush]
      6 root     S    [kupdated]
      7 root     S    [mtdblockd]

Do I need any of these if I don't have swap?  Are there any special
kernel configs I should be doing if I don't have swap?

I appreciate the help.  If you think I should take this to LKML, let
me know.

Thanks,
Dave




More information about the uClibc mailing list