Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp119303pxx; Tue, 27 Oct 2020 23:31:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwd8KlzNt7afAo+eU0DejOVrm4hmc/HEyPcFrAkbm8HYFBMKmU6kXVwa/9hLZfo92PSPGEO X-Received: by 2002:a17:906:1955:: with SMTP id b21mr6364932eje.42.1603866719620; Tue, 27 Oct 2020 23:31:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603866719; cv=none; d=google.com; s=arc-20160816; b=CPIVFOJfhW/uC041tqbTnLtw0hCVvE/LlXuXOcyWiFP14svdGJSuh+AeUJ13DsIb4X rua+bYZwXtiPaQHXX+wSEmXg5CW2SPdur69KvmvXv4fPdWAZMVdyvXKjxtkN4IU3rPko PiXeAt4v64Q9PXwyHDBt4AP2FN6zV+9IcYukj+eBEt3UpWLCdzYhNgI9yDJCudpFTfj0 r8OhsSgFmlIEvlXsLcP2zRJETMlR7fYESIGyMUVYy+WlppDOZGxbgB5pZyj3culuSJ0F 8vykKnBFYu1ZWp7RYT5aF92+Rsoe9bmkmvIqdXgO6qRnr/bW2/8DHUkSHFImcY/L0YlL Q3IA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=6aOC6xFQmwg2mk6qkSKitJ9OpnbA1LofYYkCAXG1v+o=; b=nEP/egQcKz9S5WE73cZg6KvdGJIhKa9WRRo+LLt46ecN7p6fjwGoTsrKJenJ/qTC6d TiMyLlY8abIbeSCsh122ohRbS6eNkKRb2Ni3m62GBfSjdFvhXfVJW9+/fiZEKz5Hf2cj UOpr9zAMOs1PR/P2kIm7CsAixBSIgYWpNbcNbUG6cdQSW0rgZHrRFHUFiEFNpVSkrTHX m4VkGYGKmMiflhsWLD5Tr3NwfY3UnD/fCNAor4d/L1SlYG01lxxg6EeYyKbG7tZjr5eF Wp63cw1m8hooWsgL6pzxSnQz7iHfJ63DLFxKOhzYVUOZRFJpXPfvC7zFlULzBBfokBSv fqCQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bs11si2022155edb.24.2020.10.27.23.31.37; Tue, 27 Oct 2020 23:31:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2896589AbgJ0J6b (ORCPT + 99 others); Tue, 27 Oct 2020 05:58:31 -0400 Received: from foss.arm.com ([217.140.110.172]:37030 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2410433AbgJ0J6A (ORCPT ); Tue, 27 Oct 2020 05:58:00 -0400 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 A5AFD30E; Tue, 27 Oct 2020 02:57:59 -0700 (PDT) Received: from [192.168.178.2] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C35C13F66E; Tue, 27 Oct 2020 02:57:57 -0700 (PDT) Subject: Re: [PATCH v2] sched: sched_domain fix highest_flag_domain function To: Xuewen Yan , xuewen.yan@unisoc.com, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org Cc: rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, linux-kernel@vger.kernel.org References: <1603769572-8193-1-git-send-email-xuewen.yan94@gmail.com> From: Dietmar Eggemann Message-ID: <69257e98-2d93-673a-5dac-e11b6d5610be@arm.com> Date: Tue, 27 Oct 2020 10:57:56 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <1603769572-8193-1-git-send-email-xuewen.yan94@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 27/10/2020 04:32, Xuewen Yan wrote: > the highest_flag_domain is to search the highest sched_domain > containing flag, but if the lower sched_domain didn't contain > the flag, but the higher sched_domain contains the flag, the > function will return NULL instead of the higher sched_domain. > > For example: > In MC domain : no SD_ASYM_CPUCAPACITY flag; > In DIE domain : containing SD_ASYM_CPUCAPACITY flag; > the "highest_flag_domain(cpu, SD_ASYM_CPUCAPACITY)" will return NULL. > > Signed-off-by: Xuewen Yan > --- > kernel/sched/sched.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h > index 28709f6..2c7c566 100644 > --- a/kernel/sched/sched.h > +++ b/kernel/sched/sched.h > @@ -1427,7 +1427,7 @@ static inline struct sched_domain *highest_flag_domain(int cpu, int flag) > > for_each_domain(cpu, sd) { > if (!(sd->flags & flag)) > - break; > + continue; > hsd = sd; > } We distinguish between SDF_SHARED_PARENT and SDF_SHARED_CHILD SD flags. 1 SD_FLAG(*SD_ASYM_CPUCAPACITY*, SDF_SHARED_PARENT | SDF_NEEDS_GROUPS) 2 SD_FLAG(SD_SERIALIZE, SDF_SHARED_PARENT | SDF_NEEDS_GROUPS) 3 SD_FLAG(SD_OVERLAP, SDF_SHARED_PARENT | SDF_NEEDS_GROUPS) 4 SD_FLAG(SD_NUMA, SDF_SHARED_PARENT | SDF_NEEDS_GROUPS) 1 SD_FLAG(SD_BALANCE_NEWIDLE, SDF_SHARED_CHILD | SDF_NEEDS_GROUPS) 2 SD_FLAG(SD_BALANCE_EXEC, SDF_SHARED_CHILD | SDF_NEEDS_GROUPS) 3 SD_FLAG(SD_BALANCE_FORK, SDF_SHARED_CHILD | SDF_NEEDS_GROUPS) 4 SD_FLAG(SD_BALANCE_WAKE, SDF_SHARED_CHILD | SDF_NEEDS_GROUPS) 5 82 SD_FLAG(SD_WAKE_AFFINE, SDF_SHARED_CHILD) 6 SD_FLAG(SD_SHARE_CPUCAPACITY, SDF_SHARED_CHILD | SDF_NEEDS_GROUPS) 7 SD_FLAG(SD_SHARE_PKG_RESOURCES, SDF_SHARED_CHILD | SDF_NEEDS_GROUPS) 8 SD_FLAG(SD_ASYM_PACKING, SDF_SHARED_CHILD | SDF_NEEDS_GROUPS) We call lowest_flag_domain() on SDF_SHARED_PARENT and highest_flag_domain() on SDF_SHARED_CHILD SD flags. 1 sd = lowest_flag_domain(cpu, SD_NUMA); 2 sd = lowest_flag_domain(cpu, *SD_ASYM_CPUCAPACITY*); 1 sd = highest_flag_domain(cpu, SD_SHARE_PKG_RESOURCES); 2 sd = highest_flag_domain(cpu, SD_ASYM_PACKING);