Merge branch 'akpm' (patches from Andrew)
Merge misc updates from Andrew Morton: "191 patches. Subsystems affected by this patch series: kthread, ia64, scripts, ntfs, squashfs, ocfs2, kernel/watchdog, and mm (gup, pagealloc, slab, slub, kmemleak, dax, debug, pagecache, gup, swap, memcg, pagemap, mprotect, bootmem, dma, tracing, vmalloc, kasan, initialization, pagealloc, and memory-failure)" * emailed patches from Andrew Morton <akpm@linux-foundation.org>: (191 commits) mm,hwpoison: make get_hwpoison_page() call get_any_page() mm,hwpoison: send SIGBUS with error virutal address mm/page_alloc: split pcp->high across all online CPUs for cpuless nodes mm/page_alloc: allow high-order pages to be stored on the per-cpu lists mm: replace CONFIG_FLAT_NODE_MEM_MAP with CONFIG_FLATMEM mm: replace CONFIG_NEED_MULTIPLE_NODES with CONFIG_NUMA docs: remove description of DISCONTIGMEM arch, mm: remove stale mentions of DISCONIGMEM mm: remove CONFIG_DISCONTIGMEM m68k: remove support for DISCONTIGMEM arc: remove support for DISCONTIGMEM arc: update comment about HIGHMEM implementation alpha: remove DISCONTIGMEM and NUMA mm/page_alloc: move free_the_page mm/page_alloc: fix counting of managed_pages mm/page_alloc: improve memmap_pages dbg msg mm: drop SECTION_SHIFT in code comments mm/page_alloc: introduce vm.percpu_pagelist_high_fraction mm/page_alloc: limit the number of pages on PCP lists when reclaim is active mm/page_alloc: scale the number of pages that are batch freed ...
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
#include <sys/mman.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <pthread.h>
|
||||
#include <assert.h>
|
||||
#include "../../../../mm/gup_test.h"
|
||||
|
||||
#define MB (1UL << 20)
|
||||
@@ -15,6 +17,12 @@
|
||||
#define FOLL_WRITE 0x01 /* check pte is writable */
|
||||
#define FOLL_TOUCH 0x02 /* mark page accessed */
|
||||
|
||||
static unsigned long cmd = GUP_FAST_BENCHMARK;
|
||||
static int gup_fd, repeats = 1;
|
||||
static unsigned long size = 128 * MB;
|
||||
/* Serialize prints */
|
||||
static pthread_mutex_t print_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
static char *cmd_to_str(unsigned long cmd)
|
||||
{
|
||||
switch (cmd) {
|
||||
@@ -34,17 +42,55 @@ static char *cmd_to_str(unsigned long cmd)
|
||||
return "Unknown command";
|
||||
}
|
||||
|
||||
void *gup_thread(void *data)
|
||||
{
|
||||
struct gup_test gup = *(struct gup_test *)data;
|
||||
int i;
|
||||
|
||||
/* Only report timing information on the *_BENCHMARK commands: */
|
||||
if ((cmd == PIN_FAST_BENCHMARK) || (cmd == GUP_FAST_BENCHMARK) ||
|
||||
(cmd == PIN_LONGTERM_BENCHMARK)) {
|
||||
for (i = 0; i < repeats; i++) {
|
||||
gup.size = size;
|
||||
if (ioctl(gup_fd, cmd, &gup))
|
||||
perror("ioctl"), exit(1);
|
||||
|
||||
pthread_mutex_lock(&print_mutex);
|
||||
printf("%s: Time: get:%lld put:%lld us",
|
||||
cmd_to_str(cmd), gup.get_delta_usec,
|
||||
gup.put_delta_usec);
|
||||
if (gup.size != size)
|
||||
printf(", truncated (size: %lld)", gup.size);
|
||||
printf("\n");
|
||||
pthread_mutex_unlock(&print_mutex);
|
||||
}
|
||||
} else {
|
||||
gup.size = size;
|
||||
if (ioctl(gup_fd, cmd, &gup)) {
|
||||
perror("ioctl");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&print_mutex);
|
||||
printf("%s: done\n", cmd_to_str(cmd));
|
||||
if (gup.size != size)
|
||||
printf("Truncated (size: %lld)\n", gup.size);
|
||||
pthread_mutex_unlock(&print_mutex);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct gup_test gup = { 0 };
|
||||
unsigned long size = 128 * MB;
|
||||
int i, fd, filed, opt, nr_pages = 1, thp = -1, repeats = 1, write = 1;
|
||||
unsigned long cmd = GUP_FAST_BENCHMARK;
|
||||
int filed, i, opt, nr_pages = 1, thp = -1, write = 1, nthreads = 1, ret;
|
||||
int flags = MAP_PRIVATE, touch = 0;
|
||||
char *file = "/dev/zero";
|
||||
pthread_t *tid;
|
||||
char *p;
|
||||
|
||||
while ((opt = getopt(argc, argv, "m:r:n:F:f:abctTLUuwWSHpz")) != -1) {
|
||||
while ((opt = getopt(argc, argv, "m:r:n:F:f:abcj:tTLUuwWSHpz")) != -1) {
|
||||
switch (opt) {
|
||||
case 'a':
|
||||
cmd = PIN_FAST_BENCHMARK;
|
||||
@@ -74,6 +120,9 @@ int main(int argc, char **argv)
|
||||
/* strtol, so you can pass flags in hex form */
|
||||
gup.gup_flags = strtol(optarg, 0, 0);
|
||||
break;
|
||||
case 'j':
|
||||
nthreads = atoi(optarg);
|
||||
break;
|
||||
case 'm':
|
||||
size = atoi(optarg) * MB;
|
||||
break;
|
||||
@@ -154,8 +203,8 @@ int main(int argc, char **argv)
|
||||
if (write)
|
||||
gup.gup_flags |= FOLL_WRITE;
|
||||
|
||||
fd = open("/sys/kernel/debug/gup_test", O_RDWR);
|
||||
if (fd == -1) {
|
||||
gup_fd = open("/sys/kernel/debug/gup_test", O_RDWR);
|
||||
if (gup_fd == -1) {
|
||||
perror("open");
|
||||
exit(1);
|
||||
}
|
||||
@@ -185,32 +234,17 @@ int main(int argc, char **argv)
|
||||
p[0] = 0;
|
||||
}
|
||||
|
||||
/* Only report timing information on the *_BENCHMARK commands: */
|
||||
if ((cmd == PIN_FAST_BENCHMARK) || (cmd == GUP_FAST_BENCHMARK) ||
|
||||
(cmd == PIN_LONGTERM_BENCHMARK)) {
|
||||
for (i = 0; i < repeats; i++) {
|
||||
gup.size = size;
|
||||
if (ioctl(fd, cmd, &gup))
|
||||
perror("ioctl"), exit(1);
|
||||
|
||||
printf("%s: Time: get:%lld put:%lld us",
|
||||
cmd_to_str(cmd), gup.get_delta_usec,
|
||||
gup.put_delta_usec);
|
||||
if (gup.size != size)
|
||||
printf(", truncated (size: %lld)", gup.size);
|
||||
printf("\n");
|
||||
}
|
||||
} else {
|
||||
gup.size = size;
|
||||
if (ioctl(fd, cmd, &gup)) {
|
||||
perror("ioctl");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
printf("%s: done\n", cmd_to_str(cmd));
|
||||
if (gup.size != size)
|
||||
printf("Truncated (size: %lld)\n", gup.size);
|
||||
tid = malloc(sizeof(pthread_t) * nthreads);
|
||||
assert(tid);
|
||||
for (i = 0; i < nthreads; i++) {
|
||||
ret = pthread_create(&tid[i], NULL, gup_thread, &gup);
|
||||
assert(ret == 0);
|
||||
}
|
||||
for (i = 0; i < nthreads; i++) {
|
||||
ret = pthread_join(tid[i], NULL);
|
||||
assert(ret == 0);
|
||||
}
|
||||
free(tid);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user