mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-06-12 10:26:12 +00:00
lib: Add igt_drop_caches_set()
This is basically a "drop cache" interface to the igt_debugfs facilities. Also, update existing users. Signed-off-by: Oscar Mateo <oscar.mateo@intel.com> Cc: Damien Lespiau <damien.lespiau@intel.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
This commit is contained in:
parent
a97402e89a
commit
5f0ab94c3f
@ -316,3 +316,31 @@ igt_pipe_crc_get_crcs(igt_pipe_crc_t *pipe_crc, int n_crcs,
|
|||||||
|
|
||||||
*out_crcs = crcs;
|
*out_crcs = crcs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Drop caches
|
||||||
|
*/
|
||||||
|
|
||||||
|
int igt_drop_caches_set(uint64_t val)
|
||||||
|
{
|
||||||
|
igt_debugfs_t debugfs;
|
||||||
|
int fd;
|
||||||
|
char data[19];
|
||||||
|
size_t nbytes;
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
|
sprintf(data, "0x%" PRIx64, val);
|
||||||
|
|
||||||
|
igt_debugfs_init(&debugfs);
|
||||||
|
fd = igt_debugfs_open(&debugfs, "i915_gem_drop_caches", O_WRONLY);
|
||||||
|
|
||||||
|
if (fd >= 0)
|
||||||
|
{
|
||||||
|
nbytes = write(fd, data, strlen(data) + 1);
|
||||||
|
if (nbytes == strlen(data) + 1)
|
||||||
|
ret = 0;
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
@ -79,4 +79,19 @@ void igt_pipe_crc_stop(igt_pipe_crc_t *pipe_crc);
|
|||||||
void igt_pipe_crc_get_crcs(igt_pipe_crc_t *pipe_crc, int n_crcs,
|
void igt_pipe_crc_get_crcs(igt_pipe_crc_t *pipe_crc, int n_crcs,
|
||||||
igt_crc_t **out_crcs);
|
igt_crc_t **out_crcs);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Drop caches
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define DROP_UNBOUND 0x1
|
||||||
|
#define DROP_BOUND 0x2
|
||||||
|
#define DROP_RETIRE 0x4
|
||||||
|
#define DROP_ACTIVE 0x8
|
||||||
|
#define DROP_ALL (DROP_UNBOUND | \
|
||||||
|
DROP_BOUND | \
|
||||||
|
DROP_RETIRE | \
|
||||||
|
DROP_ACTIVE)
|
||||||
|
|
||||||
|
int igt_drop_caches_set(uint64_t val);
|
||||||
|
|
||||||
#endif /* __IGT_DEBUGFS_H__ */
|
#endif /* __IGT_DEBUGFS_H__ */
|
||||||
|
@ -42,6 +42,7 @@
|
|||||||
#include "intel_bufmgr.h"
|
#include "intel_bufmgr.h"
|
||||||
#include "intel_batchbuffer.h"
|
#include "intel_batchbuffer.h"
|
||||||
#include "intel_gpu_tools.h"
|
#include "intel_gpu_tools.h"
|
||||||
|
#include "igt_debugfs.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Testcase: Persistent relocations as used by uxa/libva
|
* Testcase: Persistent relocations as used by uxa/libva
|
||||||
@ -287,21 +288,13 @@ static void do_forked_test(int fd, unsigned flags)
|
|||||||
struct igt_helper_process thrasher = {};
|
struct igt_helper_process thrasher = {};
|
||||||
|
|
||||||
if (flags & (THRASH | THRASH_INACTIVE)) {
|
if (flags & (THRASH | THRASH_INACTIVE)) {
|
||||||
char fname[FILENAME_MAX];
|
uint64_t val = (flags & THRASH_INACTIVE) ?
|
||||||
int drop_caches_fd;
|
(DROP_RETIRE | DROP_BOUND | DROP_UNBOUND) : DROP_ALL;
|
||||||
const char *data = (flags & THRASH_INACTIVE) ? "0x7" : "0xf";
|
|
||||||
|
|
||||||
snprintf(fname, FILENAME_MAX, "%s/%i/%s",
|
|
||||||
"/sys/kernel/debug/dri", drm_get_card(),
|
|
||||||
"i915_gem_drop_caches");
|
|
||||||
|
|
||||||
drop_caches_fd = open(fname, O_WRONLY);
|
|
||||||
igt_require(drop_caches_fd >= 0);
|
|
||||||
|
|
||||||
igt_fork_helper(&thrasher) {
|
igt_fork_helper(&thrasher) {
|
||||||
while (1) {
|
while (1) {
|
||||||
usleep(1000);
|
usleep(1000);
|
||||||
igt_assert(write(drop_caches_fd, data, strlen(data) + 1) == strlen(data) + 1);
|
do_or_die(igt_drop_caches_set(val));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,7 @@
|
|||||||
#include "intel_bufmgr.h"
|
#include "intel_bufmgr.h"
|
||||||
#include "intel_batchbuffer.h"
|
#include "intel_batchbuffer.h"
|
||||||
#include "intel_gpu_tools.h"
|
#include "intel_gpu_tools.h"
|
||||||
|
#include "igt_debugfs.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Testcase: Kernel relocations vs. gpu races
|
* Testcase: Kernel relocations vs. gpu races
|
||||||
@ -282,21 +283,13 @@ static void do_forked_test(int fd, unsigned flags)
|
|||||||
struct igt_helper_process thrasher = {};
|
struct igt_helper_process thrasher = {};
|
||||||
|
|
||||||
if (flags & (THRASH | THRASH_INACTIVE)) {
|
if (flags & (THRASH | THRASH_INACTIVE)) {
|
||||||
char fname[FILENAME_MAX];
|
uint64_t val = (flags & THRASH_INACTIVE) ?
|
||||||
int drop_caches_fd;
|
(DROP_RETIRE | DROP_BOUND | DROP_UNBOUND) : DROP_ALL;
|
||||||
const char *data = (flags & THRASH_INACTIVE) ? "0x7" : "0xf";
|
|
||||||
|
|
||||||
snprintf(fname, FILENAME_MAX, "%s/%i/%s",
|
|
||||||
"/sys/kernel/debug/dri", drm_get_card(),
|
|
||||||
"i915_gem_drop_caches");
|
|
||||||
|
|
||||||
drop_caches_fd = open(fname, O_WRONLY);
|
|
||||||
igt_require(drop_caches_fd >= 0);
|
|
||||||
|
|
||||||
igt_fork_helper(&thrasher) {
|
igt_fork_helper(&thrasher) {
|
||||||
while (1) {
|
while (1) {
|
||||||
usleep(1000);
|
usleep(1000);
|
||||||
igt_assert(write(drop_caches_fd, data, strlen(data) + 1) == strlen(data) + 1);
|
do_or_die(igt_drop_caches_set(val));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user