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 14:44:29 -0400	[thread overview]
Message-ID: <6.2.5.6.2.20090515144058.03a55298@binnacle.cx> (raw)

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

This was really bugging me, so I hacked out
the test case for the attach failure.

Hoses 2.6.29.1 100% every time.  Run it like this:

tcbm_att
tcbm_att -
tcbm_att -
tcbm_att -

It will break on the last iteration with ENOMEM
and ENOMEM is all any shmget() or shmat() call
gets forever more.

After removing the segments this appears:

HugePages_Total:    2048
HugePages_Free:     2048
HugePages_Rsvd:     1280
HugePages_Surp:        0

Even though no segments show in 'ipcs'.

[-- Attachment #2: tcbm_att.C.txt --]
[-- Type: text/plain, Size: 2429 bytes --]

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

int main(
   int          argc,
   const char** argv,
   const char** envp
)
{
   if (argc == 1) {

      int seg1id = shmget(0x12345600,
                          (size_t) 0x40000000,
                          IPC_CREAT|SHM_HUGETLB|0640
                         );
      if (seg1id == -1) {
         perror("shmget(1GB)");
         return 1;
      }
      void* seg1adr = shmat(seg1id, (void*) 0x400000000, 0);
      if (seg1adr == (void*) -1) {
         perror("shmat(1GB)");
         return 1;
      }

      int seg2id = shmget(0x12345601,
                          (size_t) 0x10000000,
                          IPC_CREAT|SHM_HUGETLB|0640
                         );
      if (seg2id == -1) {
         perror("shmget(256MB)");
         return 1;
      }
      void* seg2adr = shmat(seg2id, (void*) 0x580000000, 0);
      if (seg2adr == (void*) -1) {
         perror("shmat(256MB)");
         return 1;
      }

      char* seg_p = (char*) seg1adr;
      int i1 = 182;
      while (i1 > 0) {
         memset(seg_p, 0x55, 0x400000);
         seg_p += 0x400000;
         i1--;
      }

      seg_p = (char*) seg2adr;
      i1 = 6;
      while (i1 > 0) {
         memset(seg_p, 0xAA, 0x400000);
         seg_p += 0x400000;
         i1--;
      }

      if (shmdt((void*) 0x400000000) != 0) {
         perror("shmdt(1GB)");
         return 1;
      }

      if (shmdt((void*) 0x580000000) != 0) {
         perror("shmdt(256MB)");
         return 1;
      }

   } else {

      int seg1id = shmget(0x12345600, 0, 0);
      if (seg1id == -1) {
         perror("shmget(1GB)");
         return 1;
      }
      void* seg1adr = shmat(seg1id, (void*) 0x400000000, SHM_RDONLY);
      if (seg1adr == (void*) -1) {
         perror("shmat(1GB)");
         return 1;
      }

      int seg2id = shmget(0x12345601, 0, 0);
      if (seg2id == -1) {
         perror("shmget(256MB)");
         return 1;
      }
      void* seg2adr = shmat(seg2id, (void*) 0x580000000, SHM_RDONLY);
      if (seg2adr == (void*) -1) {
         perror("shmat(256MB)");
         return 1;
      }

      if (shmdt((void*) 0x400000000) != 0) {
         perror("shmdt(1GB)");
         return 1;
      }

      if (shmdt((void*) 0x580000000) != 0) {
         perror("shmdt(256MB)");
         return 1;
      }

   }

   return 0;
}

[-- Attachment #3: do_tcbm_att.txt --]
[-- Type: application/octet-stream, Size: 36 bytes --]

g++ -Wall -g -o tcbm_att tcbm_att.C

             reply	other threads:[~2009-05-15 18:47 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-15 18:44 starlight [this message]
2009-05-18 16:36 ` Mel Gorman
  -- 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  5:32 starlight
2009-05-15 14:55 ` Mel Gorman
2009-05-15 15:02   ` starlight
     [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.20090515144058.03a55298@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