Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp5225049ybl; Tue, 10 Dec 2019 02:37:44 -0800 (PST) X-Google-Smtp-Source: APXvYqxAOYZmDxOxfl4Bm1VnY0OGQDwwPqNyZ3M+qDNgF4yCEs477199tfN6Cezj1rsdDHH3sT7p X-Received: by 2002:a05:6830:1498:: with SMTP id s24mr25120984otq.208.1575974264845; Tue, 10 Dec 2019 02:37:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575974264; cv=none; d=google.com; s=arc-20160816; b=HOlUHzjMhGyUeYzAGBWM/g5W+CiF6m/ioOi27zPDpipmC9FHwGkiIgLPQaKEpKe+VF TdUWiOg1+WB7D4BaE0GgpzH5WDnMhAhn0DbwEV9ftn1EqUdmiZBL+cGTXiW4r3rM/heE c/zgOfPAoVdpGcUDocywqKJ/y6J94Dll5kRfDNvvBZdsX3zWa2J63ceKifUghPgedU+T UI5tHDtlXmwTzClKhgNBBXikc7JdVaunMPsQOnK4PDomzQscj5/4vS5r0uxNa4R0sbe5 wvyrPW1JUY7c7ZNQDF/ftH5MmBxbWI3oBkajI90HQ7lYkfcKITxi2MbWfHvHHs591f5F ApTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=Ro/pqgjNZp3eQ9LJrWdVlwIfveoi8NuaitvJ8+HhnDE=; b=0y1spwwA/j+EZl12o2vr+QxkHT2pJgF2DmA1v5nVSKmcyP7G9fcftfw9c0xillRFgW 2XkWGEzHk3vupez/RHdEmhC4xonl9tQkh37hRfiiVfTxpM9HwlWq1TnXvCrDupYUiGhl tkcxWkDBEmsmyQeHsbIfhzaf7qpA+mS8U6I28sC/DVm7oLlz5OwRYe6gaIkrlakKQuum yiml8cTuqXHSR8oA/WrQwwKUL6kYxMnn0K4UblkcxuwdwonOiT4W1RlucNzLtNt0FJWI +X2JdrLM4XAKtrY9TVe5LekqTNLki4e9vJ+dwH3pEQf2ck7V1IUcs2PbpUfzllA62oDr McIw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h22si1657476oie.15.2019.12.10.02.37.29; Tue, 10 Dec 2019 02:37:44 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727159AbfLJKhB (ORCPT + 99 others); Tue, 10 Dec 2019 05:37:01 -0500 Received: from foss.arm.com ([217.140.110.172]:38950 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727063AbfLJKhB (ORCPT ); Tue, 10 Dec 2019 05:37:01 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C1B0E1FB; Tue, 10 Dec 2019 02:37:00 -0800 (PST) Received: from e107158-lin.cambridge.arm.com (e107158-lin.cambridge.arm.com [10.1.195.21]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 564973F6CF; Tue, 10 Dec 2019 02:36:59 -0800 (PST) Date: Tue, 10 Dec 2019 10:36:57 +0000 From: Qais Yousef To: Vincent Guittot Cc: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, linux-kernel@vger.kernel.org, john.stultz@linaro.org, valentin.schneider@arm.com Subject: Re: [PATCH] sched/fair: fix find_idlest_group() to handle CPU affinity Message-ID: <20191210103656.637xilg2egtdwv5b@e107158-lin.cambridge.arm.com> References: <1575483700-22153-1-git-send-email-vincent.guittot@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1575483700-22153-1-git-send-email-vincent.guittot@linaro.org> User-Agent: NeoMutt/20171215 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/04/19 19:21, Vincent Guittot wrote: > Because of CPU affinity, the local group can be skipped which breaks the > assumption that statistics are always collected for local group. With > uninitialized local_sgs, the comparison is meaningless and the behavior > unpredictable. This can even end up to use local pointer which is to > NULL in this case. For the record; I think this is safe and I can't see how the local_sgs can be used uninitialized, but experience shows that if this happened once it's likely to happen again when things change. So I think it'd be safer to always initialize local_sgs to something sensible and avoid future trouble. I don't see any cost to initializing it. My 2p :-) The change is good for me as-is otherwise. Cheers -- Qais Yousef > > If the local group has been skipped because of CPU affinity, we return > the idlest group. > > Fixes: 57abff067a08 ("sched/fair: Rework find_idlest_group()") > Reported-by: John Stultz > Signed-off-by: Vincent Guittot > Tested-by: John Stultz > --- > kernel/sched/fair.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index 08a233e..146b6c8 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -8417,6 +8417,10 @@ find_idlest_group(struct sched_domain *sd, struct task_struct *p, > if (!idlest) > return NULL; > > + /* The local group has been skipped because of CPU affinity */ > + if (!local) > + return idlest; > + > /* > * If the local group is idler than the selected idlest group > * don't try and push the task. > -- > 2.7.4 >