博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
进程创建时cgroup处理
阅读量:4151 次
发布时间:2019-05-25

本文共 2849 字,大约阅读时间需要 9 分钟。

 
void cgroup_fork(struct task_struct *child){ RCU_INIT_POINTER(child->cgroups, &init_css_set); INIT_LIST_HEAD(&child->cg_list);}
 
cgroup_can_fork:
/** * cgroup_can_fork - called on a new task before the process is exposed * @child: the task in question. * * This calls the subsystem can_fork() callbacks. If the can_fork() callback * returns an error, the fork aborts with that error code. This allows for * a cgroup subsystem to conditionally allow or deny new forks. */int cgroup_can_fork(struct task_struct *child){ struct cgroup_subsys *ss; int i, j, ret;  do_each_subsys_mask(ss, i, have_canfork_callback) {  ret = ss->can_fork(child);  if (ret)   goto out_revert; } while_each_subsys_mask();  return 0; out_revert: for_each_subsys(ss, j) {  if (j >= i)   break;  if (ss->cancel_fork)   ss->cancel_fork(child); }  return ret;}
 
/** * cgroup_post_fork - called on a new task after adding it to the task list * @child: the task in question * * Adds the task to the list running through its css_set if necessary and * call the subsystem fork() callbacks.  Has to be after the task is * visible on the task list in case we race with the first call to * cgroup_task_iter_start() - to guarantee that the new task ends up on its * list. */void cgroup_post_fork(struct task_struct *child){ struct cgroup_subsys *ss; int i;  /*  * This may race against cgroup_enable_task_cg_lists().  As that  * function sets use_task_css_set_links before grabbing  * tasklist_lock and we just went through tasklist_lock to add  * @child, it's guaranteed that either we see the set  * use_task_css_set_links or cgroup_enable_task_cg_lists() sees  * @child during its iteration.  *  * If we won the race, @child is associated with %current's  * css_set.  Grabbing css_set_lock guarantees both that the  * association is stable, and, on completion of the parent's  * migration, @child is visible in the source of migration or  * already in the destination cgroup.  This guarantee is necessary  * when implementing operations which need to migrate all tasks of  * a cgroup to another.  *  * Note that if we lose to cgroup_enable_task_cg_lists(), @child  * will remain in init_css_set.  This is safe because all tasks are  * in the init_css_set before cg_links is enabled and there's no  * operation which transfers all tasks out of init_css_set.  */ if (use_task_css_set_links) {  struct css_set *cset;   spin_lock_irq(&css_set_lock);  cset = task_css_set(current);  if (list_empty(&child->cg_list)) {   get_css_set(cset);   css_set_move_task(child, NULL, cset, false);  }  spin_unlock_irq(&css_set_lock); }  /*  * Call ss->fork().  This must happen after @child is linked on  * css_set; otherwise, @child might change state between ->fork()  * and addition to css_set.  */ do_each_subsys_mask(ss, i, have_fork_callback) {  ss->fork(child); } while_each_subsys_mask();}

转载地址:http://kkhti.baihongyu.com/

你可能感兴趣的文章
Mysql复制表以及复制数据库
查看>>
Linux分区方案
查看>>
如何使用 systemd 中的定时器
查看>>
linux进程监控和自动重启的简单实现
查看>>
OpenFeign学习(三):OpenFeign配置生成代理对象
查看>>
OpenFeign学习(四):OpenFeign的方法同步请求执行
查看>>
OpenFeign学习(六):OpenFign进行表单提交参数或传输文件
查看>>
Ribbon 学习(二):Spring Cloud Ribbon 加载配置原理
查看>>
Ribbon 学习(三):RestTemplate 请求负载流程解析
查看>>
深入理解HashMap
查看>>
XML生成(一):DOM生成XML
查看>>
XML生成(三):JDOM生成
查看>>
Ubuntu Could not open lock file /var/lib/dpkg/lock - open (13:Permission denied)
查看>>
collect2: ld returned 1 exit status
查看>>
C#入门
查看>>
C#中ColorDialog需点两次确定才会退出的问题
查看>>
数据库
查看>>
nginx反代 499 502 bad gateway 和timeout
查看>>
linux虚拟机安装tar.gz版jdk步骤详解
查看>>
Kubernetes集群搭建之CNI-Flanneld部署篇
查看>>