diff options
author | Petri Latvala <petri.latvala@intel.com> | 2016-09-27 12:22:12 +0300 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2016-09-27 10:39:54 +0100 |
commit | d16318ade57a75455f2130c1396d100e351e1ecd (patch) | |
tree | 1e1535030d87df1ddb2cecb2338c04cb9a7705e6 /lib/intel_os.c | |
parent | 823ee3e4887d7265afddff9aeafa7843566b3167 (diff) |
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)
Signed-off-by: Petri Latvala <petri.latvala@intel.com>
Diffstat (limited to 'lib/intel_os.c')
-rw-r--r-- | lib/intel_os.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/intel_os.c b/lib/intel_os.c index b9f970df..0f9af634 100644 --- a/lib/intel_os.c +++ b/lib/intel_os.c @@ -296,14 +296,26 @@ void intel_purge_vm_caches(void) int fd; fd = open("/proc/sys/vm/drop_caches", O_WRONLY); + if (fd >= 0) { + /* 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); + } + + /* Reset write position back to start. Do as a seperate write to keep + * the stages segregated and avoid failure from the squelching stopping + * the purge. + */ + 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); } |