Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755469AbbLDI2h (ORCPT ); Fri, 4 Dec 2015 03:28:37 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60912 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752542AbbLDI2f (ORCPT ); Fri, 4 Dec 2015 03:28:35 -0500 Subject: Re: [PATCH] sched/core: Clear the root_domain cpumasks in init_rootdomain() To: Ingo Molnar References: <1449057179-29321-1-git-send-email-xlpang@redhat.com> <20151202123414.GB9928@worktop.ger.corp.intel.com> <565EEE3E.30301@redhat.com> <20151202162542.GT3816@twins.programming.kicks-ass.net> <565FAC78.3030205@redhat.com> <20151203082800.GA2321@gmail.com> <56602D19.5080308@redhat.com> <20151204080901.GA26934@gmail.com> Cc: Peter Zijlstra , linux-kernel@vger.kernel.org, Ingo Molnar , Steven Rostedt , Rusty Russell From: Xunlei Pang Message-ID: <56614EAC.1010804@redhat.com> Date: Fri, 4 Dec 2015 16:28:28 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <20151204080901.GA26934@gmail.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2226 Lines: 67 Hi Ingo, On 12/04/2015 at 04:09 PM, Ingo Molnar wrote: > * Xunlei Pang wrote: > >>> Hm, is the alloc_cpumask_var() done in alloc_sched_domains() safe? >> Until now, I haven't found any other similar issues, but I will check further. >> >>> At least the usage pattern in init_sched_domains() looks unsafe: >>> >>> doms_cur = alloc_sched_domains(ndoms_cur); >>> if (!doms_cur) >>> doms_cur = &fallback_doms; >>> cpumask_andnot(doms_cur[0], cpu_map, cpu_isolated_map); > So is this pattern in init_sched_domains() correct, for OFFSTACK=y? > > It looks wrong to me, as alloc_sched_domains() allocates an uninitialized cpumask > via alloc_cpumask_var() and returns it: > > cpumask_var_t *alloc_sched_domains(unsigned int ndoms) > { > int i; > cpumask_var_t *doms; > > doms = kmalloc(sizeof(*doms) * ndoms, GFP_KERNEL); > if (!doms) > return NULL; > for (i = 0; i < ndoms; i++) { > if (!alloc_cpumask_var(&doms[i], GFP_KERNEL)) { > free_sched_domains(doms, i); > return NULL; > } > } > return doms; > } > > and then this code: > >>> cpumask_andnot(doms_cur[0], cpu_map, cpu_isolated_map); > uses it without first clearing it. > > So is this another such bug, or am I missing something? Yeah, I noticed that as well. But fortunately cpumask_andnot(), cpumask_and() and the like will clear doms_cur[] indirectly, also cpu_isolated_map, cpu_active_mask, etc doesn't contain any garbage bits. I also checked the use of it by cpuset, no extra such bug found by me so far. Regards, Xunlei > > Thanks, > > Ingo > -- > 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/ -- 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/