tools/testing/selftests/mm/transhuge-stress.c

Source file repositories/reference/linux-study-clean/tools/testing/selftests/mm/transhuge-stress.c

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/mm/transhuge-stress.c
Extension
.c
Size
3486 bytes
Lines
143
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: implementation source
Status
source implementation candidate

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

if (pfn < 0) {
				nr_failed++;
			} else {
				size_t idx = pfn >> (HPAGE_SHIFT - pshift());

				nr_succeed++;
				if (idx >= map_len) {
					map = realloc(map, idx + 1);
					if (!map)
						ksft_exit_fail_msg("map realloc\n");
					memset(map + map_len, 0, idx + 1 - map_len);
					map_len = idx + 1;
				}
				if (!map[idx])
					nr_pages++;
				map[idx] = 1;
			}

			/* split transhuge page, keep last page */
			if (madvise(p, HPAGE_SIZE - psize(), MADV_DONTNEED))
				ksft_exit_fail_msg("MADV_DONTNEED");
		}
		clock_gettime(CLOCK_MONOTONIC, &b);
		s = b.tv_sec - a.tv_sec + (b.tv_nsec - a.tv_nsec) / 1000000000.;

		ksft_print_msg("%.3f s/loop, %.3f ms/page, %10.3f MiB/s\t"
			       "%4d succeed, %4d failed, %4d different pages\n",
			       s, s * 1000 / (len >> HPAGE_SHIFT), len / s / (1 << 20),
			       nr_succeed, nr_failed, nr_pages);

		if (duration > 0 && b.tv_sec - start.tv_sec >= duration) {
			ksft_test_result_pass("Completed\n");
			ksft_finished();
		}
	}
}

Annotation

Implementation Notes