thpsize
#define to_thpsize(kobj) container_of(kobj, struct thpsize, kobj)
static struct thpsize *thpsize_create(int order, struct kobject *parent)
struct thpsize *thpsize;
thpsize = kzalloc_obj(*thpsize);
if (!thpsize)
thpsize->order = order;
ret = kobject_init_and_add(&thpsize->kobj, &thpsize_ktype, parent,
kfree(thpsize);
ret = sysfs_add_group(&thpsize->kobj, &any_ctrl_attr_grp);
ret = sysfs_add_group(&thpsize->kobj, &any_stats_attr_grp);
ret = sysfs_add_group(&thpsize->kobj, &anon_ctrl_attr_grp);
ret = sysfs_add_group(&thpsize->kobj, &anon_stats_attr_grp);
ret = sysfs_add_group(&thpsize->kobj, &file_ctrl_attr_grp);
ret = sysfs_add_group(&thpsize->kobj, &file_stats_attr_grp);
return thpsize;
kobject_put(&thpsize->kobj);
struct thpsize *thpsize;
thpsize = thpsize_create(order, *hugepage_kobj);
if (IS_ERR(thpsize)) {
err = PTR_ERR(thpsize);
list_add(&thpsize->node, &thpsize_list);
struct thpsize *thpsize, *tmp;
list_for_each_entry_safe(thpsize, tmp, &thpsize_list, node) {
list_del(&thpsize->node);
kobject_put(&thpsize->kobj);
static void do_run_with_thp(test_fn fn, enum thp_run thp_run, size_t thpsize)
mmap_size = 2 * thpsize;
mem = (char *)(((uintptr_t)mmap_mem + thpsize) & ~(thpsize - 1));
ret = madvise(mem, thpsize, MADV_HUGEPAGE);
if (!pagemap_is_populated(pagemap_fd, mem + thpsize - pagesize)) {
memset(mem, 1, thpsize);
size = thpsize;
assert(thpsize == pmdsize);
ret = madvise(mem + pagesize, thpsize - pagesize, MADV_DONTNEED);
mremap_size = thpsize / 2;
ret = madvise(mem + pagesize, thpsize - pagesize, MADV_DONTFORK);
ret = madvise(mem + pagesize, thpsize - pagesize, MADV_DOFORK);
if (!pagemap_is_populated(pagemap_fd, mem + thpsize - pagesize)) {
if (mprotect(mem, thpsize, PROT_READ)) {
if (!pagemap_is_populated(pagemap_fd, mem + thpsize - pagesize)) {
if (syscall(__NR_mbind, mem, thpsize, MPOL_LOCAL, NULL, 0x7fful,
if (mprotect(mem, thpsize, PROT_READ)) {
if (!pagemap_is_populated(pagemap_fd, mem + thpsize - pagesize)) {
if (mprotect(mem + thpsize - pagesize, pagesize,
static size_t thpsize;
thpsize = read_pmd_pagesize();
if (thpsize) {
thpsize / 1024);
if (thpsize)
if (thpsize)
if (thpsize)
const size_t mmap_size = 2 * thpsize;
mem = (char *)(((uintptr_t)mmap_mem + thpsize) & ~(thpsize - 1));
if (madvise(mem, thpsize, MADV_HUGEPAGE)) {