All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jesper Krogh <jesper@krogh.cc>
To: Ingo Molnar <mingo@elte.hu>
Cc: linux-kernel@vger.kernel.org, jk@novozymes.com,
	Andrew Morton <akpm@linux-foundation.org>,
	Yinghai Lu <yinghai@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	"H. Peter Anvin" <hpa@zytor.com>, Tejun Heo <tj@kernel.org>,
	yinghai@kernel.org, herrmann.der.user@googlemail.com
Subject: Re: Memory issues with Opteron 6220
Date: Thu, 09 Feb 2012 22:07:14 +0100	[thread overview]
Message-ID: <4F343582.7080007@krogh.cc> (raw)
In-Reply-To: <20120209083315.GA19380@elte.hu>

On 2012-02-09 09:33, Ingo Molnar wrote:
> * Anders Ossowicki<aowi@novozymes.com>  wrote:
>> Hey,
>>
>> We're seeing unexpected slowdowns and other memory issues with a new system.
>> Enough to render it unusable. For example:
>>
>> Error: open3: fork failed: Cannot allocate memory
>>
>> at times where there's no real memory pressure:
>>                     total       used       free     shared    buffers     cached
>>        Mem:     132270720  131942388     328332          0     299768  103334420
>>        -/+ buffers/cache:   28308200  103962520
>>        Swap:      7811068      13760    7797308
>>
>> [...]
Anders' co-worker here..  below C-code (Summary: for -t processes that 
repeatedly
allocates and dallocates 2GB of memory) can excersize the bug
pretty frequently using -t 32 on this machine. On the other 128GB
machine it can run without issues.

It actually ended up toasting the machine:
jk@nysvin:~$ ./foo -t 32
-bash: fork: Cannot allocate memory
jk@nysvin:~$ w
-bash: fork: Cannot allocate memory
jk@nysvin:~$ top
-bash: fork: Cannot allocate memory
jk@nysvin:~$ ls
-bash: fork: Cannot allocate memory

I dont know what to conclude.

jk@nysvin:~$ ./foo -t 32
Upper bound: 1953 MB
malloc(1953) MB failed. iterations: 6
malloc(1953) MB failed. iterations: 2
malloc(1953) MB failed. iterations: 8

foo.c
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <sys/wait.h>

void worker(void)
{
     long long i;
     char *p;
     int action;
     int mult = 500000;
     int size = mult * 4096;
     fprintf(stderr,"Upper bound: %lu MB\n",(long int) (size/1024/1024));
     for (i=0; ; i++) {
         action = i%2;
         switch(action) {
         case 0:
             p = malloc(size);
             if (!p){
                 fprintf(stderr,"malloc(%lu) MB failed. iterations: 
%lli\n", (long int)size/1024/1024,i);
                 exit(1);
             }
             break;
         case 1:
             free(p);
             break;
         }
     }
}

void usage(const char *cmd)
{
     fprintf(stderr,"Usage: %s [-t numthreads]\n", cmd);
     exit(1);
}

int main(int argc, char **argv)
{
     int c, i;
     int nproc = sysconf(_SC_NPROCESSORS_ONLN);


     while ((c = getopt(argc, argv, "t:")) != EOF) {
         switch (c) {
         case 't':
             nproc = strtol(optarg, 0, 0);
             break;
         default:
             usage(argv[0]);
         }
     }

     //printf("forking %d children\n", nproc);
     for (i=0; i < nproc; i++) {
         switch(fork()) {
         case -1:
             fprintf(stderr,"fork: %s\n", strerror(errno));
             exit(1);
         case 0: /* child */
             worker();
             exit(0);
         default: /* parent */
             /* nothing */
             break;
         }
     }

     for (i=0; i < nproc; i++) {
         int x, p;
         p = wait(&x);
     }

     return 0;
}

Can also be found here: http://shrek.krogh.cc/~jesper/foo.c

-- 
Jesper Krogh

  parent reply	other threads:[~2012-02-09 21:15 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-08 14:37 Memory issues with Opteron 6220 Anders Ossowicki
2012-02-09  8:33 ` Ingo Molnar
2012-02-09  9:08   ` Eric Dumazet
2012-02-09 13:23     ` Ingo Molnar
2012-02-09 21:07   ` Jesper Krogh [this message]
2012-02-10 15:21     ` Jesper Krogh
2012-02-11 13:48       ` Ingo Molnar
2012-02-14  9:32         ` Anders Ossowicki
     [not found] ` <20120208205628.GA18909@alberich.amd.com>
2012-02-09 12:43   ` Anders Ossowicki
2012-02-09 13:28     ` Ingo Molnar
2012-02-09 13:49       ` Anders Ossowicki
2012-02-09 16:11         ` Yinghai Lu
2012-02-09 17:51           ` Anders Ossowicki
2012-02-09 18:56             ` Yinghai Lu
2012-02-11 13:50               ` Ingo Molnar

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=4F343582.7080007@krogh.cc \
    --to=jesper@krogh.cc \
    --cc=akpm@linux-foundation.org \
    --cc=herrmann.der.user@googlemail.com \
    --cc=hpa@zytor.com \
    --cc=jk@novozymes.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=tglx@linutronix.de \
    --cc=tj@kernel.org \
    --cc=yinghai@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.