4 #include <linux/kernel.h> 5 #include <linux/types.h> 10 #include <sys/resource.h> 11 #include <api/fs/fs.h> 20 #define TEMPL "/tmp/perf-test-XXXXXX" 21 static char buf_templ[
sizeof(
TEMPL)];
22 char *templ = buf_templ;
26 strcpy(buf_templ,
TEMPL);
31 perror(
"mkstemp failed");
41 for (i = 0; i <
size; i++)
42 buf[i] = (
unsigned char) ((int) i % 10);
44 if (size != write(fd, buf, size))
52 #define TEST_FILE_SIZE (DSO__DATA_CACHE_SIZE * 20) 64 .data = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
70 .data = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
76 .data = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
82 .data = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
88 .data = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
94 .data = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
100 .data = { 7, 8, 9, 0, 0, 0, 0, 0, 0, 0 },
125 memset(&machine, 0,
sizeof(machine));
133 for (i = 0; i < ARRAY_SIZE(offsets); i++) {
156 for (c = 0; c < 2; c++) {
164 for (i = 0; i < (size_t)size; i++)
184 scnprintf(path,
PATH_MAX,
"%s/self/fd", procfs__mountpoint());
190 while ((dent = readdir(dir)) != NULL) {
191 if (!strcmp(dent->d_name,
".") ||
192 !strcmp(dent->d_name,
".."))
208 dsos =
malloc(
sizeof(*dsos) * cnt);
211 for (i = 0; i < cnt; i++) {
228 for (i = 0; i < cnt; i++) {
229 struct dso *
dso = dsos[i];
242 if (getrlimit(RLIMIT_NOFILE, &rlim))
245 pr_debug(
"file limit %ld, new %d\n", (
long) rlim.rlim_cur, n);
248 return setrlimit(RLIMIT_NOFILE, &rlim);
255 int dso_cnt, limit, i, fd;
260 memset(&machine, 0,
sizeof(machine));
271 for (i = 0; i < (dso_cnt - 1); i++) {
272 struct dso *
dso = dsos[i];
306 pr_debug(
"nr start %ld, nr stop %ld\n", nr, nr_end);
317 #define dso_0 (dsos[0]) 318 #define dso_1 (dsos[1]) 319 #define dso_2 (dsos[2]) 324 memset(&machine, 0,
sizeof(machine));
353 fd_extra = open(
"/dev/null", O_RDONLY);
382 pr_debug(
"nr start %ld, nr stop %ld\n", nr, nr_end);
static long open_files_cnt(void)
#define TEST_ASSERT_VAL(text, cond)
void reset_fd_limit(void)
int dso__data_get_fd(struct dso *dso, struct machine *machine)
static int set_fd_limit(int n)
x86 movsq based memset() in arch/x86/lib/memset_64.S") MEMSET_FN(memset_erms
void dso__put(struct dso *dso)
#define pr_debug(fmt,...)
static char * test_file(int size)
static int dsos__create(int cnt, int size)
static void dsos__delete(int cnt)
struct test_data_offset offsets[]
static int dso__data_fd(struct dso *dso, struct machine *machine)
int test__dso_data(struct test *test __maybe_unused, int subtest __maybe_unused)
static struct dso ** dsos
struct dso * dso__new(const char *name)
int test__dso_data_cache(struct test *test __maybe_unused, int subtest __maybe_unused)
#define DSO__DATA_CACHE_SIZE
int test__dso_data_reopen(struct test *test __maybe_unused, int subtest __maybe_unused)
ssize_t dso__data_read_offset(struct dso *dso, struct machine *machine, u64 offset, u8 *data, ssize_t size)
void dso__data_put_fd(struct dso *dso __maybe_unused)