Messages in this thread | | | Date | Thu, 10 Nov 2011 13:27:21 +0300 | Subject | Re: [PATCH v2 09/14] Keep nr_iowait per cgroup | From | Andrew Wagin <> |
| |
This code has a race condition. A task may be moved in another group between task_group_nr_iowait_inc and task_group_nr_iowait_dec.
# dd if=/dev/sda of=//dev/null bs=4095 & pid=$! # echo $pid > /cgroup/1/tasks # kill $pid # cat /cgroup/1/cpu.proc.stat | grep procs_blocked procs_blocked 18446744073709551615
> +static inline void task_group_nr_iowait_inc(struct task_struct *p, int cpu) > +{ > + > + atomic_inc(&per_cpu(kernel_cpustat, cpu).nr_iowait); > + > +#ifdef CONFIG_CGROUP_SCHED > + if (static_branch(&sched_cgroup_enabled)) { > + struct kernel_cpustat *kcpustat; > + struct task_group *tg; > + > + rcu_read_lock(); > + tg = task_group(p); > + while (tg && (tg != &root_task_group)) { > + kcpustat = per_cpu_ptr(tg->cpustat, cpu); > + atomic_inc(&kcpustat->nr_iowait); > + tg = tg->parent; > + } > + rcu_read_unlock(); > + } > +#endif > +} > + > +static inline void task_group_nr_iowait_dec(struct task_struct *p, int cpu) > +{ > + > + atomic_dec(&per_cpu(kernel_cpustat, cpu).nr_iowait); > + > +#ifdef CONFIG_CGROUP_SCHED > + if (static_branch(&sched_cgroup_enabled)) { > + struct kernel_cpustat *kcpustat; > + struct task_group *tg; > + > + rcu_read_lock(); > + tg = task_group(p); > + while (tg && (tg != &root_task_group)) { > + kcpustat = per_cpu_ptr(tg->cpustat, cpu); > + atomic_dec(&kcpustat->nr_iowait); > + tg = tg->parent; > + } > + rcu_read_unlock(); > + } > +#endif > +} > + -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |