Skip to contentSkip to conversation

igt/gem_fd_exhaustion: Actually test error handling on fd exhaustion

PATCH Superseded Karol Krol 3 participants 5 messages Feb 27, 2018

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Karol Krol

author
#0 lore raw

PATCH 1/2 igt/gem_fd_exhaustion: Actually test error handling on fd exhaustion

Long time ago, there was an issue with driver crashing due to lack of error handling on struct file creation (gem_create()). We're unable to hit this scenario, because dup() does not creat flip. Let's replace dup() with open() and assert that error is returned on exhaustion.

---
 tests/gem_fd_exhaustion.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tests/gem_fd_exhaustion.c +3 -1
index 0969f9c6..6750444e 100644
@@ -65,7 +65,7 @@ igt_simple_main
 		igt_drop_root();
 
 		for (int i = 0; ; i++) {
-			int leak = dup(fd);
+			int leak = open("/dev/null", O_RDONLY);
 			uint32_t handle;
 
 			if (__gem_create(fd, 4096, &handle) == 0)
@@ -73,6 +73,8 @@ igt_simple_main
 
 			if (leak < 0) {
 				igt_info("fd exhaustion after %i rounds.\n", i);
+				igt_assert(__gem_create(fd, 4096,
+							&handle) == -ENFILE);
 				break;
 			}
 		}
Signature · 16 lines
2.14.3

--------------------------------------------------------------------

Intel Technology Poland sp. z o.o.
ul. Slowackiego 173 | 80-298 Gdansk | Sad Rejonowy Gdansk Polnoc | VII Wydzial Gospodarczy Krajowego Rejestru Sadowego - KRS 101882 | NIP 957-07-52-316 | Kapital zakladowy 200.000 PLN.

Ta wiadomosc wraz z zalacznikami jest przeznaczona dla okreslonego adresata i moze zawierac informacje poufne. W razie przypadkowego otrzymania tej wiadomosci, prosimy o powiadomienie nadawcy oraz trwale jej usuniecie; jakiekolwiek
przegladanie lub rozpowszechnianie jest zabronione.
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). If you are not the intended recipient, please contact the sender and delete all copies; any review or distribution by
others is strictly prohibited.

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
author
#1 lore raw

PATCH 2/2 igt/gem_fd_exhaustion: Modify fs.nr_open for duration of the test

We also need to adjust fs.nr_open to allow setting rlimit equal to fs.file-max. Otherwise we're getting EPREM on setrlimit().

---
 tests/gem_fd_exhaustion.c | 49 ++++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 42 insertions(+), 7 deletions(-)
tests/gem_fd_exhaustion.c +42 -7
index 6750444e..aa3fe8b3 100644
@@ -33,17 +33,44 @@
 #include <fcntl.h>
 #include <limits.h>
 
+unsigned int original_nr_open;
+
+static int read_sysctl(const char *path)
+{
+	unsigned int val;
+	FILE *f = fopen(path, "r");
+
+	if (f) {
+		igt_assert(fscanf(f, "%u", &val) == 1);
+		fclose(f);
+		return val;
+	}
+	return -errno;
+}
+
+static int write_sysctl(const char *path, unsigned int val)
+{
+	FILE *f = fopen(path, "w");
+
+	if (f) {
+		igt_assert(fprintf(f, "%u", val));
+		fclose(f);
+		return 0;
+	}
+	return -errno;
+}
+
 static bool allow_unlimited_files(void)
 {
+	unsigned int nofile_rlim = 1024*1024;
 	struct rlimit rlim;
-	unsigned nofile_rlim = 1024*1024;
+	unsigned int buf;
 
-	FILE *file = fopen("/proc/sys/fs/file-max", "r");
-	if (file) {
-		igt_assert(fscanf(file, "%u", &nofile_rlim) == 1);
-		igt_info("System limit for open files is %u\n", nofile_rlim);
-		fclose(file);
-	}
+	buf = read_sysctl("/proc/sys/fs/file-max");
+	if (buf > 0)
+		nofile_rlim = buf;
+	original_nr_open = read_sysctl("/proc/sys/fs/nr_open");
+	igt_assert(write_sysctl("/proc/sys/fs/nr_open", nofile_rlim) == 0);
 
 	if (getrlimit(RLIMIT_NOFILE, &rlim))
 		return false;
@@ -53,6 +80,12 @@ static bool allow_unlimited_files(void)
 	return setrlimit(RLIMIT_NOFILE, &rlim) == 0;
 }
 
