函数源码 |
Source File:mm\hugetlb_cgroup.c |
Create Date:2022-07-27 17:50:51 |
首页 | Copyright©Brick |
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 | int hugetlb_cgroup_charge_cgroup( int idx, unsigned long nr_pages, struct hugetlb_cgroup **ptr) { int ret = 0; struct page_counter *counter; struct hugetlb_cgroup *h_cg = NULL; if (hugetlb_cgroup_disabled()) goto done; /* * We don't charge any cgroup if the compound page have less * than 3 pages. */ if (huge_page_order(&hstates[idx]) < HUGETLB_CGROUP_MIN_ORDER) goto done; again: rcu_read_lock(); h_cg = hugetlb_cgroup_from_task(current); if (!css_tryget(&h_cg->css)) { rcu_read_unlock(); goto again; } rcu_read_unlock(); if (!page_counter_try_charge(&h_cg->hugepage[idx], nr_pages, &counter)) ret = -ENOMEM; css_put(&h_cg->css); done: *ptr = h_cg; return ret; } |