From: "Chen, Kenneth W" <kenneth.w.chen@intel.com>
To: 'Hugh Dickins' <hugh@veritas.com>,
David Gibson <david@gibson.dropbear.id.au>
Cc: Andrew Morton <akpm@osdl.org>, Bill Irwin <wli@holomorphy.com>,
Adam Litke <agl@us.ibm.com>,
linux-mm@kvack.org
Subject: RE: [PATCH 2/3] hugetlb: fix prio_tree unit
Date: Wed, 25 Oct 2006 16:49:29 -0700 [thread overview]
Message-ID: <000001c6f890$373fb960$12d0180a@amr.corp.intel.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0610250828020.8576@blonde.wat.veritas.com>
[-- Attachment #1: Type: text/plain, Size: 1354 bytes --]
Hugh Dickins wrote on Wednesday, October 25, 2006 12:41 AM
> On Wed, 25 Oct 2006, David Gibson wrote:
> >
> > Hugh, I'd like to add a testcase to the libhugetlbfs testsuite which
> > will trigger this bug, but from the description above I'm not sure
> > exactly how to tickle it. Can you give some more details of what
> > sequence of calls will cause the BUG_ON() to be called.
> >
> > I've attached the skeleton test I have now, but I'm not sure if it's
> > even close to what's really required for this.
>
> I'll take a look, or reconstruct my own sequence, later on today and
> send it just to you. The BUG_ON was not at all what I was expecting,
> and I spent quite a while working out how it came about (v_offset
> wrapped, so vm_start + v_offset less than vm_start, so the huge unmap
> applied to a non-huge vma before it). Though I'm dubious whether it's
> really worthwhile devising such a test now.
It's fairly easy to reproduce. I got a test cases that easily trigger
kernel oops and even got a sequence to screw up hugepage_rsvd count.
All I have to do is to place vm_start high enough and combined with large
enough v_offset, the add "vma->vm_start + v_offset" will overflow. It
doesn't even need to be over 4GB.
Hugh, if you haven't got time to reconstruct the bug sequence, don't
bother. I'll give my test cases to David.
- Ken
[-- Attachment #2: case2.c --]
[-- Type: application/octet-stream, Size: 1296 bytes --]
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <fcntl.h>
#define FILE_NAME "/mnt/htlb/junk"
#define HPAGE_SIZE (4*1024*1024)
#define LENGTH (16UL*1024*1024)
#define TRUNCATE (0x60000000)
#define PROTECTION (PROT_READ | PROT_WRITE)
#define ADDR (void *)(0xa0000000UL)
#define FLAGS (MAP_PRIVATE)
int main(void)
{
char *addr;
int fd;
char s;
unsigned long i;
fd = open(FILE_NAME, O_CREAT | O_RDWR, 0755);
if (fd < 0) {
perror("Open failed");
exit(1);
}
addr = mmap(0, LENGTH+TRUNCATE, PROTECTION, FLAGS, fd, 0);
if (addr == MAP_FAILED) {
perror("first mmap");
unlink(FILE_NAME);
exit(1);
}
munmap(addr, LENGTH+TRUNCATE);
addr = mmap(ADDR, LENGTH, PROTECTION, FLAGS, fd, 0);
if (addr == MAP_FAILED) {
perror("secound mmap");
unlink(FILE_NAME);
exit(1);
}
for (i = 0; i < LENGTH; i+= HPAGE_SIZE)
addr[i] = 1;
printf("addr = %lx\n", addr);
ftruncate(fd, TRUNCATE);
s = addr[0];
close(fd);
unlink(FILE_NAME);
return s;
}
[-- Attachment #3: case1.c --]
[-- Type: application/octet-stream, Size: 1024 bytes --]
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <fcntl.h>
#define FILE_NAME "/mnt/htlb/junk"
#define HPAGE_SIZE (4*1024*1024)
#define LENGTH (16UL*1024*1024)
#define TRUNCATE (8UL*1024*1024)
#define PROTECTION (PROT_READ | PROT_WRITE)
#define ADDR (void *)(0xa0000000UL)
#define OFFSET (0x50000000L)
#define FLAGS (MAP_SHARED)
int main(void)
{
char *addr;
int fd;
char s;
unsigned long i;
fd = open(FILE_NAME, O_CREAT | O_RDWR, 0755);
if (fd < 0) {
perror("Open failed");
exit(1);
}
addr = mmap(ADDR, LENGTH, PROTECTION, FLAGS, fd, OFFSET);
if (addr == MAP_FAILED) {
perror("mmap");
unlink(FILE_NAME);
exit(1);
}
for (i = 0; i < LENGTH; i+= HPAGE_SIZE)
addr[i] = 1;
ftruncate(fd, TRUNCATE);
close(fd);
unlink(FILE_NAME);
return s;
}
next prev parent reply other threads:[~2006-10-25 23:49 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-25 2:31 [PATCH 1/3] hugetlb: fix size=4G parsing Hugh Dickins
2006-10-25 2:35 ` [PATCH 2/3] hugetlb: fix prio_tree unit Hugh Dickins
2006-10-25 7:08 ` David Gibson
2006-10-25 7:41 ` Hugh Dickins
2006-10-25 23:49 ` Chen, Kenneth W [this message]
2006-10-26 3:47 ` David Gibson
2006-10-26 6:15 ` Chen, Kenneth W
2006-10-26 7:55 ` Hugh Dickins
2006-10-26 8:13 ` Hugh Dickins
2006-10-26 10:42 ` David Gibson
2006-10-25 2:38 ` [PATCH 3/3] hugetlb: fix absurd HugePages_Rsvd Hugh Dickins
2006-10-25 5:23 ` Mika Penttilä
2006-10-25 5:52 ` David Gibson
2006-10-25 7:27 ` Hugh Dickins
2006-10-25 6:26 ` David Gibson
2006-10-25 6:29 ` David Gibson
2006-10-25 8:39 ` Hugh Dickins
2006-10-25 10:09 ` David Gibson
2006-10-26 3:59 ` Chen, Kenneth W
2006-10-26 4:13 ` 'David Gibson'
2006-10-26 19:08 ` Christoph Lameter
2006-10-26 19:19 ` Chen, Kenneth W
2006-10-26 20:59 ` Christoph Lameter
2006-10-26 22:19 ` 'David Gibson'
2006-10-25 21:31 ` Adam Litke
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='000001c6f890$373fb960$12d0180a@amr.corp.intel.com' \
--to=kenneth.w.chen@intel.com \
--cc=agl@us.ibm.com \
--cc=akpm@osdl.org \
--cc=david@gibson.dropbear.id.au \
--cc=hugh@veritas.com \
--cc=linux-mm@kvack.org \
--cc=wli@holomorphy.com \
/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