Re: [Intel-gfx] [i-g-t] dumb_buffer@clear_create triggers OOM since 0b0eaa353

2020-04-25 Thread Li Zhijian



On 4/23/20 5:38 PM, Li Zhijian wrote:

Hi guys

0Day noticed that dumb_buffer@clear_create triggers OOM  since commit: 
0b0eaa353 ("tests/dumb_buffer: Try to compute the largest possible 
dumb buffer")


our platform is
- CPU: Intel(R) Xeon(R) CPU D-1541 @ 2.10GHz
- memory: 48G
- kernel: v5.5, v5.6, v5.7-rc2

i tried 2 other platforms
- i7-3770K + 16G
- AMD Opteron(TM) Processor 6276 + 128G
dumb_buffer@clear_create works well on both of them.

i have no enough knowledge in IGT and Kernel Graphic Driver, so if you 
want to more debug info, please let me know.



Thanks






i tried to add some debug into the code as following
diff --git a/tests/dumb_buffer.c b/tests/dumb_buffer.c
index c1e7b4d3..22611f95 100644
--- a/tests/dumb_buffer.c
+++ b/tests/dumb_buffer.c
@@ -58,11 +58,13 @@ static int __dumb_create(int fd, struct 
drm_mode_create_dumb *create)

 {
    int err = 0;

+   igt_info("start __dumb_create %ld\n", create->size);
    if (igt_ioctl(fd, DRM_IOCTL_MODE_CREATE_DUMB, create)) {
    err = -errno;
    igt_assume(err);
    }

+   igt_info("end __dumb_create %ld, err %d\n", create->size, err);
    errno = 0;
    return err;
 }
@@ -80,10 +82,12 @@ static void *__dumb_map(int fd, uint32_t handle, 
uint64_t size, unsigned prot)

    if (igt_ioctl(fd, DRM_IOCTL_MODE_MAP_DUMB, &arg))
    return NULL;

+   igt_info("size %ld, offset %x\n", size, arg.offset);
    ptr = mmap(NULL, size, prot, MAP_SHARED, fd, arg.offset);
    if (ptr == MAP_FAILED)
    return NULL;

+   igt_info("mmap success, size %ld, offset %x\n", size, 
arg.offset);

    return ptr;
 }

@@ -356,6 +360,7 @@ static uint64_t estimate_largest_dumb_buffer(int fd)
    return largest / PAGE_SIZE;
    }

+   sleep(1);
    for (create.height = 1; create.height; create.height *= 2) {
    if (__dumb_create(fd, &create))
    longjmp(sigjmp, SIGABRT);
@@ -368,7 +373,9 @@ static uint64_t estimate_largest_dumb_buffer(int fd)
    if (!*ptr)
    largest = create.size;

+   igt_info("mmap %ld\n", create.size);
    munmap(ptr, create.size);
+   igt_info("unmmap %ld\n", create.size);
    ptr = NULL;
    }


then get below outputs:

Subtest map-invalid-size: SUCCESS (0.000s)
Starting subtest: create-clear
start __dumb_create 0
end __dumb_create 4194304, err 0
size 4194304, offset 1a48000
mmap success, size 4194304, offset 1a48000
mmap 4194304
unmmap 4194304
start __dumb_create 4194304
end __dumb_create 8388608, err 0
size 8388608, offset 1a48000
mmap success, size 8388608, offset 1a48000
mmap 8388608
unmmap 8388608
start __dumb_create 8388608
end __dumb_create 16777216, err 0
size 16777216, offset 1a48000
mmap success, size 16777216, offset 1a48000
mmap 16777216
unmmap 16777216
start __dumb_create 16777216
end __dumb_create 33554432, err 0
size 33554432, offset 1a48000
mmap success, size 33554432, offset 1a48000
mmap 33554432
unmmap 33554432
start __dumb_create 33554432
end __dumb_create 67108864, err 0
size 67108864, offset 1a48000
mmap success, size 67108864, offset 1a48000
mmap 67108864
unmmap 67108864
start __dumb_create 67108864
end __dumb_create 134217728, err 0
size 134217728, offset 1a48000
mmap success, size 134217728, offset 1a48000
mmap 134217728
unmmap 134217728
start __dumb_create 134217728
end __dumb_create 268435456, err 0
size 268435456, offset 1a48000
mmap success, size 268435456, offset 1a48000
mmap 268435456
unmmap 268435456
start __dumb_create 268435456
end __dumb_create 536870912, err 0
size 536870912, offset 1a48000
mmap success, size 536870912, offset 1a48000
mmap 536870912
unmmap 536870912
start __dumb_create 536870912
end __dumb_create 1073741824, err 0
size 1073741824, offset 1a48000
mmap success, size 1073741824, offset 1a48000
mmap 1073741824
unmmap 1073741824
start __dumb_create 1073741824
end __dumb_create 2147483648, err 0
size 2147483648, offset 1a48000
mmap success, size 2147483648, offset 1a48000
Killed


