Lines Matching refs:css

244 static void kill_css(struct cgroup_subsys_state *css);
245 static int cgroup_addrm_files(struct cgroup_subsys_state *css,
501 struct cgroup_subsys_state *css; in cgroup_tryget_css() local
504 css = cgroup_css(cgrp, ss); in cgroup_tryget_css()
505 if (css && !css_tryget_online(css)) in cgroup_tryget_css()
506 css = NULL; in cgroup_tryget_css()
509 return css; in cgroup_tryget_css()
559 struct cgroup_subsys_state *css; in cgroup_e_css() local
565 css = cgroup_css(cgrp, ss); in cgroup_e_css()
567 if (css) in cgroup_e_css()
568 return css; in cgroup_e_css()
589 struct cgroup_subsys_state *css; in cgroup_get_e_css() local
597 css = cgroup_css(cgrp, ss); in cgroup_get_e_css()
599 if (css && css_tryget_online(css)) in cgroup_get_e_css()
604 css = init_css_set.subsys[ss->id]; in cgroup_get_e_css()
605 css_get(css); in cgroup_get_e_css()
608 return css; in cgroup_get_e_css()
679 #define for_each_css(css, ssid, cgrp) \ argument
681 if (!((css) = rcu_dereference_check( \
694 #define for_each_e_css(css, ssid, cgrp) \ argument
696 if (!((css) = cgroup_e_css_by_mask(cgrp, \
941 static unsigned long css_set_hash(struct cgroup_subsys_state *css[]) in css_set_hash() argument
948 key += (unsigned long)css[i]; in css_set_hash()
1268 struct cgroup_subsys_state *css = cset->subsys[ssid]; in find_css_set() local
1271 &css->cgroup->e_csets[ssid]); in find_css_set()
1272 css_get(css); in find_css_set()
1652 struct cgroup_subsys_state *css = cgroup_css(cgrp, cft->ss); in cgroup_rm_file() local
1653 struct cgroup_file *cfile = (void *)css + cft->file_offset; in cgroup_rm_file()
1669 static void css_clear_dir(struct cgroup_subsys_state *css) in css_clear_dir() argument
1671 struct cgroup *cgrp = css->cgroup; in css_clear_dir()
1674 if (!(css->flags & CSS_VISIBLE)) in css_clear_dir()
1677 css->flags &= ~CSS_VISIBLE; in css_clear_dir()
1679 if (!css->ss) { in css_clear_dir()
1685 cgroup_addrm_files(css, cgrp, cfts, false); in css_clear_dir()
1687 list_for_each_entry(cfts, &css->ss->cfts, node) in css_clear_dir()
1688 cgroup_addrm_files(css, cgrp, cfts, false); in css_clear_dir()
1698 static int css_populate_dir(struct cgroup_subsys_state *css) in css_populate_dir() argument
1700 struct cgroup *cgrp = css->cgroup; in css_populate_dir()
1704 if ((css->flags & CSS_VISIBLE) || !cgrp->kn) in css_populate_dir()
1707 if (!css->ss) { in css_populate_dir()
1717 list_for_each_entry(cfts, &css->ss->cfts, node) { in css_populate_dir()
1718 ret = cgroup_addrm_files(css, cgrp, cfts, true); in css_populate_dir()
1726 css->flags |= CSS_VISIBLE; in css_populate_dir()
1730 list_for_each_entry(cfts, &css->ss->cfts, node) { in css_populate_dir()
1733 cgroup_addrm_files(css, cgrp, cfts, false); in css_populate_dir()
1785 struct cgroup_subsys_state *css = cgroup_css(scgrp, ss); in rebind_subsystems() local
1788 WARN_ON(!css || cgroup_css(dcgrp, ss)); in rebind_subsystems()
1799 rcu_assign_pointer(dcgrp->subsys[ssid], css); in rebind_subsystems()
1801 css->cgroup = dcgrp; in rebind_subsystems()
1810 list_del_rcu(&css->rstat_css_node); in rebind_subsystems()
1811 list_add_rcu(&css->rstat_css_node, in rebind_subsystems()
1830 ss->bind(css); in rebind_subsystems()
3002 struct cgroup_subsys_state *css = cgroup_css(dsct, ss); in cgroup_lock_and_drain_offline() local
3005 if (!css || !percpu_ref_is_dying(&css->refcnt)) in cgroup_lock_and_drain_offline()
3083 static bool css_visible(struct cgroup_subsys_state *css) in css_visible() argument
3085 struct cgroup_subsys *ss = css->ss; in css_visible()
3086 struct cgroup *cgrp = css->cgroup; in css_visible()
3117 struct cgroup_subsys_state *css = cgroup_css(dsct, ss); in cgroup_apply_control_enable() local
3122 if (!css) { in cgroup_apply_control_enable()
3123 css = css_create(dsct, ss); in cgroup_apply_control_enable()
3124 if (IS_ERR(css)) in cgroup_apply_control_enable()
3125 return PTR_ERR(css); in cgroup_apply_control_enable()
3128 WARN_ON_ONCE(percpu_ref_is_dying(&css->refcnt)); in cgroup_apply_control_enable()
3130 if (css_visible(css)) { in cgroup_apply_control_enable()
3131 ret = css_populate_dir(css); in cgroup_apply_control_enable()
3163 struct cgroup_subsys_state *css = cgroup_css(dsct, ss); in cgroup_apply_control_disable() local
3165 if (!css) in cgroup_apply_control_disable()
3168 WARN_ON_ONCE(percpu_ref_is_dying(&css->refcnt)); in cgroup_apply_control_disable()
3170 if (css->parent && in cgroup_apply_control_disable()
3172 kill_css(css); in cgroup_apply_control_disable()
3173 } else if (!css_visible(css)) { in cgroup_apply_control_disable()
3174 css_clear_dir(css); in cgroup_apply_control_disable()
3176 ss->css_reset(css); in cgroup_apply_control_disable()
3580 struct cgroup_subsys_state *css; in cgroup_extra_stat_show() local
3586 css = cgroup_tryget_css(cgrp, ss); in cgroup_extra_stat_show()
3587 if (!css) in cgroup_extra_stat_show()
3590 ret = ss->css_extra_stat_show(seq, css); in cgroup_extra_stat_show()
3591 css_put(css); in cgroup_extra_stat_show()
3774 struct cgroup_subsys_state *css; in cgroup_kill() local
3779 cgroup_for_each_live_descendant_pre(dsct, css, cgrp) in cgroup_kill()
3858 struct cgroup_subsys_state *css; in cgroup_file_write() local
3885 css = cgroup_css(cgrp, cft->ss); in cgroup_file_write()
3892 ret = cft->write_u64(css, cft, v); in cgroup_file_write()
3897 ret = cft->write_s64(css, cft, v); in cgroup_file_write()
3934 struct cgroup_subsys_state *css = seq_css(m); in cgroup_seqfile_show() local
3940 seq_printf(m, "%llu\n", cft->read_u64(css, cft)); in cgroup_seqfile_show()
3942 seq_printf(m, "%lld\n", cft->read_s64(css, cft)); in cgroup_seqfile_show()
3989 static int cgroup_add_file(struct cgroup_subsys_state *css, struct cgroup *cgrp, in cgroup_add_file() argument
4015 struct cgroup_file *cfile = (void *)css + cft->file_offset; in cgroup_add_file()
4037 static int cgroup_addrm_files(struct cgroup_subsys_state *css, in cgroup_addrm_files() argument
4062 ret = cgroup_add_file(css, cgrp, cft); in cgroup_addrm_files()
4081 struct cgroup_subsys_state *css; in cgroup_apply_cftypes() local
4087 css_for_each_descendant_pre(css, cgroup_css(root, ss)) { in cgroup_apply_cftypes()
4088 struct cgroup *cgrp = css->cgroup; in cgroup_apply_cftypes()
4090 if (!(css->flags & CSS_VISIBLE)) in cgroup_apply_cftypes()
4093 ret = cgroup_addrm_files(css, cgrp, cfts, is_add); in cgroup_apply_cftypes()
4501 bool css_has_online_children(struct cgroup_subsys_state *css) in css_has_online_children() argument
4507 css_for_each_child(child, css) { in css_has_online_children()
4699 void css_task_iter_start(struct cgroup_subsys_state *css, unsigned int flags, in css_task_iter_start() argument
4706 it->ss = css->ss; in css_task_iter_start()
4710 it->cset_pos = &css->cgroup->e_csets[css->ss->id]; in css_task_iter_start()
4712 it->cset_pos = &css->cgroup->cset_links; in css_task_iter_start()
5101 struct cgroup_subsys_state *css = container_of(to_rcu_work(work), in css_free_rwork_fn() local
5103 struct cgroup_subsys *ss = css->ss; in css_free_rwork_fn()
5104 struct cgroup *cgrp = css->cgroup; in css_free_rwork_fn()
5106 percpu_ref_exit(&css->refcnt); in css_free_rwork_fn()
5110 struct cgroup_subsys_state *parent = css->parent; in css_free_rwork_fn()
5111 int id = css->id; in css_free_rwork_fn()
5113 ss->css_free(css); in css_free_rwork_fn()
5150 struct cgroup_subsys_state *css = in css_release_work_fn() local
5152 struct cgroup_subsys *ss = css->ss; in css_release_work_fn()
5153 struct cgroup *cgrp = css->cgroup; in css_release_work_fn()
5157 css->flags |= CSS_RELEASED; in css_release_work_fn()
5158 list_del_rcu(&css->sibling); in css_release_work_fn()
5162 if (!list_empty(&css->rstat_css_node)) { in css_release_work_fn()
5164 list_del_rcu(&css->rstat_css_node); in css_release_work_fn()
5167 cgroup_idr_replace(&ss->css_idr, NULL, css->id); in css_release_work_fn()
5169 ss->css_released(css); in css_release_work_fn()
5198 INIT_RCU_WORK(&css->destroy_rwork, css_free_rwork_fn); in css_release_work_fn()
5199 queue_rcu_work(cgroup_destroy_wq, &css->destroy_rwork); in css_release_work_fn()
5204 struct cgroup_subsys_state *css = in css_release() local
5207 INIT_WORK(&css->destroy_work, css_release_work_fn); in css_release()
5208 queue_work(cgroup_destroy_wq, &css->destroy_work); in css_release()
5211 static void init_and_link_css(struct cgroup_subsys_state *css, in init_and_link_css() argument
5218 memset(css, 0, sizeof(*css)); in init_and_link_css()
5219 css->cgroup = cgrp; in init_and_link_css()
5220 css->ss = ss; in init_and_link_css()
5221 css->id = -1; in init_and_link_css()
5222 INIT_LIST_HEAD(&css->sibling); in init_and_link_css()
5223 INIT_LIST_HEAD(&css->children); in init_and_link_css()
5224 INIT_LIST_HEAD(&css->rstat_css_node); in init_and_link_css()
5225 css->serial_nr = css_serial_nr_next++; in init_and_link_css()
5226 atomic_set(&css->online_cnt, 0); in init_and_link_css()
5229 css->parent = cgroup_css(cgroup_parent(cgrp), ss); in init_and_link_css()
5230 css_get(css->parent); in init_and_link_css()
5234 list_add_rcu(&css->rstat_css_node, &cgrp->rstat_css_list); in init_and_link_css()
5240 static int online_css(struct cgroup_subsys_state *css) in online_css() argument
5242 struct cgroup_subsys *ss = css->ss; in online_css()
5248 ret = ss->css_online(css); in online_css()
5250 css->flags |= CSS_ONLINE; in online_css()
5251 rcu_assign_pointer(css->cgroup->subsys[ss->id], css); in online_css()
5253 atomic_inc(&css->online_cnt); in online_css()
5254 if (css->parent) in online_css()
5255 atomic_inc(&css->parent->online_cnt); in online_css()
5261 static void offline_css(struct cgroup_subsys_state *css) in offline_css() argument
5263 struct cgroup_subsys *ss = css->ss; in offline_css()
5267 if (!(css->flags & CSS_ONLINE)) in offline_css()
5271 ss->css_offline(css); in offline_css()
5273 css->flags &= ~CSS_ONLINE; in offline_css()
5274 RCU_INIT_POINTER(css->cgroup->subsys[ss->id], NULL); in offline_css()
5276 wake_up_all(&css->cgroup->offline_waitq); in offline_css()
5293 struct cgroup_subsys_state *css; in css_create() local
5298 css = ss->css_alloc(parent_css); in css_create()
5299 if (!css) in css_create()
5300 css = ERR_PTR(-ENOMEM); in css_create()
5301 if (IS_ERR(css)) in css_create()
5302 return css; in css_create()
5304 init_and_link_css(css, ss, cgrp); in css_create()
5306 err = percpu_ref_init(&css->refcnt, css_release, 0, GFP_KERNEL); in css_create()
5313 css->id = err; in css_create()
5316 list_add_tail_rcu(&css->sibling, &parent_css->children); in css_create()
5317 cgroup_idr_replace(&ss->css_idr, css, css->id); in css_create()
5319 err = online_css(css); in css_create()
5323 return css; in css_create()
5326 list_del_rcu(&css->sibling); in css_create()
5328 list_del_rcu(&css->rstat_css_node); in css_create()
5329 INIT_RCU_WORK(&css->destroy_rwork, css_free_rwork_fn); in css_create()
5330 queue_rcu_work(cgroup_destroy_wq, &css->destroy_rwork); in css_create()
5542 struct cgroup_subsys_state *css = in css_killed_work_fn() local
5548 offline_css(css); in css_killed_work_fn()
5549 css_put(css); in css_killed_work_fn()
5551 css = css->parent; in css_killed_work_fn()
5552 } while (css && atomic_dec_and_test(&css->online_cnt)); in css_killed_work_fn()
5560 struct cgroup_subsys_state *css = in css_killed_ref_fn() local
5563 if (atomic_dec_and_test(&css->online_cnt)) { in css_killed_ref_fn()
5564 INIT_WORK(&css->destroy_work, css_killed_work_fn); in css_killed_ref_fn()
5565 queue_work(cgroup_destroy_wq, &css->destroy_work); in css_killed_ref_fn()
5578 static void kill_css(struct cgroup_subsys_state *css) in kill_css() argument
5582 if (css->flags & CSS_DYING) in kill_css()
5585 css->flags |= CSS_DYING; in kill_css()
5591 css_clear_dir(css); in kill_css()
5597 css_get(css); in kill_css()
5609 percpu_ref_kill_and_confirm(&css->refcnt, css_killed_ref_fn); in kill_css()
5640 struct cgroup_subsys_state *css; in cgroup_destroy_locked() local
5675 for_each_css(css, ssid, cgrp) in cgroup_destroy_locked()
5676 kill_css(css); in cgroup_destroy_locked()
5734 struct cgroup_subsys_state *css; in cgroup_init_subsys() local
5745 css = ss->css_alloc(cgroup_css(&cgrp_dfl_root.cgrp, ss)); in cgroup_init_subsys()
5747 BUG_ON(IS_ERR(css)); in cgroup_init_subsys()
5748 init_and_link_css(css, ss, &cgrp_dfl_root.cgrp); in cgroup_init_subsys()
5754 css->flags |= CSS_NO_REF; in cgroup_init_subsys()
5758 css->id = 1; in cgroup_init_subsys()
5760 css->id = cgroup_idr_alloc(&ss->css_idr, css, 1, 2, GFP_KERNEL); in cgroup_init_subsys()
5761 BUG_ON(css->id < 0); in cgroup_init_subsys()
5768 init_css_set.subsys[ss->id] = css; in cgroup_init_subsys()
5780 BUG_ON(online_css(css)); in cgroup_init_subsys()
5862 struct cgroup_subsys_state *css = in cgroup_init() local
5865 css->id = cgroup_idr_alloc(&ss->css_idr, css, 1, 2, in cgroup_init()
5867 BUG_ON(css->id < 0); in cgroup_init()
6079 struct cgroup_subsys_state *css; in cgroup_get_from_file() local
6082 css = css_tryget_online_from_dir(f->f_path.dentry, NULL); in cgroup_get_from_file()
6083 if (IS_ERR(css)) in cgroup_get_from_file()
6084 return ERR_CAST(css); in cgroup_get_from_file()
6086 cgrp = css->cgroup; in cgroup_get_from_file()
6489 struct cgroup_subsys_state *css = NULL; in css_tryget_online_from_dir() local
6506 css = cgroup_css(cgrp, ss); in css_tryget_online_from_dir()
6508 if (!css || !css_tryget_online(css)) in css_tryget_online_from_dir()
6509 css = ERR_PTR(-ENOENT); in css_tryget_online_from_dir()
6512 return css; in css_tryget_online_from_dir()