Re: [PATCH v2 1/3] sched/core: Clear the root_domain cpumasks in init_rootdomain()
From: Steven Rostedt
Date: Thu Dec 03 2015 - 10:27:04 EST
On Thu, 3 Dec 2015 12:44:59 +0800
Xunlei Pang <xlpang@xxxxxxxxxx> wrote:
> root_domain::rto_mask allocated through alloc_cpumask_var()
> contains garbage data with CONFIG_CPUMASK_OFFSTACK set, this
> may cause problems. For instance, When doing pull_rt_task(),
> it may do useless iterations if rto_mask retains some extra
> garbage bits. Worse still, this can violate the isolated domain
> rule for clustered scheduling using cpuset, because the tasks
> (with all the cpus allowed) which belongs to one root domain
> can be pulled away into another root domain.
I really hate the fact that alloc_cpumask_var() behaves differently
depending on weather or not CONFIG_CPUMASK_OFFSTACK is defined or not.
I wonder if the better solution is to pass the __GFP_ZERO into
allocating the cpu mask when CPUMASK_OFFSTACK is defined. This will
prevent other areas from having this same bug. Also, I doubt any
allocations of cpumasks is in performance critical sections.
Or at least see if the address passed in is already null, which tells
us that something already cleared it. Like in this case the
memset(rd, 0, sizeof(*rd)).
Have something like:
bool alloc_cpumask_var_node(cpumask_var_t *mask, gfp_t flags, int node)
{
if ((long)*mask == 0)
flags |= __GFP_ZERO;
Maybe I'll post a patch to do this.
>
> The patch cleans the garbage by passing alloc_cpumask_var()
> with an extra __GFP_ZERO for root_domain::rto_mask allocation,
> thereby addressing the issues.
>
> Do the same thing for root_domain's other cpumask memembers:
> dlo_mask, span, and online.
Acked-by: Steven Rostedt <rostedt@xxxxxxxxxxx>
-- Steve
>
> Signed-off-by: Xunlei Pang <xlpang@xxxxxxxxxx>
> ---
--
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/