lib: Do two writes to /proc/sys/vm/drop_caches again
PATCH 1/1 lib: Do two writes to /proc/sys/vm/drop_caches again
The drop_caches sysctl has a max value of 4, so writing 7 to it just fails. Avoid the earlier two-writes problem by seeking to the beginning between writes.
--- lib/intel_os.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
lib/intel_os.c +7 -2
@@ -299,11 +299,16 @@ void intel_purge_vm_caches(void)if (fd <0 )return ; +/* BIT(2): Be quiet. Cannot be combined with other operations, +* the sysctl has a max value of 4. +*/ +igt_ignore_warn (write (fd,"4\n" ,2 )); +igt_assert (lseek (fd,0 ,SEEK_SET ) ==0 ); +/* BIT(0): Drop page cache * BIT(1): Drop slab cache -* BIT(2): Be quiet in future */ -igt_ignore_warn (write (fd,"7\n" ,2 )); +igt_ignore_warn (write (fd,"3\n" ,2 ));close (fd); }
Signature · 6 lines
2.9.3 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 14 lines · Petri Latvala
The
drop_cachessysctl has a max value of 4, so writing 7 to it just fails. Avoid the earlier two-writes problem by seeking to the beginning between writes.Signed-off-by Petri Latvala <[email protected]>--- lib/intel_os.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)lib/intel_os.c +0
-0
lib/intel_os.c void intel_purge_vm_caches(void) · line 306
Quoted 8 lines
lib/intel_os.c +5
-0@@ -299,11 +299,16 @@ void intel_purge_vm_caches(void)if (fd <0 )return ; +/* BIT(2): Be quiet. Cannot be combined with other operations, +* the sysctl has a max value of 4. +*/ +igt_ignore_warn (write (fd,"4\n" ,2 )); +igt_assert (lseek (fd,0 ,SEEK_SET ) ==0 );
Don't assert here. If you think it might fail, just close and reopen. -Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 1/1 lib: Do two writes to /proc/sys/vm/drop_caches again
The drop_caches sysctl has a max value of 4, so writing 7 to it just fails. Avoid the earlier two-writes problem by opening the fd twice.
v2: Don't lseek(), open() twice. (Chris)
--- lib/intel_os.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
lib/intel_os.c +11 -2
@@ -299,11 +299,20 @@ void intel_purge_vm_caches(void)if (fd <0 )return ; +/* BIT(2): Be quiet. Cannot be combined with other operations, +* the sysctl has a max value of 4. +*/ +igt_ignore_warn (write (fd,"4\n" ,2 )); +close (fd); + + fd =open ("/proc/sys/vm/drop_caches" ,O_WRONLY ); +if (fd <0 ) +return ; +/* BIT(0): Drop page cache * BIT(1): Drop slab cache -* BIT(2): Be quiet in future */ -igt_ignore_warn (write (fd,"7\n" ,2 )); +igt_ignore_warn (write (fd,"3\n" ,2 ));close (fd); }
Signature · 6 lines
2.9.3 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 6 lines · Petri Latvala
The
drop_cachessysctl has a max value of 4, so writing 7 to it just fails. Avoid the earlier two-writes problem by opening the fd twice.v2: Don't
lseek(),open()twice. (Chris)Signed-off-by Petri Latvala <[email protected]>
Thanks, pushed. The sysctl being a bitmask and not accepting the full range is a bit surprising.
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx