* [PATCH i-g-t] lib: Do two writes to /proc/sys/vm/drop_caches again
@ 2016-09-27 7:45 Petri Latvala
2016-09-27 7:57 ` Chris Wilson
0 siblings, 1 reply; 4+ messages in thread
From: Petri Latvala @ 2016-09-27 7:45 UTC (permalink / raw)
To: intel-gfx
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.
Signed-off-by: Petri Latvala <petri.latvala@intel.com>
---
lib/intel_os.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/lib/intel_os.c b/lib/intel_os.c
index b9f970d..cb3b062 100644
--- a/lib/intel_os.c
+++ b/lib/intel_os.c
@@ -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);
}
--
2.9.3
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH i-g-t] lib: Do two writes to /proc/sys/vm/drop_caches again
2016-09-27 7:45 [PATCH i-g-t] lib: Do two writes to /proc/sys/vm/drop_caches again Petri Latvala
@ 2016-09-27 7:57 ` Chris Wilson
2016-09-27 9:22 ` Petri Latvala
0 siblings, 1 reply; 4+ messages in thread
From: Chris Wilson @ 2016-09-27 7:57 UTC (permalink / raw)
To: Petri Latvala; +Cc: intel-gfx
On Tue, Sep 27, 2016 at 10:45:17AM +0300, Petri Latvala wrote:
> 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.
>
> Signed-off-by: Petri Latvala <petri.latvala@intel.com>
> ---
> lib/intel_os.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/lib/intel_os.c b/lib/intel_os.c
> index b9f970d..cb3b062 100644
> --- a/lib/intel_os.c
> +++ b/lib/intel_os.c
> @@ -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
--
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH i-g-t] lib: Do two writes to /proc/sys/vm/drop_caches again
2016-09-27 7:57 ` Chris Wilson
@ 2016-09-27 9:22 ` Petri Latvala
2016-09-27 9:41 ` Chris Wilson
0 siblings, 1 reply; 4+ messages in thread
From: Petri Latvala @ 2016-09-27 9:22 UTC (permalink / raw)
To: intel-gfx
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>
---
lib/intel_os.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/lib/intel_os.c b/lib/intel_os.c
index b9f970d..e448bb4 100644
--- a/lib/intel_os.c
+++ b/lib/intel_os.c
@@ -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);
}
--
2.9.3
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH i-g-t] lib: Do two writes to /proc/sys/vm/drop_caches again
2016-09-27 9:22 ` Petri Latvala
@ 2016-09-27 9:41 ` Chris Wilson
0 siblings, 0 replies; 4+ messages in thread
From: Chris Wilson @ 2016-09-27 9:41 UTC (permalink / raw)
To: Petri Latvala; +Cc: intel-gfx
On Tue, Sep 27, 2016 at 12:22:12PM +0300, Petri Latvala wrote:
> 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>
Thanks, pushed. The sysctl being a bitmask and not accepting the full
range is a bit surprising.
-Chris
--
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-09-27 9:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-27 7:45 [PATCH i-g-t] lib: Do two writes to /proc/sys/vm/drop_caches again Petri Latvala
2016-09-27 7:57 ` Chris Wilson
2016-09-27 9:22 ` Petri Latvala
2016-09-27 9:41 ` Chris Wilson
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.