linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: starlight@binnacle.cx
To: Mel Gorman <mel@csn.ul.ie>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	linux-mm@kvack.org, bugzilla-daemon@bugzilla.kernel.org,
	bugme-daemon@bugzilla.kernel.org, Adam Litke <agl@us.ibm.com>,
	Eric B Munson <ebmunson@us.ibm.com>
Subject: Re: [Bugme-new] [Bug 13302] New: "bad pmd" on fork() of process with hugepage shared memory segments attached
Date: Fri, 15 May 2009 01:32:38 -0400	[thread overview]
Message-ID: <6.2.5.6.2.20090515012125.057a9c88@binnacle.cx> (raw)

[-- Attachment #1: Type: text/plain, Size: 1105 bytes --]

Whacked at a this, attempting to build a testcase from a 
combination of the original daemon strace in the bug report
and knowledge of what the daemon is doing.

What emerged is something that will destroy RHEL5 
2.6.18-128.1.6.el5 100% every time.  Completely fills the kernel 
message log with "bad pmd" errors and wrecks hugepages.

Unfortunately it only occasionally breaks 2.6.29.1.  Haven't
been able to produce "bad pmd" messages, but did get the
kernel to think it's out of large page memory when in
theory it was not.  Saw a lot of really strange accounting
in the hugepage section of /proc/meminfo.

For what it's worth, the testcase code is attached.

Note that hugepages=2048 is assumed--the bug seems to require 
use of more than 50% of large page memory.

Definately will be posted under the RHEL5 bug report, which is 
the more pressing issue here than far-future kernel support.

In addition, the original segment attach bug 
http://bugzilla.kernel.org/show_bug.cgi?id=12134 is still there 
and can be reproduced every time with the 'create_seg_strace' 
and 'access_seg_straceX' sequences.

[-- Attachment #2: do_tcbm.txt --]
[-- Type: text/plain, Size: 28 bytes --]

g++ -Wall -g -o tcbm tcbm.C

[-- Attachment #3: tcbm.C.txt --]
[-- Type: text/plain, Size: 3873 bytes --]

extern "C" {
#include <errno.h>
#include <memory.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sched.h>
#include <sys/wait.h>
#include <sys/shm.h>
#include <sys/resource.h>
#include <sys/mman.h>
}

extern "C"
void child_signal_handler(
   const int
)
{
   int   errno_save;
   pid_t dead_pid;
   int   dead_status;

   errno_save = errno;

   do {
      dead_pid = waitpid(-1, &dead_status, WNOHANG);
      if (dead_pid == -1) {
         if (errno == ECHILD) break;
         perror("waitpid");
         exit(1);
      }
   } while (dead_pid != 0);

   errno = errno_save;

   return;
}

int rabbits(void)
{
   int pid = fork();
   if (pid != 0) {

      return 0;

   } else {

      const int sched_policy = sched_getscheduler(0);
      if (sched_policy == -1) {
         perror("sched_getscheduler");
      }
      if (sched_policy != SCHED_OTHER) {
         sched_param sched;
         memset(&sched, 0, sizeof(sched));
         sched.sched_priority = 0;
         if (sched_setscheduler(0, SCHED_OTHER, &sched) != 0) {
            perror("sched_setscheduler");
         }
      }
      errno = 0;                   // -1 return value legitimate
      const int nice = getpriority(PRIO_PROCESS, 0);
      if (errno != 0) {
         perror("getpriority");
      }
      if (nice < -10) {
         if (setpriority(PRIO_PROCESS, 0, -10) != 0) {   // somewhat elevated
            perror("setpriority");
         }
      }

      char* program;
      program = (char*) "script";
      char* pargs[2];
      pargs[0] = program;
      pargs[1] = NULL;
      execvp(program, pargs);
      perror("execvp");
      exit(1);

   }

}

int main(
   int          argc,
   const char** argv,
   const char** envp
)
{
#if 1
   sched_param sched;
   memset(&sched, 0, sizeof(sched));
   sched.sched_priority = 26;
   if (sched_setscheduler(0, SCHED_RR, &sched) != 0) {
      perror("sched_setscheduler(SCHED_RR, 26)");
      return 1;
   }
#endif

#if 0
   if (mlockall(MCL_CURRENT|MCL_FUTURE) != 0) {
      perror("mlockall");
      return 1;
   }
#endif

   struct sigaction sas_child;
   memset(&sas_child, 0, sizeof(sas_child));
   sas_child.sa_handler = child_signal_handler;
   if (sigaction(SIGCHLD, &sas_child, NULL) != 0) {
      perror("sigaction(SIGCHLD)");
      return 1;
   }

   int seg1id = shmget(0x12345600,
                       (size_t) 0xC0000000,
                       IPC_CREAT|SHM_HUGETLB|0640
                      );
   if (seg1id == -1) {
      perror("shmget(3GB)");
      return 1;
   }
   void* seg1adr = shmat(seg1id, (void*) 0x400000000, 0);
   if (seg1adr == (void*) -1) {
      perror("shmat(3GB)");
      return 1;
   }
#if 1
   memset(seg1adr, 0xFF, (size_t) 0x60000000);
   if (mlock(seg1adr, (size_t) 0xC0000000) != 0) {
      perror("mlock(3GB)");
      return 1;
   }
#endif

   int seg2id = shmget(0x12345601,
                       (size_t) 0x40000000,
                       IPC_CREAT|SHM_HUGETLB|0640
                      );
   if (seg2id == -1) {
      perror("shmget(1GB)");
      return 1;
   }
   void* seg2adr = shmat(seg2id, (void*) 0x500000000, 0);
   if (seg2adr == (void*) -1) {
      perror("shmat(1GB)");
      return 1;
   }
#if 1
   memset(seg2adr, 0xFF, (size_t) 0x40000000);
   if (mlock(seg2adr, (size_t) 0x40000000) != 0) {
      perror("mlock(1GB)");
      return 1;
   }
#endif

   for (int i1 = 0; i1 < 50; i1++) {
      void* mmtarg = mmap(NULL,
                          528384,
                          PROT_READ|PROT_WRITE,
                          MAP_PRIVATE|MAP_ANONYMOUS,
                          -1,
                          0
                         );
      if (mmtarg == (void*) -1) {
         perror("mmap");
         return 1;
      }
   }

   for (int i1 = 0; i1 < 50; i1++) {
      rabbits();
      usleep(500);
   }

   while (true) {
      pause();
   }

   return 0;
}

             reply	other threads:[~2009-05-15  5:44 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-15  5:32 starlight [this message]
2009-05-15 14:55 ` [Bugme-new] [Bug 13302] New: "bad pmd" on fork() of process with hugepage shared memory segments attached Mel Gorman
2009-05-15 15:02   ` starlight
  -- strict thread matches above, loose matches on Subject: below --
2009-05-15 18:53 starlight
2009-05-20 11:35 ` Mel Gorman
2009-05-20 14:29   ` Mel Gorman
2009-05-20 14:53   ` Lee Schermerhorn
2009-05-20 15:05     ` Lee Schermerhorn
2009-05-20 15:41       ` Mel Gorman
2009-05-21  0:41         ` KOSAKI Motohiro
2009-05-22 16:41           ` Mel Gorman
2009-05-24 13:44             ` KOSAKI Motohiro
2009-05-25  8:51               ` Mel Gorman
2009-05-25 10:10                 ` Hugh Dickins
2009-05-25 13:17                   ` Mel Gorman
2009-05-15 18:44 starlight
2009-05-18 16:36 ` Mel Gorman
     [not found] <bug-13302-10286@http.bugzilla.kernel.org/>
2009-05-13 20:08 ` Andrew Morton
2009-05-14 10:53   ` Mel Gorman
2009-05-14 10:59     ` Mel Gorman
2009-05-14 17:20       ` starlight
2009-05-14 17:49         ` Mel Gorman
2009-05-14 18:42           ` starlight
2009-05-14 19:10           ` starlight
2009-05-14 17:16     ` starlight

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=6.2.5.6.2.20090515012125.057a9c88@binnacle.cx \
    --to=starlight@binnacle.cx \
    --cc=agl@us.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=bugme-daemon@bugzilla.kernel.org \
    --cc=bugzilla-daemon@bugzilla.kernel.org \
    --cc=ebmunson@us.ibm.com \
    --cc=linux-mm@kvack.org \
    --cc=mel@csn.ul.ie \
    /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;
as well as URLs for NNTP newsgroup(s).