Re: Re: [PATCH] cgroup(fix critical bug): new handling for tasksfile

From: Lai Jiangshan
Date: Mon Sep 08 2008 - 04:21:26 EST


It's great, Thanks!

Lai Jiangshan.


Reviewed-by: Lai Jiangshan <laijs@xxxxxxxxxxxxxx>

Paul Menage wrote:

> - allocate an array of single pages rather than a single kmalloc() region

I will send a patch for it in few days.

> +
> +static void *cgroup_tasks_start(struct seq_file *s, loff_t *pos)
> {
> - int cnt = 0;
> - int i;
> + /*
> + * Initially we receive a position value that corresponds to
> + * one more than the last pid shown (or 0 on the first call or
> + * after a seek to the start). Use a binary-search to find the
> + * next pid to display, if any
> + */
> + struct cgroup *cgrp = s->private;
> + int index = 0, pid = *pos;
> + int *iter;

use pid_t instead of int (include other functions)

> +
> + down_read(&cgrp->pids_mutex);
> + if (pid) {
> + int end = cgrp->pids_length;
> + int i;

int i; unused.

> + while (index < end) {
> + int mid = (index + end) / 2;
> + if (cgrp->tasks_pids[mid] == pid) {
> + index = mid;
> + break;
> + } else if (cgrp->tasks_pids[mid] <= pid)

(cgrp->tasks_pids[mid] <= pid) ===> (cgrp->tasks_pids[mid] < pid)

> + index = mid + 1;
> + else
> + end = mid;
> + }
> + }

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/