+ mmap_mem = mmap((void *)0x60000000, 0x100000, PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+
+ // find safe location for section map, we'll use fb
+ fbdev = open("/dev/fb0", O_RDWR);
+ if (fbdev == -1) {
+ perror("fb open");
+ goto out;
+ }
+
+ ret = ioctl(fbdev, FBIOGET_FSCREENINFO, &fbfix);
+ if (ret == -1) {
+ perror("ioctl(fbdev)");
+ goto out;
+ }
+
+ section_mem = (void *)0x70000000;
+ ret = warm_mmap_section(section_mem, fbfix.smem_start, 0x100000,
+ WCB_C_BIT|WCB_B_BIT);
+ if (ret != 0) {
+ fprintf(stderr, "section map failed\n");
+ goto out;
+ }
+
+ // prefault
+ memset(mmap_mem, 0, 0x100000);
+ memset(section_mem, 0, 0x100000);
+
+ ONE_TEST(REP, page_writes_ref(mmap_mem));
+ show_result("page_wr_ref_m", 0x100000 * REP);
+
+ ONE_TEST(REP, page_inc_ref(mmap_mem));
+ show_result("page_inc_ref_m", 0x100000 * REP);
+
+ ONE_TEST(REP, page_writes_ref(section_mem));
+ show_result("page_wr_ref_s", 0x100000 * REP);
+
+ ONE_TEST(REP, page_inc_ref(section_mem));
+ show_result("page_inc_ref_s", 0x100000 * REP);
+
+ printf("== pages ==\n");
+ page_tests(mmap_mem);
+
+ printf("== section ==\n");
+ printf("-- default --\n");
+ page_tests(section_mem);
+
+ printf("-- ncnb --\n");
+ warm_change_cb_range(WCB_C_BIT|WCB_B_BIT, 0, section_mem, 0x100000);
+ page_tests(section_mem);
+
+ printf("-- nc b --\n");
+ warm_change_cb_range(WCB_B_BIT, 1, section_mem, 0x100000);
+ page_tests(section_mem);
+
+ printf("-- cnb --\n");
+ warm_change_cb_range(WCB_C_BIT, 1, section_mem, 0x100000);
+ warm_change_cb_range(WCB_B_BIT, 0, section_mem, 0x100000);
+ page_tests(section_mem);
+
+ warm_munmap_section(section_mem, 0x100000);
+
+out: