Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1427979
| From | Tejun Heo <tj@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v3] cgroup: Add pids controller event when fork fails because of pid limit |
| Date | 2016-06-21 19:20 +0200 |
| Message-ID | <rMxvb-ii-5@gated-at.bofh.it> (permalink) |
| References | <rMwSu-8eX-31@gated-at.bofh.it> <rMxbQ-8nf-11@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Hello,
Just a couple nits.
On Tue, Jun 21, 2016 at 09:56:38AM -0700, Kenny Yu wrote:
> Summary:
No need for "Summary:" tag.
> This patch adds more visibility into the pids controller when the controller
> rejects a fork request. Whenever fork fails because the limit on the number of
> pids in the cgroup is reached, the controller will log this and also notify the
> newly added cgroups events file. The `max` key in the events file represents
> the number of times fork failed because of the pids controller.
>
> This change also adds an atomic boolean to prevent logging too much (e.g. a fork
> bomb). The message is logged once per cgroup until the next time the pids limit
> changes.
The above paragraph isn't uptodate anymore.
> @@ -213,10 +220,23 @@ static int pids_can_fork(struct task_struct *task)
> {
> struct cgroup_subsys_state *css;
> struct pids_cgroup *pids;
> + int err;
> + int events_limit;
>
> css = task_css_check(current, pids_cgrp_id, true);
> pids = css_pids(css);
> - return pids_try_charge(pids, 1);
> + err = pids_try_charge(pids, 1);
> + if (err) {
> + events_limit = atomic64_inc_return(&pids->events_limit);
> + cgroup_file_notify(&pids->events_file);
> + /* Only log the first time events_limit is incremented. */
> + if (events_limit == 1) {
> + pr_info("cgroup: fork rejected by pids controller in ");
> + pr_cont_cgroup_path(task_cgroup(current, pids_cgrp_id));
> + pr_cont("\n");
> + }
> + }
> + return err;
> }
It'd be better to use atomic64_inc_and_test() instead.
if (err) {
if (atomic64_inc_and_test()) {
pr_xxx...;
}
cgroup_file_notify(&pids->events_file);
}
Thanks.
--
tejun
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH] cgroup: Add pids controller event when fork fails because of pid limit Kenny Yu <kennyyu@fb.com> - 2016-06-21 05:20 +0200
Re: [PATCH] cgroup: Add pids controller event when fork fails because of pid limit Johannes Weiner <hannes@cmpxchg.org> - 2016-06-21 06:50 +0200
Re: [PATCH v2] cgroup: Add pids controller event when fork fails because of pid limit Aleksa Sarai <cyphar@cyphar.com> - 2016-06-21 18:10 +0200
Re: [PATCH v2] cgroup: Add pids controller event when fork fails because of pid limit Tejun Heo <tj@kernel.org> - 2016-06-21 18:40 +0200
[PATCH v3] cgroup: Add pids controller event when fork fails because of pid limit Kenny Yu <kennyyu@fb.com> - 2016-06-21 19:00 +0200
Re: [PATCH v3] cgroup: Add pids controller event when fork fails because of pid limit Tejun Heo <tj@kernel.org> - 2016-06-21 19:20 +0200
Re: [PATCH v3] cgroup: Add pids controller event when fork fails because of pid limit Tejun Heo <tj@kernel.org> - 2016-06-21 20:30 +0200
[PATCH v4] cgroup: Add pids controller event when fork fails because of pid limit Kenny Yu <kennyyu@fb.com> - 2016-06-21 20:40 +0200
Re: [PATCH v3] cgroup: Add pids controller event when fork fails because of pid limit Kenny Yu <kennyyu@fb.com> - 2016-06-21 20:40 +0200
[PATCH v2] cgroup: Add pids controller event when fork fails because of pid limit Kenny Yu <kennyyu@fb.com> - 2016-06-21 18:30 +0200
csiph-web