attached the dmesg as well[10703.523385] dumb_buffer invoked 
oom-killer: gfp_mask=0x0(), order=0, oom_score_adj=1000
[10703.531385] CPU: 0 PID: 7166 Comm: dumb_buffer Not tainted 
5.6.0-00335-g7111951b8d497 #1
[10703.539466] Hardware name: Supermicro 
SYS-5018D-FN4T/X10SDV-8C-TLN4F, BIOS 1.1 03/02/2016

[10703.547630] Call Trace:
[10703.550080]  dump_stack+0x66/0x8b
[10703.553398]  dump_header+0x4a/0x220
[10703.556889]  oom_kill_process+0xf6/0x150
[10703.560805]  out_of_memory+0x105/0x540
[10703.564548]  pagefault_out_of_memory+0x64/0x80
[10703.568987]  page_fault+0x3e/0x50
[10703.572296] RIP: 0033:0x556f7b09257a
[10703.575867] Code: e8 2b fe ff ff 8b 74 24 40 44 89 f7 48 89 44 24 
28 e8 ea fb ff ff 48 8b 44 24 28 48 85 c0 74 7d 48 8b 44 24 28 48 8b 
4c 24 48 <80> 38 00 75 05 48 89 4c 24

[Intel-gfx] [i-g-t] dumb_buffer@clear_create triggers OOM since 0b0eaa353

2020-04-23 Thread Li Zhijian

Hi guys

0Day noticed that dumb_buffer@clear_create triggers OOM  since commit: 
0b0eaa353 ("tests/dumb_buffer: Try to compute the largest possible dumb 
buffer")


our platform is
- CPU: Intel(R) Xeon(R) CPU D-1541 @ 2.10GHz
- memory: 48G
- kernel: v5.5, v5.6, v5.7-rc2


i tried to add some debug into the code as following
diff --git a/tests/dumb_buffer.c b/tests/dumb_buffer.c
index c1e7b4d3..22611f95 100644
--- a/tests/dumb_buffer.c
+++ b/tests/dumb_buffer.c
@@ -58,11 +58,13 @@ static int __dumb_create(int fd, struct 
drm_mode_create_dumb *create)

 {
    int err = 0;

+   igt_info("start __dumb_create %ld\n", create->size);
    if (igt_ioctl(fd, DRM_IOCTL_MODE_CREATE_DUMB, create)) {
    err = -errno;
    igt_assume(err);
    }

+   igt_info("end __dumb_create %ld, err %d\n", create->size, err);
    errno = 0;
    return err;
 }
@@ -80,10 +82,12 @@ static void *__dumb_map(int fd, uint32_t handle, 
uint64_t size, unsigned prot)

    if (igt_ioctl(fd, DRM_IOCTL_MODE_MAP_DUMB, &arg))
    return NULL;

+   igt_info("size %ld, offset %x\n", size, arg.offset);
    ptr = mmap(NULL, size, prot, MAP_SHARED, fd, arg.offset);
    if (ptr == MAP_FAILED)
    return NULL;

+   igt_info("mmap success, size %ld, offset %x\n", size, arg.offset);
    return ptr;
 }

@@ -356,6 +360,7 @@ static uint64_t estimate_largest_dumb_buffer(int fd)
    return largest / PAGE_SIZE;
    }

