Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2409785pxb; Fri, 25 Mar 2022 17:32:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwjo8N3CNmHpbjdnMCqZuD0YgQHBDvqHzoOIqGYNDTxiZsshLSBCQUvBa/OPT2tfr6YC7OZ X-Received: by 2002:a05:6402:35c5:b0:419:2c72:66c3 with SMTP id z5-20020a05640235c500b004192c7266c3mr1593426edc.343.1648254751327; Fri, 25 Mar 2022 17:32:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648254751; cv=none; d=google.com; s=arc-20160816; b=F1D6H12bP5EhgK8Iv3z4MoXVi0ZzH9CSLPH6d7QyKxO/4yYwIMWPWpY8CYHXFunf02 a8WjYec+d5v6fYDwf2wveMFZMM35b0VQoUQ/pHdArjsB5X+8x4VG1Dha4w40ulB5S7W7 h9RZFG+BvCJ0T6FHA4ilCHpX+ja9LmVPkR7BpD3mnj/OKSZyuA98eCU5d6TkzQIM228S VdGwAFk0K8aMnOs30l+xZxV9jvr3dTulYrw37yhDwzxp5yehRYXoNvgsrQ3PfDTXXy6v mWtbUEokBnFiA2Ex3JBb5TkPaczkp1WLvsv0qezyQUdvm0bYrJ0CoFwbC5DlwNwT/8OU 5txw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qLUuTy+GoN9nVpBPP6xdbMpMIG8GCoMLbiaPj8pzyAA=; b=RptPKXTHjlHkOo8ld+d4BpWiDahFLK3XhXXeP1cekioNnMjUrPVCaPg1ebhSVRCr4e Mh54MTxtqNDPWQG3gjRItoHkasutJywSEPoQmPbrD5dfyAdzBltvJ5C8Z++0HnVPbGQo RpaHysBb7A1mE9MINFvgZV6hHkul6RUxDfCdlsbEy3pBlO0t/9U4tJrhXdI0PWU1trRb U/hxfEHZcFO+6oiupMby6A4cKw+i6NxuIVr73T1y9bsxVyEJHF2Th/M1HqOpQvIDeFtI YGCdAljX8E63mRb+kyB6dQUfhBEMMJpZwfjCVA1U8X3eOmL1Qt9NKPaBsoTlmkDH+zi9 Ttjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=HEeKewEy; 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=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gh2-20020a1709073c0200b006df76385d10si3752403ejc.432.2022.03.25.17.32.05; Fri, 25 Mar 2022 17:32:31 -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; dkim=pass header.i=@intel.com header.s=Intel header.b=HEeKewEy; 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=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229633AbiCYXxt (ORCPT + 99 others); Fri, 25 Mar 2022 19:53:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229562AbiCYXxo (ORCPT ); Fri, 25 Mar 2022 19:53:44 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CEA14AE33 for ; Fri, 25 Mar 2022 16:52:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648252329; x=1679788329; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mHLNNSPQ4EYmrAFhqKFt7xJOVLotEnt4YlgX3orT5jE=; b=HEeKewEyJM9Ob/1FQBjkI6q0G23b/yOLq4Bwn9Ic5cQUX+iAWM/X3yPI o/BrI9tLU4kve7jzq4ZpKagWD1LVCnmyFDzGpCllENYKYJ+EH3V5ddicP 9ORYR6U71wmoXn4sd2mVeyaflUEm2mqVCvEQ6hbpJnZdhxOvLOlPXKtmG xnhmYpEWNrLNDdU72y+4DtnZWwWVHvF81bE2LWESYvyt2quQub8iMNUGm iprWdRHQ5BOxuIaTs6Lv1cEQ9ncrrwqqTVOtL/l2BGbLyhDys+YUa9hed Pn3SoiXB54vpDaCHb0+AOWt194m90XPZ5Yq3W3mJTrB2cAKfsGgopAeJj g==; X-IronPort-AV: E=McAfee;i="6200,9189,10297"; a="321930148" X-IronPort-AV: E=Sophos;i="5.90,211,1643702400"; d="scan'208";a="321930148" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2022 16:52:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,211,1643702400"; d="scan'208";a="648425294" Received: from skl-02.jf.intel.com ([10.54.74.28]) by fmsmga002.fm.intel.com with ESMTP; 25 Mar 2022 16:52:08 -0700 From: Tim Chen To: Peter Zijlstra , Vincent Guittot , Ingo Molnar , Juri Lelli Cc: Yu Chen , Walter Mack , Mel Gorman , linux-kernel@vger.kernel.org, Tim Chen Subject: [PATCH 1/2] sched/fair: Don't rely on ->exec_start for migration Date: Fri, 25 Mar 2022 15:54:16 -0700 Message-Id: <68832dfbb60fda030540b5f4e39c5801942689b1.1648228023.git.tim.c.chen@linux.intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_NONE,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 From: Peter Zijlstra From: Peter Zijlstra (Intel) Currently migrate_task_rq_fair() (ab)uses se->exec_start to make task_hot() fail. In order to preserve ->exec_start, add a ->migrated flag to sched_entity. Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Tim Chen --- include/linux/sched.h | 1 + kernel/sched/fair.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/linux/sched.h b/include/linux/sched.h index 75ba8aa60248..0edf16b4d40a 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -541,6 +541,7 @@ struct sched_entity { struct rb_node run_node; struct list_head group_node; unsigned int on_rq; + unsigned int migrated; u64 exec_start; u64 sum_exec_runtime; diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 5146163bfabb..2498e97804fd 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -1004,6 +1004,7 @@ update_stats_curr_start(struct cfs_rq *cfs_rq, struct sched_entity *se) /* * We are starting a new run period: */ + se->migrated = 0; se->exec_start = rq_clock_task(rq_of(cfs_rq)); } @@ -6979,7 +6980,7 @@ static void migrate_task_rq_fair(struct task_struct *p, int new_cpu) p->se.avg.last_update_time = 0; /* We have migrated, no longer consider this task hot */ - p->se.exec_start = 0; + p->se.migrated = 1; update_scan_period(p, new_cpu); } @@ -7665,6 +7666,9 @@ static int task_hot(struct task_struct *p, struct lb_env *env) if (sysctl_sched_migration_cost == 0) return 0; + if (p->se.migrated) + return 0; + delta = rq_clock_task(env->src_rq) - p->se.exec_start; return delta < (s64)sysctl_sched_migration_cost; -- 2.32.0