Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp270200rdb; Thu, 7 Sep 2023 23:10:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGGHPrEF5vjC71I87ztE+IPQHvC/QRGzrnp568Y8joj9PzSAT659MJPheGdewXzMka9aW8l X-Received: by 2002:a17:903:41c8:b0:1c0:bf60:ba4f with SMTP id u8-20020a17090341c800b001c0bf60ba4fmr1766055ple.4.1694153434131; Thu, 07 Sep 2023 23:10:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694153434; cv=none; d=google.com; s=arc-20160816; b=WqP5jWkEaeGXtL/JGyLvsu/kzl+4Jp9gf3jJ67zZUFV5J8+fFIUvChqToNjUxF6+lF dyUSNf9oOLPLuLbRdOyjuQXfNF63OUL5ie3WN1bK7rDTCfsxGTVvfKbwjcLf92R6xy6x rQwg1h1mDFQHmnWlVV9Tudr7Oa3GSLHMdmqJ9gtd0yuzf/1tcmIRQyl2rfRE6jxnc0Gh +fXspv+M8T3dfP2D5M+KLDWKJuvarDBglLOZOcE6ZhHrVGgaOyCPqO94oQYK5vI4O6D8 +CCfAXC8J/fu/Jh1kTFLsJPnPPR4CV4pdzPCeoy3GJnIYiAHqd/KmXHurnX2UmGmA8tH dX4Q== 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; bh=UbM5Rrn35ly8Ud5h7Nbvfi6qPGbKEpUj1gu9OUUbID0=; fh=sldJIy9DY5Chlvr5BvPLYhEdc3mAHdJnMDIv8II55p0=; b=zdynwpGo1KTNE0290v4KtzjDA/CNSkct8ugOK7+42R0D9iovT8ViJoxEMoTCaTuDrd 4VXs4J5ez8wnKr9NrmnLfXVNAgloc05d1aXWC/D+eXX8b/AwXpa5hkvu7UcqPbv0Ioey f9HnuqGeHCit2p+ewl1bWOrUOAzHE5uyHB39YFaVntC6fSYbdCPbf81pYpdmf73+gYcE YUbBVLvpfKEZprTjTkPLVyGEXyJO0xHRzS29vw8wIPE/4oIp6dnIAvbPeiZeDhAcYwaE 7EGt/cgMD5uh9lx5Ey/NSb2zMlizoQnjZXgYVxInzfVWEuoqYc3XSfqwwLBGJYbX46+o giJQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b14-20020a170902650e00b001bbcf3bc9d3si998830plk.384.2023.09.07.23.10.21; Thu, 07 Sep 2023 23:10:34 -0700 (PDT) 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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241080AbjIHDS2 (ORCPT + 58 others); Thu, 7 Sep 2023 23:18:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235397AbjIHDS2 (ORCPT ); Thu, 7 Sep 2023 23:18:28 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AEB521BD9; Thu, 7 Sep 2023 20:18:22 -0700 (PDT) Received: from kwepemd200002.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Rhh6f5jffzGprF; Fri, 8 Sep 2023 11:14:34 +0800 (CST) Received: from huawei.com (10.67.174.28) by kwepemd200002.china.huawei.com (7.221.188.186) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.1258.23; Fri, 8 Sep 2023 11:18:15 +0800 From: Liao Chang To: , , , , , , , , , , , CC: , Subject: [PATCH] cpufreq: schedutil: Merge initialization code of sg_cpu in single loop Date: Fri, 8 Sep 2023 03:16:04 +0000 Message-ID: <20230908031604.2262422-1-liaochang1@huawei.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.67.174.28] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemd200002.china.huawei.com (7.221.188.186) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS 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 The initialization code of the per-cpu sg_cpu struct is currently split into two for-loop blocks. This can be simplified by merging the two blocks into a single loop. This will make the code more maintainable. Signed-off-by: Liao Chang --- kernel/sched/cpufreq_schedutil.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index 4492608b7d7f..f3a95def49cc 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -767,14 +767,6 @@ static int sugov_start(struct cpufreq_policy *policy) sg_policy->need_freq_update = cpufreq_driver_test_flags(CPUFREQ_NEED_UPDATE_LIMITS); - for_each_cpu(cpu, policy->cpus) { - struct sugov_cpu *sg_cpu = &per_cpu(sugov_cpu, cpu); - - memset(sg_cpu, 0, sizeof(*sg_cpu)); - sg_cpu->cpu = cpu; - sg_cpu->sg_policy = sg_policy; - } - if (policy_is_shared(policy)) uu = sugov_update_shared; else if (policy->fast_switch_enabled && cpufreq_driver_has_adjust_perf()) @@ -785,6 +777,9 @@ static int sugov_start(struct cpufreq_policy *policy) for_each_cpu(cpu, policy->cpus) { struct sugov_cpu *sg_cpu = &per_cpu(sugov_cpu, cpu); + memset(sg_cpu, 0, sizeof(*sg_cpu)); + sg_cpu->cpu = cpu; + sg_cpu->sg_policy = sg_policy; cpufreq_add_update_util_hook(cpu, &sg_cpu->update_util, uu); } return 0; -- 2.34.1