+   sleep(1);
    for (create.height = 1; create.height; create.height *= 2) {
    if (__dumb_create(fd, &create))
    longjmp(sigjmp, SIGABRT);
@@ -368,7 +373,9 @@ static uint64_t estimate_largest_dumb_buffer(int fd)
    if (!*ptr)
    largest = create.size;

+   igt_info("mmap %ld\n", create.size);
    munmap(ptr, create.size);
+   igt_info("unmmap %ld\n", create.size);
    ptr = NULL;
    }


then get below outputs:

Subtest map-invalid-size: SUCCESS (0.000s)
Starting subtest: create-clear
start __dumb_create 0
end __dumb_create 4194304, err 0
size 4194304, offset 1a48000
mmap success, size 4194304, offset 1a48000
mmap 4194304
unmmap 4194304
start __dumb_create 4194304
end __dumb_create 8388608, err 0
size 8388608, offset 1a48000
mmap success, size 8388608, offset 1a48000
mmap 8388608
unmmap 8388608
start __dumb_create 8388608
end __dumb_create 16777216, err 0
size 16777216, offset 1a48000
mmap success, size 16777216, offset 1a48000
mmap 16777216
unmmap 16777216
start __dumb_create 16777216
end __dumb_create 33554432, err 0
size 33554432, offset 1a48000
mmap success, size 33554432, offset 1a48000
mmap 33554432
unmmap 33554432
start __dumb_create 33554432
end __dumb_create 67108864, err 0
size 67108864, offset 1a48000
mmap success, size 67108864, offset 1a48000
mmap 67108864
unmmap 67108864
start __dumb_create 67108864
end __dumb_create 134217728, err 0
size 134217728, offset 1a48000
mmap success, size 134217728, offset 1a48000
mmap 134217728
unmmap 134217728
start __dumb_create 134217728
end __dumb_create 268435456, err 0
size 268435456, offset 1a48000
mmap success, size 268435456, offset 1a48000
mmap 268435456
unmmap 268435456
start __dumb_create 268435456
end __dumb_create 536870912, err 0
size 536870912, offset 1a48000
mmap success, size 536870912, offset 1a48000
mmap 536870912
unmmap 536870912
start __dumb_create 536870912
end __dumb_create 1073741824, err 0
size 1073741824, offset 1a48000
mmap success, size 1073741824, offset 1a48000
mmap 1073741824
unmmap 1073741824
start __dumb_create 1073741824
end __dumb_create 2147483648, err 0
size 2147483648, offset 1a48000
mmap success, size 2147483648, offset 1a48000
Killed


attached the dmesg as well[10703.523385] dumb_buffer invoked oom-killer: 
gfp_mask=0x0(), order=0, oom_score_adj=1000
[10703.531385] CPU: 0 PID: 7166 Comm: dumb_buffer Not tainted 
5.6.0-00335-g7111951b8d497 #1
[10703.539466] Hardware name: Supermicro SYS-5018D-FN4T/X10SDV-8C-TLN4F, 
BIOS 1.1 03/02/2016

[10703.547630] Call Trace:
[10703.550080]  dump_stack+0x66/0x8b
[10703.553398]  dump_header+0x4a/0x220
[10703.556889]  oom_kill_process+0xf6/0x150
[10703.560805]  out_of_memory+0x105/0x540
[10703.564548]  pagefault_out_of_memory+0x64/0x80
[10703.568987]  page_fault+0x3e/0x50
[10703.572296] RIP: 0033:0x556f7b09257a
[10703.575867] Code: e8 2b fe ff ff 8b 74 24 40 44 89 f7 48 89 44 24 28 
e8 ea fb ff ff 48 8b 44 24 28 48 85 c0 74 7d 48 8b 44 24 28 48 8b 4c 24 
48 <80> 38 00 75 05 48 89 4c 24 20 48 8d 15 71 0b 00 00 31 ff 31 c0 be

[10703.594613] RSP: 002b:7fff025dc330 EFLAGS: 00010206
[10703.599829] RAX: 7fd2e42cf000 RBX: 7fff025dc360 RCX: 
8000
[10703.606955] RDX: 7fff025dc31c RSI: c00464b4 RDI: 
0003
[10703.614078] RBP: 7fff025dc4e0 R08: 556f7b3b8014 R09: 
0001
[10703.621201] R10: 556f7b3e2530 R11: 0246 R12: