Lines Matching refs:idx
30 #define hugetlb_cgroup_from_counter(counter, idx) \ argument
31 container_of(counter, struct hugetlb_cgroup, hugepage[idx])
36 __hugetlb_cgroup_counter_from_cgroup(struct hugetlb_cgroup *h_cg, int idx, in __hugetlb_cgroup_counter_from_cgroup() argument
40 return &h_cg->rsvd_hugepage[idx]; in __hugetlb_cgroup_counter_from_cgroup()
41 return &h_cg->hugepage[idx]; in __hugetlb_cgroup_counter_from_cgroup()
45 hugetlb_cgroup_counter_from_cgroup(struct hugetlb_cgroup *h_cg, int idx) in hugetlb_cgroup_counter_from_cgroup() argument
47 return __hugetlb_cgroup_counter_from_cgroup(h_cg, idx, false); in hugetlb_cgroup_counter_from_cgroup()
51 hugetlb_cgroup_counter_from_cgroup_rsvd(struct hugetlb_cgroup *h_cg, int idx) in hugetlb_cgroup_counter_from_cgroup_rsvd() argument
53 return __hugetlb_cgroup_counter_from_cgroup(h_cg, idx, true); in hugetlb_cgroup_counter_from_cgroup_rsvd()
81 int idx; in hugetlb_cgroup_have_usage() local
83 for (idx = 0; idx < hugetlb_max_hstate; idx++) { in hugetlb_cgroup_have_usage()
85 hugetlb_cgroup_counter_from_cgroup(h_cg, idx))) in hugetlb_cgroup_have_usage()
94 int idx; in hugetlb_cgroup_init() local
96 for (idx = 0; idx < HUGE_MAX_HSTATE; idx++) { in hugetlb_cgroup_init()
104 parent_h_cgroup, idx); in hugetlb_cgroup_init()
106 parent_h_cgroup, idx); in hugetlb_cgroup_init()
109 idx), in hugetlb_cgroup_init()
112 hugetlb_cgroup_counter_from_cgroup_rsvd(h_cgroup, idx), in hugetlb_cgroup_init()
116 1 << huge_page_order(&hstates[idx])); in hugetlb_cgroup_init()
119 hugetlb_cgroup_counter_from_cgroup(h_cgroup, idx), in hugetlb_cgroup_init()
123 hugetlb_cgroup_counter_from_cgroup_rsvd(h_cgroup, idx), in hugetlb_cgroup_init()
161 static void hugetlb_cgroup_move_parent(int idx, struct hugetlb_cgroup *h_cg, in hugetlb_cgroup_move_parent() argument
182 page_counter_charge(&parent->hugepage[idx], nr_pages); in hugetlb_cgroup_move_parent()
184 counter = &h_cg->hugepage[idx]; in hugetlb_cgroup_move_parent()
202 int idx; in hugetlb_cgroup_css_offline() local
205 idx = 0; in hugetlb_cgroup_css_offline()
209 hugetlb_cgroup_move_parent(idx, h_cg, page); in hugetlb_cgroup_css_offline()
212 idx++; in hugetlb_cgroup_css_offline()
218 static inline void hugetlb_event(struct hugetlb_cgroup *hugetlb, int idx, in hugetlb_event() argument
221 atomic_long_inc(&hugetlb->events_local[idx][event]); in hugetlb_event()
222 cgroup_file_notify(&hugetlb->events_local_file[idx]); in hugetlb_event()
225 atomic_long_inc(&hugetlb->events[idx][event]); in hugetlb_event()
226 cgroup_file_notify(&hugetlb->events_file[idx]); in hugetlb_event()
231 static int __hugetlb_cgroup_charge_cgroup(int idx, unsigned long nr_pages, in __hugetlb_cgroup_charge_cgroup() argument
245 if (huge_page_order(&hstates[idx]) < HUGETLB_CGROUP_MIN_ORDER) in __hugetlb_cgroup_charge_cgroup()
257 __hugetlb_cgroup_counter_from_cgroup(h_cg, idx, rsvd), in __hugetlb_cgroup_charge_cgroup()
260 hugetlb_event(h_cg, idx, HUGETLB_MAX); in __hugetlb_cgroup_charge_cgroup()
274 int hugetlb_cgroup_charge_cgroup(int idx, unsigned long nr_pages, in hugetlb_cgroup_charge_cgroup() argument
277 return __hugetlb_cgroup_charge_cgroup(idx, nr_pages, ptr, false); in hugetlb_cgroup_charge_cgroup()
280 int hugetlb_cgroup_charge_cgroup_rsvd(int idx, unsigned long nr_pages, in hugetlb_cgroup_charge_cgroup_rsvd() argument
283 return __hugetlb_cgroup_charge_cgroup(idx, nr_pages, ptr, true); in hugetlb_cgroup_charge_cgroup_rsvd()
287 static void __hugetlb_cgroup_commit_charge(int idx, unsigned long nr_pages, in __hugetlb_cgroup_commit_charge() argument
298 void hugetlb_cgroup_commit_charge(int idx, unsigned long nr_pages, in hugetlb_cgroup_commit_charge() argument
302 __hugetlb_cgroup_commit_charge(idx, nr_pages, h_cg, page, false); in hugetlb_cgroup_commit_charge()
305 void hugetlb_cgroup_commit_charge_rsvd(int idx, unsigned long nr_pages, in hugetlb_cgroup_commit_charge_rsvd() argument
309 __hugetlb_cgroup_commit_charge(idx, nr_pages, h_cg, page, true); in hugetlb_cgroup_commit_charge_rsvd()
315 static void __hugetlb_cgroup_uncharge_page(int idx, unsigned long nr_pages, in __hugetlb_cgroup_uncharge_page() argument
328 page_counter_uncharge(__hugetlb_cgroup_counter_from_cgroup(h_cg, idx, in __hugetlb_cgroup_uncharge_page()
338 void hugetlb_cgroup_uncharge_page(int idx, unsigned long nr_pages, in hugetlb_cgroup_uncharge_page() argument
341 __hugetlb_cgroup_uncharge_page(idx, nr_pages, page, false); in hugetlb_cgroup_uncharge_page()
344 void hugetlb_cgroup_uncharge_page_rsvd(int idx, unsigned long nr_pages, in hugetlb_cgroup_uncharge_page_rsvd() argument
347 __hugetlb_cgroup_uncharge_page(idx, nr_pages, page, true); in hugetlb_cgroup_uncharge_page_rsvd()
350 static void __hugetlb_cgroup_uncharge_cgroup(int idx, unsigned long nr_pages, in __hugetlb_cgroup_uncharge_cgroup() argument
357 if (huge_page_order(&hstates[idx]) < HUGETLB_CGROUP_MIN_ORDER) in __hugetlb_cgroup_uncharge_cgroup()
360 page_counter_uncharge(__hugetlb_cgroup_counter_from_cgroup(h_cg, idx, in __hugetlb_cgroup_uncharge_cgroup()
368 void hugetlb_cgroup_uncharge_cgroup(int idx, unsigned long nr_pages, in hugetlb_cgroup_uncharge_cgroup() argument
371 __hugetlb_cgroup_uncharge_cgroup(idx, nr_pages, h_cg, false); in hugetlb_cgroup_uncharge_cgroup()
374 void hugetlb_cgroup_uncharge_cgroup_rsvd(int idx, unsigned long nr_pages, in hugetlb_cgroup_uncharge_cgroup_rsvd() argument
377 __hugetlb_cgroup_uncharge_cgroup(idx, nr_pages, h_cg, true); in hugetlb_cgroup_uncharge_cgroup_rsvd()
458 int idx; in hugetlb_cgroup_read_u64_max() local
465 idx = MEMFILE_IDX(cft->private); in hugetlb_cgroup_read_u64_max()
466 counter = &h_cg->hugepage[idx]; in hugetlb_cgroup_read_u64_max()
469 1 << huge_page_order(&hstates[idx])); in hugetlb_cgroup_read_u64_max()
473 counter = &h_cg->rsvd_hugepage[idx]; in hugetlb_cgroup_read_u64_max()
480 counter = &h_cg->rsvd_hugepage[idx]; in hugetlb_cgroup_read_u64_max()
502 int ret, idx; in hugetlb_cgroup_write() local
515 idx = MEMFILE_IDX(of_cft(of)->private); in hugetlb_cgroup_write()
516 nr_pages = round_down(nr_pages, 1 << huge_page_order(&hstates[idx])); in hugetlb_cgroup_write()
525 __hugetlb_cgroup_counter_from_cgroup(h_cg, idx, rsvd), in hugetlb_cgroup_write()
591 int idx; in __hugetlb_events_show() local
596 idx = MEMFILE_IDX(cft->private); in __hugetlb_events_show()
599 max = atomic_long_read(&h_cg->events_local[idx][HUGETLB_MAX]); in __hugetlb_events_show()
601 max = atomic_long_read(&h_cg->events[idx][HUGETLB_MAX]); in __hugetlb_events_show()
618 static void __init __hugetlb_cgroup_file_dfl_init(int idx) in __hugetlb_cgroup_file_dfl_init() argument
622 struct hstate *h = &hstates[idx]; in __hugetlb_cgroup_file_dfl_init()
630 cft->private = MEMFILE_PRIVATE(idx, RES_LIMIT); in __hugetlb_cgroup_file_dfl_init()
638 cft->private = MEMFILE_PRIVATE(idx, RES_RSVD_LIMIT); in __hugetlb_cgroup_file_dfl_init()
646 cft->private = MEMFILE_PRIVATE(idx, RES_USAGE); in __hugetlb_cgroup_file_dfl_init()
653 cft->private = MEMFILE_PRIVATE(idx, RES_RSVD_USAGE); in __hugetlb_cgroup_file_dfl_init()
660 cft->private = MEMFILE_PRIVATE(idx, 0); in __hugetlb_cgroup_file_dfl_init()
662 cft->file_offset = offsetof(struct hugetlb_cgroup, events_file[idx]); in __hugetlb_cgroup_file_dfl_init()
668 cft->private = MEMFILE_PRIVATE(idx, 0); in __hugetlb_cgroup_file_dfl_init()
671 events_local_file[idx]); in __hugetlb_cgroup_file_dfl_init()
682 static void __init __hugetlb_cgroup_file_legacy_init(int idx) in __hugetlb_cgroup_file_legacy_init() argument
686 struct hstate *h = &hstates[idx]; in __hugetlb_cgroup_file_legacy_init()
694 cft->private = MEMFILE_PRIVATE(idx, RES_LIMIT); in __hugetlb_cgroup_file_legacy_init()
701 cft->private = MEMFILE_PRIVATE(idx, RES_RSVD_LIMIT); in __hugetlb_cgroup_file_legacy_init()
708 cft->private = MEMFILE_PRIVATE(idx, RES_USAGE); in __hugetlb_cgroup_file_legacy_init()
714 cft->private = MEMFILE_PRIVATE(idx, RES_RSVD_USAGE); in __hugetlb_cgroup_file_legacy_init()
720 cft->private = MEMFILE_PRIVATE(idx, RES_MAX_USAGE); in __hugetlb_cgroup_file_legacy_init()
727 cft->private = MEMFILE_PRIVATE(idx, RES_RSVD_MAX_USAGE); in __hugetlb_cgroup_file_legacy_init()
734 cft->private = MEMFILE_PRIVATE(idx, RES_FAILCNT); in __hugetlb_cgroup_file_legacy_init()
741 cft->private = MEMFILE_PRIVATE(idx, RES_RSVD_FAILCNT); in __hugetlb_cgroup_file_legacy_init()
753 static void __init __hugetlb_cgroup_file_init(int idx) in __hugetlb_cgroup_file_init() argument
755 __hugetlb_cgroup_file_dfl_init(idx); in __hugetlb_cgroup_file_init()
756 __hugetlb_cgroup_file_legacy_init(idx); in __hugetlb_cgroup_file_init()