Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp928093rwe; Fri, 26 Aug 2022 18:36:41 -0700 (PDT) X-Google-Smtp-Source: AA6agR5D5BFFPYbMMZM9lW0QPwR6yaVKXEKErVfiH/tzlQxtk9NVuISC7plKMCdqY9cxRbGIqZlT X-Received: by 2002:a63:ab05:0:b0:41d:a203:aee6 with SMTP id p5-20020a63ab05000000b0041da203aee6mr5435446pgf.144.1661564201472; Fri, 26 Aug 2022 18:36:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661564201; cv=none; d=google.com; s=arc-20160816; b=Gjw80Jpp4ArT6x+l+C+RS5erZ/7WxBJ4XgLkReMJlMM9dqMR8t/AdBws4kjjmY/nNj i8H0IFuAaQqNrM03vFoFDngmKaO0w1iW6zYVIlTToUvbYHVc5GHlcL3KZNtr0/2sSeRm aOKyUpcZE71DUFaQEiYSmsT2V4rFPUwixIBtr3bs5hQ4p7wN4y8jK0L17Px2ufDZuqLl Un6Xdj0NmAm93uOHMnQxqALwLbUiqI0ZEpDfhgxoofoS3ZYO8jX1xG7PfGGBfmM1g7vw 870HKW6iieDYjyU7+9CQA89BfYDuLJcDHnIR3Ezd32zaMyBsdCxfHrYLvlN4OwyCiKtI 44fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=vbHrMe2lgQqkxfHlBIeGuBWY3C5pLHDeyU/V6J/URxo=; b=fr91gYBEACFKTHTojuAewT+u27RGEFLktAj/fc4dvrbmX+IN/uR1GslFCSrSUVj9p9 pfSlpgS4CpnQcYaAPb2iCnhiiDTYefV5QQcMkD6+6/OrZZ3my6NYFV5+72U2V3L8dk2B F5UUfkTtrfEs5iNZ7Gmn9BGwolSk7eAvP+npeCQStyPWSTFSs87B5jHemS/ZQ/XGHoRz vE5SyuthGAVEHYz1Y3TcizIBex8Gxu+1qJuIt561wwsYL6G2tatcMnNzFnA+SkrWlIFH FvMVzUf/Xg5T/nhCiG+cbcruLm+h1Y7NPfsJcwdmsSj7UrY5+GDaBqVLAAulxbHzPWEV 1BuQ== 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 cv3-20020a056a0044c300b0052e40b7481fsi3193963pfb.92.2022.08.26.18.36.30; Fri, 26 Aug 2022 18:36:41 -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 S1344717AbiH0B3c (ORCPT + 99 others); Fri, 26 Aug 2022 21:29:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230416AbiH0B3b (ORCPT ); Fri, 26 Aug 2022 21:29:31 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61495E68E3 for ; Fri, 26 Aug 2022 18:29:30 -0700 (PDT) Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4MDzYH125fz1N7Rv; Sat, 27 Aug 2022 09:25:55 +0800 (CST) Received: from kwepemm600008.china.huawei.com (7.193.23.88) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Sat, 27 Aug 2022 09:29:28 +0800 Received: from huawei.com (10.175.100.227) by kwepemm600008.china.huawei.com (7.193.23.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Sat, 27 Aug 2022 09:29:27 +0800 From: Shang XiaoJing To: , , , , , , , , , , CC: Subject: [PATCH -next] sched/deadline: Save processing meaningless ops in dl_task_offline_migration Date: Sat, 27 Aug 2022 10:04:30 +0800 Message-ID: <20220827020430.29415-1-shangxiaojing@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.100.227] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemm600008.china.huawei.com (7.193.23.88) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, 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 Task's bw will be sub from old rd, and add to new rd, even though find_lock_later_rq returns a new rq that belong to the same rd with old rq. Save ops for moving task's bw if rd is not changed. Signed-off-by: Shang XiaoJing --- kernel/sched/deadline.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index 3bf4b12ec5b7..58ca9aaa9c44 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -714,20 +714,22 @@ static struct rq *dl_task_offline_migration(struct rq *rq, struct task_struct *p add_rq_bw(&p->dl, &later_rq->dl); } - /* - * And we finally need to fixup root_domain(s) bandwidth accounting, - * since p is still hanging out in the old (now moved to default) root - * domain. - */ - dl_b = &rq->rd->dl_bw; - raw_spin_lock(&dl_b->lock); - __dl_sub(dl_b, p->dl.dl_bw, cpumask_weight(rq->rd->span)); - raw_spin_unlock(&dl_b->lock); + if (&rq->rd != &later_rq->rd) { + /* + * And we finally need to fixup root_domain(s) bandwidth accounting, + * since p is still hanging out in the old (now moved to default) root + * domain. + */ + dl_b = &rq->rd->dl_bw; + raw_spin_lock(&dl_b->lock); + __dl_sub(dl_b, p->dl.dl_bw, cpumask_weight(rq->rd->span)); + raw_spin_unlock(&dl_b->lock); - dl_b = &later_rq->rd->dl_bw; - raw_spin_lock(&dl_b->lock); - __dl_add(dl_b, p->dl.dl_bw, cpumask_weight(later_rq->rd->span)); - raw_spin_unlock(&dl_b->lock); + dl_b = &later_rq->rd->dl_bw; + raw_spin_lock(&dl_b->lock); + __dl_add(dl_b, p->dl.dl_bw, cpumask_weight(later_rq->rd->span)); + raw_spin_unlock(&dl_b->lock); + } set_task_cpu(p, later_rq->cpu); double_unlock_balance(later_rq, rq); -- 2.17.1