Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp900315pxm; Thu, 3 Mar 2022 06:48:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJy430b1IaaN5XtsshLW12IlTvroFY1Y9TtpgnU1E7LWCSFAImMkitZ+h7GVTyFCZHtbFeTC X-Received: by 2002:a05:6402:175a:b0:415:ee73:3e25 with SMTP id v26-20020a056402175a00b00415ee733e25mr1054236edx.1.1646318903431; Thu, 03 Mar 2022 06:48:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646318903; cv=none; d=google.com; s=arc-20160816; b=NmOuya3Iq2M/FKfJA2Lw6XSHoNt5oAraHcSc5c4u406Fp8KvhYeCXU8zhf+w+csyb1 pstDK0KBaCQYVBY62nKFreDLnaVz27jIca9e9thI752gFnlCaP0vEy7SfGjlevtxgZwj PhM09H3xjwUoQzwTLNOxmYUQF0EQ8ucAjOO3gS2Le/sq4Y8pP+OaU75nOR0D2AQ1MENU JBBgniBZ1/f8sLKrjXmdj3gK1J+oRluQEwYpvybI1jIkMnXInwiNcfgK3UK5GmtwG64Y L6hGI+V/CBg0S+4zLfFtkG7uaglQ9/Y5jRoY6Jr89Wf54/wP2hg9DUScBFdy9jGjtD5G IpRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=VexrjkXSjl/LTDm+xnGgTi8XTrYcdQ/0U3vjR+rYTQw=; b=NnBg0ZzdfFmRU5oFN020SGyQaWMi6cMLFQfwfrlcwuxxWeU9eZqDKG+9c6gqyT4wJ2 VselIjmwoVkuxIwVIH55CGRDBIvvPkSb004w/o6ytn2UQBWqmaL6wWkqDuoL+BCEND63 WAtLIh8GpPDvlaqT3SDLbtp72g9sqx1UUm5G9rPtQ82qn6QnLkWAOnGD7/yYc8gga9Ik kZQCo3XZMQsz0GJR+XSHQ+d+f3Lu0YwxSPFk4bHQKJ4VcxVBCOaX7LeWVF6ObAPmbMaO mCeqo8DIh2P92gxInfHbtSZZnuAchIJ3NudVQCYzbyZXjEMQfVJOJHDTghUqa9oOtF26 eciA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=p1j7mA4Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bh15-20020a170906a0cf00b006b25c172698si1259716ejb.822.2022.03.03.06.47.56; Thu, 03 Mar 2022 06:48:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=p1j7mA4Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233692AbiCCNUl (ORCPT + 99 others); Thu, 3 Mar 2022 08:20:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231211AbiCCNUk (ORCPT ); Thu, 3 Mar 2022 08:20:40 -0500 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A004B188870 for ; Thu, 3 Mar 2022 05:19:54 -0800 (PST) Received: by mail-ed1-x531.google.com with SMTP id f8so6563377edf.10 for ; Thu, 03 Mar 2022 05:19:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=VexrjkXSjl/LTDm+xnGgTi8XTrYcdQ/0U3vjR+rYTQw=; b=p1j7mA4YzD3XdeLqxs2B1b8zKL6YZUoDqmFhWdCRW7JWnkJx8j0Em3ciA/IQx2xIJY 9qNHbVbhQY9JntYcwKWlljR4V0icJQXqcdT+k/QStB+rCraJhMwVOVN6WSBtiLIIhw/B ixzTTLJYLnG9+DLq5U1JM5VzzZDsr+LezlGZNnqPce8IRZKgDj7gC2jhRQRusDHXx72X 0lgBEt7RvCd1mCZkR96nja6+whvhw0UZhT3XlWT4spuFdF6xj9ByDgX8oyD2FDkdNQUV cryPmyfLEDZmH/37imjP9KER89/sQMqMN5djWJBV048VXma/IRCovAGirCQSEjk9Gzec CZCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=VexrjkXSjl/LTDm+xnGgTi8XTrYcdQ/0U3vjR+rYTQw=; b=IIzHgebHdX2HnmBoKIB/9Eh35As6SAfPk81dv4cDPbUwcr5TBq4TejfpVhuvAsvrlt IcnjjReT40T7iaUSmOhalfy9IwOdE2IiWQSauHH81UX+Hl8PRRSKSfsrLKZFZ80LbdfH Zc/BvSuN187WE/sFIY/2YAwnxUL2j5HrEs0bF4WyO//GMJydAmiNdaHKIuEqrBJtlV4M YZ9Rs9XxAjHSrH0a7kutRYfzyyfLAiwMFO9QuA4Fhep8io4fHUbb/HDpf7Tz2oZm33a4 pVHWHe4uZ+xBPw/744MAOg+Yj6QeC53G9cUexPtNxsOp+lv+j35ZwOxkeJwrPnr4QbDn NjGA== X-Gm-Message-State: AOAM532EwNebquUVN504jwTI7ilJIK3lEJqNgpLddruS1XIezJRtLo8P y2uQnmtaedcUoWXvyeIexAo= X-Received: by 2002:a05:6402:34cb:b0:415:b974:ec5c with SMTP id w11-20020a05640234cb00b00415b974ec5cmr8031561edc.329.1646313592647; Thu, 03 Mar 2022 05:19:52 -0800 (PST) Received: from tsf-452-wpa-4-117.epfl.ch (tsf-452-wpa-4-117.epfl.ch. [128.179.156.117]) by smtp.gmail.com with ESMTPSA id h24-20020a170906261800b006da94c9ccc9sm481323ejc.129.2022.03.03.05.19.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Mar 2022 05:19:52 -0800 (PST) From: Chun-Hung Tseng To: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, christian@brauner.io, linux-kernel@vger.kernel.org Cc: Chun-Hung Tseng Subject: [PATCH v3] sched: Simplify __sched_init runtime checks Date: Thu, 3 Mar 2022 14:19:42 +0100 Message-Id: <20220303131942.12030-1-henrybear327@gmail.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Improve runtime checks in __sched_init(void) by replacing if conditional checks with preprocessor directives. Signed-off-by: Chun-Hung Tseng --- kernel/sched/core.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 9745613d531c..003e8677f6ba 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -9317,28 +9317,29 @@ void __init sched_init(void) #ifdef CONFIG_RT_GROUP_SCHED ptr += 2 * nr_cpu_ids * sizeof(void **); #endif - if (ptr) { - ptr = (unsigned long)kzalloc(ptr, GFP_NOWAIT); + +#if defined(CONFIG_FAIR_GROUP_SCHED) || defined(CONFIG_RT_GROUP_SCHED) + ptr = (unsigned long)kzalloc(ptr, GFP_NOWAIT); #ifdef CONFIG_FAIR_GROUP_SCHED - root_task_group.se = (struct sched_entity **)ptr; - ptr += nr_cpu_ids * sizeof(void **); + root_task_group.se = (struct sched_entity **)ptr; + ptr += nr_cpu_ids * sizeof(void **); - root_task_group.cfs_rq = (struct cfs_rq **)ptr; - ptr += nr_cpu_ids * sizeof(void **); + root_task_group.cfs_rq = (struct cfs_rq **)ptr; + ptr += nr_cpu_ids * sizeof(void **); - root_task_group.shares = ROOT_TASK_GROUP_LOAD; - init_cfs_bandwidth(&root_task_group.cfs_bandwidth); + root_task_group.shares = ROOT_TASK_GROUP_LOAD; + init_cfs_bandwidth(&root_task_group.cfs_bandwidth); #endif /* CONFIG_FAIR_GROUP_SCHED */ #ifdef CONFIG_RT_GROUP_SCHED - root_task_group.rt_se = (struct sched_rt_entity **)ptr; - ptr += nr_cpu_ids * sizeof(void **); - - root_task_group.rt_rq = (struct rt_rq **)ptr; - ptr += nr_cpu_ids * sizeof(void **); + root_task_group.rt_se = (struct sched_rt_entity **)ptr; + ptr += nr_cpu_ids * sizeof(void **); + root_task_group.rt_rq = (struct rt_rq **)ptr; + ptr += nr_cpu_ids * sizeof(void **); #endif /* CONFIG_RT_GROUP_SCHED */ - } +#endif /* CONFIG_FAIR_GROUP_SCHED || CONFIG_RT_GROUP_SCHED */ + #ifdef CONFIG_CPUMASK_OFFSTACK for_each_possible_cpu(i) { per_cpu(load_balance_mask, i) = (cpumask_var_t)kzalloc_node( -- 2.35.1