From patchwork Sun Mar 19 20:02:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Li kunyu X-Patchwork-Id: 71549 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp117736wrt; Fri, 17 Mar 2023 21:03:45 -0700 (PDT) X-Google-Smtp-Source: AK7set8AkqAUQxROQeDqngF8DB0dSeQl/tgS2O3cE6MNdIFar0Vts3U6lrQLWm/YBsGY3heUsOmn X-Received: by 2002:a05:6a00:1ca1:b0:5fc:cd83:92f1 with SMTP id y33-20020a056a001ca100b005fccd8392f1mr9027045pfw.1.1679112225171; Fri, 17 Mar 2023 21:03:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679112225; cv=none; d=google.com; s=arc-20160816; b=P7t0RgaDtk/ZEjbG4xG4R1VQPcEUkyh4W2/JhZjuyQG0ep4MpGHliun+NwVM/9cWYE Nzmlh+cKCToY5y3YyD5nq0/lC+Di6wdjwjEMeGfY4vC+GXE5FFU9/PJg0O8i8tWpxfDV icMQgkB3afRCKTZ2o8Hnl+frG8uwod4cCrh1XlPUSidTlAp8XU+JMkk1u6oS+yWZDvAh Hl8KkBlALziXGZWA4qdylKQwHjCJzfKq6jgI5fXSuMCuLU3TztdIYD6zQHP/TMnJ/LxD XNZJFUaCHLkOCFmk5YoFKErSFeEmeWywPYqDtYR7Gu94LyCmncsgo9OYGaQQ9uQshX9J gT+Q== 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=QhxjXiTLZfkjhQdGHcOr2+Kk8bhsLHZ1fNwfkefEOfg=; b=JDoudQ6U9k+Hsy8ApvuN2tkNBUIzwyRWPcOm8jUE02FVtgYmZTHZ/4xFzQQZbtNlUR AJ4DfMRNu7XRoR/ArQ2WxYdsbUcFeCUWAVEELv72bK7T04XmbL8IBGA2+ISTBgvxui9Q QgWDb7hTEZcuSZydSOe8Ktjapghm3WED0K+fWTqycxq9ewbss0+dhEzBb/DYhqPjy6XL F6Z6k0h5G6fzFCn60JptnM95wsd3mLxfu7st8YMi/JB4f9N6LKuyGPIXgYCGPNm9JLDF +NlCgEuRc4UK5gzoMlyLrB0WPXaeO4q2PM1aba4g57oSaE+v8q03DZi2Z94qQiM8YjBT 2sbA== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z3-20020aa79f83000000b005a8a56ac57esi4022437pfr.246.2023.03.17.21.03.32; Fri, 17 Mar 2023 21:03:45 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229755AbjCRDbo (ORCPT + 99 others); Fri, 17 Mar 2023 23:31:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229604AbjCRDbm (ORCPT ); Fri, 17 Mar 2023 23:31:42 -0400 Received: from mail.nfschina.com (unknown [42.101.60.237]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42E243E1E3 for ; Fri, 17 Mar 2023 20:31:40 -0700 (PDT) Received: from localhost (unknown [127.0.0.1]) by mail.nfschina.com (Postfix) with ESMTP id DE4961A00AE2; Sat, 18 Mar 2023 11:31:40 +0800 (CST) X-Virus-Scanned: amavisd-new at nfschina.com Received: from mail.nfschina.com ([127.0.0.1]) by localhost (localhost.localdomain [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id I47z3DFNmwEc; Sat, 18 Mar 2023 11:31:40 +0800 (CST) Received: from localhost.localdomain (unknown [219.141.250.2]) (Authenticated sender: kunyu@nfschina.com) by mail.nfschina.com (Postfix) with ESMTPA id A5BDC1A0091E; Sat, 18 Mar 2023 11:31:39 +0800 (CST) From: Li kunyu 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, vschneid@redhat.com Cc: linux-kernel@vger.kernel.org, Li kunyu Subject: [PATCH] sched: core: Optimize the structure of 'tg_cfs_schedulable_down' function Date: Mon, 20 Mar 2023 04:02:55 +0800 Message-Id: <20230319200255.3640-1-kunyu@nfschina.com> X-Mailer: git-send-email 2.18.2 MIME-Version: 1.0 X-Spam-Status: No, score=2.3 required=5.0 tests=BAYES_00,DATE_IN_FUTURE_24_48, RCVD_IN_VALIDITY_RPBL,RDNS_NONE,SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: ** 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760676780588913900?= X-GMAIL-MSGID: =?utf-8?q?1760676780588913900?= Optimize if branches and define in the branch statement block parent_quota variable. Signed-off-by: Li kunyu --- kernel/sched/core.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 488655f2319f..7e8535d2e36d 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -10915,15 +10915,12 @@ static int tg_cfs_schedulable_down(struct task_group *tg, void *data) { struct cfs_schedulable_data *d = data; struct cfs_bandwidth *cfs_b = &tg->cfs_bandwidth; - s64 quota = 0, parent_quota = -1; + s64 quota = RUNTIME_INF; - if (!tg->parent) { - quota = RUNTIME_INF; - } else { + if (tg->parent) { struct cfs_bandwidth *parent_b = &tg->parent->cfs_bandwidth; - + s64 parent_quota = parent_b->hierarchical_quota; quota = normalize_cfs_quota(tg, d); - parent_quota = parent_b->hierarchical_quota; /* * Ensure max(child_quota) <= parent_quota. On cgroup2,