lkml.org 
[lkml]   [2011]   [Nov]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    SubjectRe: [PATCH v2 09/14] Keep nr_iowait per cgroup
    From
    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/

    \
     
     \ /
      Last update: 2011-11-10 11:29    [W:3.705 / U:0.308 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site