+static void restore_original_sysctl(void)
+{
+	if (original_nr_open > 0)
+		write_sysctl("/proc/sys/fs/nr_open", original_nr_open);
+}
+
 igt_simple_main
 {
 	int fd;
@@ -61,6 +94,8 @@ igt_simple_main
 
 	fd = drm_open_driver(DRIVER_INTEL);
 
+	igt_install_exit_handler(restore_original_sysctl);
+
 	igt_fork(n, 1) {
 		igt_drop_root();
 
Signature · 16 lines
2.14.3

--------------------------------------------------------------------

Intel Technology Poland sp. z o.o.
ul. Slowackiego 173 | 80-298 Gdansk | Sad Rejonowy Gdansk Polnoc | VII Wydzial Gospodarczy Krajowego Rejestru Sadowego - KRS 101882 | NIP 957-07-52-316 | Kapital zakladowy 200.000 PLN.

Ta wiadomosc wraz z zalacznikami jest przeznaczona dla okreslonego adresata i moze zawierac informacje poufne. W razie przypadkowego otrzymania tej wiadomosci, prosimy o powiadomienie nadawcy oraz trwale jej usuniecie; jakiekolwiek
przegladanie lub rozpowszechnianie jest zabronione.
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). If you are not the intended recipient, please contact the sender and delete all copies; any review or distribution by
others is strictly prohibited.

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw
In reply to Karol Krol

Quoting Karol Krol (2018-02-27 14:30:43)

Quoted 24 lines

Long time ago, there was an issue with driver crashing due to lack of error handling on struct file creation (gem_create()). We're unable to hit this scenario, because dup() does not creat flip. Let's replace dup() with open() and assert that error is returned on exhaustion.

---
 tests/gem_fd_exhaustion.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tests/gem_fd_exhaustion.c +1 -1
index 0969f9c6..6750444e 100644
@@ -65,7 +65,7 @@ igt_simple_main
                igt_drop_root();
 
                for (int i = 0; ; i++) {
-                       int leak = dup(fd);
+                       int leak = open("/dev/null", O_RDONLY);
                        uint32_t handle;
 
                        if (__gem_create(fd, 4096, &handle) == 0)

tests/gem_fd_exhaustion.c igt_simple_main · line 77

Quoted 5 lines
tests/gem_fd_exhaustion.c +2 -0
@@ -73,6 +73,8 @@ igt_simple_main
 
                        if (leak < 0) {
                                igt_info("fd exhaustion after %i rounds.\n", i);
+                               igt_assert(__gem_create(fd, 4096,
+                                                       &handle) == -ENFILE);

No. It can fail for a variety of reasons (ENOMEM is an easy one), so you cannot mandate it always fails with ENFILE.
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#3 lore raw

✓ Fi.CI.BAT: success for series starting with [1/2] igt/gem_fd_exhaustion: Actually test error handling on fd exhaustion

In reply to Karol Krol
== Series Details ==

== Series Details ==

Series: series starting with [1/2] igt/gem_fd_exhaustion: Actually test error handling on fd exhaustion
URL : https://patchwork.freedesktop.org/series/39051/
State : success

== Summary ==

IGT patchset tested on top of latest successful build 77411862d239916b40e218eeb6519b8f31fc7f1d meson: Get rid of lib_headers

with latest DRM-Tip kernel build CI_DRM_3839
aea43a430276 drm-tip: 2018y-02m-27d-10h-49m-38s UTC integration manifest

No testlist changes.

---- Possible new issues:

Test kms_force_connector_basic:

        Subgroup force-connector-state:
                skip       -> PASS       (fi-ivb-3520m)
        Subgroup force-edid:
                skip       -> PASS       (fi-ivb-3520m)
        Subgroup force-load-detect:
                skip       -> PASS       (fi-ivb-3520m)
        Subgroup prune-stale-modes:
                skip       -> PASS       (fi-ivb-3520m)

---- Known issues:

Test gem_mmap_gtt:

        Subgroup basic-small-bo-tiledx:
                pass       -> FAIL       (fi-gdg-551) fdo#102575
Test kms_pipe_crc_basic:
        Subgroup suspend-read-crc-pipe-b:
                pass       -> INCOMPLETE (fi-snb-2520m) fdo#103713
        Subgroup suspend-read-crc-pipe-c:
                incomplete -> PASS       (fi-bxt-dsi) fdo#103927

fdo#102575 https://bugs.freedesktop.org/show_bug.cgi?id=102575
fdo#103713 https://bugs.freedesktop.org/show_bug.cgi?id=103713
fdo#103927 https://bugs.freedesktop.org/show_bug.cgi?id=103927

fi-bdw-5557u     total:288  pass:265  dwarn:0   dfail:0   fail:2   skip:21  time:438s
fi-bdw-gvtdvm    total:288  pass:264  dwarn:0   dfail:0   fail:0   skip:24  time:424s
fi-blb-e6850     total:288  pass:223  dwarn:1   dfail:0   fail:0   skip:64  time:375s
fi-bsw-n3050     total:288  pass:242  dwarn:0   dfail:0   fail:0   skip:46  time:488s
fi-bwr-2160      total:288  pass:183  dwarn:0   dfail:0   fail:0   skip:105 time:286s
fi-bxt-dsi       total:288  pass:258  dwarn:0   dfail:0   fail:0   skip:30  time:479s
fi-bxt-j4205     total:288  pass:259  dwarn:0   dfail:0   fail:0   skip:29  time:481s
fi-byt-j1900     total:288  pass:253  dwarn:0   dfail:0   fail:0   skip:35  time:470s
fi-byt-n2820     total:288  pass:249  dwarn:0   dfail:0   fail:0   skip:39  time:456s
fi-cfl-8700k     total:288  pass:260  dwarn:0   dfail:0   fail:0   skip:28  time:391s
fi-cfl-s2        total:288  pass:262  dwarn:0   dfail:0   fail:0   skip:26  time:560s
fi-cnl-y3        total:288  pass:262  dwarn:0   dfail:0   fail:0   skip:26  time:565s
fi-elk-e7500     total:288  pass:229  dwarn:0   dfail:0   fail:0   skip:59  time:414s
fi-gdg-551       total:288  pass:179  dwarn:0   dfail:0   fail:1   skip:108 time:286s
fi-glk-1         total:288  pass:260  dwarn:0   dfail:0   fail:0   skip:28  time:505s
fi-hsw-4770      total:288  pass:259  dwarn:0   dfail:0   fail:2   skip:27  time:408s
fi-ilk-650       total:288  pass:228  dwarn:0   dfail:0   fail:0   skip:60  time:417s
fi-ivb-3520m     total:288  pass:259  dwarn:0   dfail:0   fail:0   skip:29  time:463s
fi-ivb-3770      total:288  pass:255  dwarn:0   dfail:0   fail:0   skip:33  time:410s
fi-kbl-7500u     total:288  pass:263  dwarn:1   dfail:0   fail:0   skip:24  time:450s
fi-kbl-7560u     total:288  pass:269  dwarn:0   dfail:0   fail:0   skip:19  time:493s
fi-kbl-7567u     total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:450s
fi-kbl-r         total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:496s
fi-pnv-d510      total:288  pass:222  dwarn:1   dfail:0   fail:0   skip:65  time:586s
fi-skl-6260u     total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:424s
fi-skl-6600u     total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:502s
fi-skl-6700hq    total:288  pass:262  dwarn:0   dfail:0   fail:0   skip:26  time:522s
fi-skl-6700k2    total:288  pass:264  dwarn:0   dfail:0   fail:0   skip:24  time:493s
fi-skl-6770hq    total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:470s
fi-skl-guc       total:288  pass:260  dwarn:0   dfail:0   fail:0   skip:28  time:407s
fi-skl-gvtdvm    total:288  pass:265  dwarn:0   dfail:0   fail:0   skip:23  time:429s
fi-snb-2520m     total:245  pass:211  dwarn:0   dfail:0   fail:0   skip:33 
fi-snb-2600      total:288  pass:248  dwarn:0   dfail:0   fail:0   skip:40  time:392s

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1014/issues.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#4 lore raw

✗ Fi.CI.IGT: failure for series starting with [1/2] igt/gem_fd_exhaustion: Actually test error handling on fd exhaustion

In reply to Karol Krol
== Series Details ==

== Series Details ==

Series: series starting with [1/2] igt/gem_fd_exhaustion: Actually test error handling on fd exhaustion
URL : https://patchwork.freedesktop.org/series/39051/
State : failure

== Summary ==

---- Possible new issues:

Test kms_vblank:

        Subgroup pipe-b-ts-continuation-modeset-rpm:
                fail       -> PASS       (shard-hsw)
        Subgroup pipe-b-ts-continuation-suspend:
                skip       -> PASS       (shard-snb)
        Subgroup pipe-c-ts-continuation-dpms-rpm:
                fail       -> PASS       (shard-hsw)
Test pm_rpm:
        Subgroup basic-pci-d3-state:
                pass       -> FAIL       (shard-hsw)
        Subgroup cursor-dpms:
                pass       -> FAIL       (shard-hsw)
        Subgroup debugfs-read:
                pass       -> FAIL       (shard-hsw)
        Subgroup dpms-mode-unset-non-lpsp:
                fail       -> PASS       (shard-hsw)
        Subgroup gem-evict-pwrite:
                fail       -> PASS       (shard-hsw)
        Subgroup gem-execbuf:
                fail       -> PASS       (shard-hsw)
        Subgroup gem-execbuf-stress-extra-wait:
                fail       -> PASS       (shard-hsw)
        Subgroup gem-idle:
                fail       -> PASS       (shard-hsw)
        Subgroup gem-mmap-cpu:
                fail       -> PASS       (shard-hsw)
        Subgroup i2c:
                fail       -> PASS       (shard-hsw)
        Subgroup modeset-lpsp:
                fail       -> SKIP       (shard-hsw)
        Subgroup modeset-lpsp-stress:
                fail       -> SKIP       (shard-hsw)
        Subgroup pm-caching:
                fail       -> PASS       (shard-hsw)

---- Known issues:

Test gem_eio:

        Subgroup in-flight:
                incomplete -> PASS       (shard-apl) fdo#104945
Test kms_flip:
        Subgroup flip-vs-expired-vblank:
                fail       -> PASS       (shard-hsw) fdo#102887
Test kms_rotation_crc:
        Subgroup sprite-rotation-180:
                fail       -> PASS       (shard-snb) fdo#103925
Test kms_vblank:
        Subgroup pipe-b-accuracy-idle:
                pass       -> FAIL       (shard-hsw) fdo#102583
Test perf:
        Subgroup buffer-fill:
                pass       -> FAIL       (shard-apl) fdo#103755
        Subgroup enable-disable:
                fail       -> PASS       (shard-apl) fdo#103715
Test perf_pmu:
        Subgroup rc6-runtime-pm-long:
                skip       -> PASS       (shard-hsw) fdo#105010
Test pm_lpsp:
        Subgroup screens-disabled:
                fail       -> PASS       (shard-hsw) fdo#104941

fdo#104945 https://bugs.freedesktop.org/show_bug.cgi?id=104945
fdo#102887 https://bugs.freedesktop.org/show_bug.cgi?id=102887
fdo#103925 https://bugs.freedesktop.org/show_bug.cgi?id=103925
fdo#102583 https://bugs.freedesktop.org/show_bug.cgi?id=102583
fdo#103755 https://bugs.freedesktop.org/show_bug.cgi?id=103755
fdo#103715 https://bugs.freedesktop.org/show_bug.cgi?id=103715
fdo#105010 https://bugs.freedesktop.org/show_bug.cgi?id=105010
fdo#104941 https://bugs.freedesktop.org/show_bug.cgi?id=104941

shard-apl        total:3460 pass:1819 dwarn:1   dfail:0   fail:8   skip:1632 time:12240s
shard-hsw        total:3460 pass:1735 dwarn:1   dfail:0   fail:34  skip:1689 time:11625s
shard-snb        total:3460 pass:1359 dwarn:1   dfail:0   fail:1   skip:2099 time:6641s

Blacklisted hosts:
shard-kbl total:3460 pass:1941 dwarn:5 dfail:0 fail:7 skip:1507 time:9647s

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1014/shards.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx