Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static __init int memcpy_align_selftest(void)
- {
- struct page *page1, *page2;
- char *dst, *src;
- int err = 0;
- int i, j;
- ktime_t j0, j1;
- printk("Strings selftest: testing with size: %d\n", PG_SIZE);
- page1 = alloc_pages(GFP_KERNEL, MAX_ORDER-1);
- if (!page1)
- return 1;
- page2 = alloc_pages(GFP_KERNEL, MAX_ORDER-1);
- if (!page2) {
- err = 1;
- goto free1;
- }
- src = page_to_virt(page1);
- dst = page_to_virt(page1);
- preempt_disable();
- for (i = 0; i < sizeof(void*); i++) {
- for (j = 0; j < sizeof(void*); j++) {
- t0 = ktime_get();
- memcpy(dst + j, src + i, PG_SIZE - max(i, j));
- t1 = ktime_get();
- printk("Strings selftest: memcpy(src+%d, dst+%d): %llu Mb/s\n", i, j, PG_SIZE * (1000000000l / 1048576l) / (t1-t0));
- }
- }
- preempt_enable();
- put_page(page2);
- free1:
- put_page(page1);
- return err;
- }
- static __init int memset_align_selftest(void)
- {
- struct page *page;
- ktime_t t0, t1;
- char *dst;
- int i;
- printk("Strings selftest: testing with size: %d\n", PG_SIZE);
- page = alloc_pages(GFP_KERNEL, MAX_ORDER-1);
- if (!page)
- return 1;
- dst = page_to_virt(page);
- preempt_disable();
- for (i = 0; i < sizeof(void*); i++) {
- t0 = ktime_get();
- memset(dst + i, 0, PG_SIZE - i);
- t1 = ktime_get();
- printk("Strings selftest: memset(dst+%d): %llu Mb/s\n", i, PG_SIZE * (1000000000l / 1048576l) / (t1-t0));
- }
- preempt_enable();
- put_page(page);
- return 0;
- }
Add Comment
Please, Sign In to add comment