Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp2271556rdh; Sat, 25 Nov 2023 23:22:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IG+rDcUqiPb4+fTVWnuHJbVxn3Pg5oHzueAyhN68NEex3058uJpb6Q4f2QV38WCMUggrU1d X-Received: by 2002:a17:902:db07:b0:1cf:ca67:4314 with SMTP id m7-20020a170902db0700b001cfca674314mr46899plx.37.1700983339328; Sat, 25 Nov 2023 23:22:19 -0800 (PST) Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id i16-20020a17090332d000b001cfb32056besi3258746plr.416.2023.11.25.23.22.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Nov 2023 23:22:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=OZDbIGKN; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 539338042A8D; Sat, 25 Nov 2023 23:22:16 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229473AbjKZHWA (ORCPT + 99 others); Sun, 26 Nov 2023 02:22:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229447AbjKZHV7 (ORCPT ); Sun, 26 Nov 2023 02:21:59 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BE82101 for ; Sat, 25 Nov 2023 23:22:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1700983325; x=1732519325; h=date:from:to:cc:subject:message-id:references: in-reply-to:mime-version; bh=OcrVfh5/LLGNxBN8mWoj8K709J6vgwc+oX5n99In2v0=; b=OZDbIGKNUP4bJ/Wx6Ustl0483TyH/hBpbzt7t4Qz6eFp61dRroM+Iavx tBmoRJi9lBrj8i6h8s6nnC980VsxH+aOJKeISPrYfLkLzR/c0rsaGWpSz 9apjjCX4ZBrjrYesC4H6YQGOFDQdD69MPliKQapxn7JuzDkFZr/V1Dz3W 4UihJ92bGU7PvNBzAoGbAAuSkTzeqERut4BjCq0aKCuspWw20GBMuJjLm O8fX5DDfmmH9RE+E1DSGm8z2Y5tyGO92tXNK9aBlculRXMGqLzTpKhAB/ HlKgFTTglb6Q7keDnbP4PxuSrthm2gZ0HWFOVzCOYaCk2ITklCGJgtuvB Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10905"; a="14113541" X-IronPort-AV: E=Sophos;i="6.04,228,1695711600"; d="scan'208";a="14113541" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Nov 2023 23:22:05 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10905"; a="885662797" X-IronPort-AV: E=Sophos;i="6.04,228,1695711600"; d="scan'208";a="885662797" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by fmsmga002.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 25 Nov 2023 23:22:04 -0800 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Sat, 25 Nov 2023 23:22:04 -0800 Received: from orsmsx603.amr.corp.intel.com (10.22.229.16) by ORSMSX611.amr.corp.intel.com (10.22.229.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Sat, 25 Nov 2023 23:22:03 -0800 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34 via Frontend Transport; Sat, 25 Nov 2023 23:22:03 -0800 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.169) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.34; Sat, 25 Nov 2023 23:22:03 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Y+7Lr6JvdsTjx7bz3WxVYFhupCnEd1nWC56G6CEabDu9dSuBbnhFGLUx9217XSK6WHaElO2ooIntOpIT0hIfeKJMyf5lBJpnXOzbnlPEihdc7tLp64cGK6NqfR8F16fxXtN6PaghFwURqy6US/zlIIx5SlIDCaUSlL+rCGHXsgFSkgwj0SpNc4QURad45TPVj7it08rkDi2K4+rfQfnBSrpngBQ1Vrk84x0mEmFpFcx+l/tnlmdOTeS7i3UQs3O2u2NrCpcsnjCbvRT5UCOc+h1D0Hm9W0HssrlBwMZAkqyGYOgdQGfk9cFFbOgoz5sXh6ulP60oWf7BplXlEopwCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5QxErmmB8a6BbBmgIRo5T/UOn4OUvK8XqpUB2sfIX2I=; b=KCGxyUDcBQhcqlogtqZA0K8iwkRTL+/hkwkIhYmYV2FJkIIg8MUGJHwDVeDCEQlv7EH9B39a1o89bZzeXY3fD1C4ccTY7zTPVAyYpyJBmgKyH1S5zn/h+kMu/lfe6OjS+Cu5PhIEf8h0GGSX6wNPY2gkXnNkICCfbTezL4I+AiM8ER9eEB4Iv1ibFUxEZmJoUZjyMkWpLDn2R0cF+bZJ6lpf1Eriwfj2pqbuGJUG2hNP8KrwRMI9KvrjC/ahL3y0a787CcCvckT+Th/VxgRBf/2M8nQhQPNFAev8J1/XrwIpCRJ7hrhJac0DhvAS0f1mMMNrut5/5uy+G0SDVEur5g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from MN0PR11MB6206.namprd11.prod.outlook.com (2603:10b6:208:3c6::8) by IA1PR11MB7368.namprd11.prod.outlook.com (2603:10b6:208:420::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.27; Sun, 26 Nov 2023 07:22:01 +0000 Received: from MN0PR11MB6206.namprd11.prod.outlook.com ([fe80::8c24:7666:7047:d99e]) by MN0PR11MB6206.namprd11.prod.outlook.com ([fe80::8c24:7666:7047:d99e%4]) with mapi id 15.20.7025.022; Sun, 26 Nov 2023 07:22:01 +0000 Date: Sun, 26 Nov 2023 15:21:46 +0800 From: Chen Yu To: Madadi Vineeth Reddy CC: Peter Zijlstra , Mathieu Desnoyers , Ingo Molnar , "Vincent Guittot" , Juri Lelli , <6dccbf0f54cc4ee068a157b9eebfb4b5fa3cc4af.1700548379.git.yu.c.chen@intel.com>, Tim Chen , Aaron Lu , "Dietmar Eggemann" , Steven Rostedt , Mel Gorman , K Prateek Nayak , "Gautham R . Shenoy" , Chen Yu , Subject: Re: [PATCH v2 2/3] sched/fair: Calculate the cache-hot time of the idle CPU Message-ID: References: <6dccbf0f54cc4ee068a157b9eebfb4b5fa3cc4af.1700548379.git.yu.c.chen@intel.com> <29f5225a-e0fb-2381-4f19-49334a0dbbc8@linux.ibm.com> Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <29f5225a-e0fb-2381-4f19-49334a0dbbc8@linux.ibm.com> X-ClientProxiedBy: SI2PR02CA0030.apcprd02.prod.outlook.com (2603:1096:4:195::17) To MN0PR11MB6206.namprd11.prod.outlook.com (2603:10b6:208:3c6::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN0PR11MB6206:EE_|IA1PR11MB7368:EE_ X-MS-Office365-Filtering-Correlation-Id: d86cf34a-d3e2-4982-1238-08dbee506171 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VxJfqDErmaBPz/O5wYuOH6j1vIJ5orFvzANZwUyFY527V2RIpB84u8nnFwPVco+87prNjorAYmvbggeFKY3Lnl8byFpBuhEPqTsyHs4FSEaAUeJbUvpJKY8F9vfvIuAzaofNv2Ih1qnkbr6Lpz3rL4g8Q+jmZxLK0TJ/KdhnzJyj+ak6/KbbxcBDEiY4yo7n1XwOUtanfS5TuPHA//CD8FpyH6xzT/IK7rTHgV1hEbCYYqXrJ+g0i5WGf9gHbDoYjq0veW6W+7aMLtEH6sP86tdTW+t8LACw8qMFpya02eUc7WFI+aIM6TcEb0zOvGzn09JMl6sHo+KjpwYwmqyIFUJvJvsR4bWAIE8jKNqjoeEvBaXhUI2xxfFJD7ZUqeSrh9kRTo4dl92kqiPyOZSRdAOS9ox722ph4F4HKZsTuJNsevgOKTqSEB2cIw3VloBRelhI1DyCT1A0NOTGz1c3HUCHFapqZxFoBZMmo2iEtKM8yF2jGrBl9DRNkMEbM50NRj//Zs6PLZTfW+QOeoYmadk5fIto3VykT997p0AJzYs= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN0PR11MB6206.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(39860400002)(376002)(136003)(396003)(366004)(230922051799003)(451199024)(64100799003)(186009)(1800799012)(26005)(6506007)(6666004)(6512007)(82960400001)(8936002)(8676002)(4326008)(7416002)(86362001)(5660300002)(478600001)(6486002)(316002)(966005)(54906003)(66556008)(66946007)(66476007)(6916009)(38100700002)(83380400001)(53546011)(2906002)(41300700001)(4001150100001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?gyHfHqQqMBRywSWtr6EfvSq7npUz8OMLXOaill7cyREbNo9JScgH+Fl/M/jo?= =?us-ascii?Q?nYJX29DjChGal4AayF9izVfLxHkyB1507eb9nEEKtexU+VTc/J/EPAhPRfUZ?= =?us-ascii?Q?S9Y0ITUYFWPInbn0m83GVIMbWdh7bdxALaG3tWVxonM1wSBUEbC34DPm4BYt?= =?us-ascii?Q?ANyHch4urTzOPlFHXca7jf+lqyJTpRQu/psZ6flwnzRipRkMxqb9wbwntSXB?= =?us-ascii?Q?ZW0Q3zvWvisAjb0+l/s2Ilagx5y/xKa75a7pqsaAIrengLrW/CEYWTxGj+Fc?= =?us-ascii?Q?Q1gbjgQ3tv/VJUVjXHW96PcgFcLqB8TZWTfqfDsULE7PWaLajMIdLFanalQF?= =?us-ascii?Q?GQXahBj+Xtl/XmUlbxghQcAWkFRm91DmWDX1JlbSwLUpicylD7ipkBk4+OvJ?= =?us-ascii?Q?21bU9kZNJymCciQsnPJdRV3m2lsPfPDFoQ0N9PMd4u6VRfZ4wbEYgUosVM0T?= =?us-ascii?Q?qw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b9NBepVClLN?= =?us-ascii?Q?BgeLN7GUqblW05HLKWlVuGiokYyoKJidABJpwz9GTMNE1sMyz6lkSyeM68Hb?= =?us-ascii?Q?oCd2FFgO4eU4+Zd26NKpg/BEKPjcJaLfdKOIGXm0pwB3Ez1FufDl2V+t15sn?= =?us-ascii?Q?x5yIyIPc+S8h5vNpeMEniz7U1ZYer50q7dz/PBMRQwTZ6o+bmez+QgrORsO4?= =?us-ascii?Q?fc7s/d7ViXkBBiuO0MFywUmlJcKGDCWwvFqup86A?= X-MS-Exchange-CrossTenant-Network-Message-Id: d86cf34a-d3e2-4982-1238-08dbee506171 X-MS-Exchange-CrossTenant-AuthSource: MN0PR11MB6206.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Nov 2023 07:22:00.4372 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: HW00vx8lk9GoEf9BBt9Bx/FVOUU8raUgy0ncgpyFOn5kVE5+fMDgt1PQLrbdDVJxDifm4/HT16iBwSJnwz5MkA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR11MB7368 X-OriginatorOrg: intel.com X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Sat, 25 Nov 2023 23:22:16 -0800 (PST) Hi Madadi, On 2023-11-25 at 12:40:18 +0530, Madadi Vineeth Reddy wrote: > Hi Chen Yu, > > On 21/11/23 13:09, Chen Yu wrote: > > When a CPU is about to become idle due to task dequeue, uses > > the dequeued task's average sleep time to set the cache > > hot timeout of this idle CPU. This information can facilitate > > SIS to skip the cache-hot idle CPU and scan for the next > > cache-cold one. When that task is woken up again, it can choose > > its previous CPU and reuses its hot-cache. > > > > This is a preparation for the next patch to introduce SIS_CACHE > > based task wakeup. > > > > Signed-off-by: Chen Yu > > --- > > kernel/sched/fair.c | 30 +++++++++++++++++++++++++++++- > > kernel/sched/features.h | 1 + > > kernel/sched/sched.h | 1 + > > 3 files changed, 31 insertions(+), 1 deletion(-) > > > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > > index 672616503e35..c309b3d203c0 100644 > > --- a/kernel/sched/fair.c > > +++ b/kernel/sched/fair.c > > @@ -6853,8 +6853,17 @@ static void dequeue_task_fair(struct rq *rq, struct task_struct *p, int flags) > > util_est_update(&rq->cfs, p, task_sleep); > > > > if (task_sleep) { > > - p->last_dequeue_time = sched_clock_cpu(cpu_of(rq)); > > + u64 now = sched_clock_cpu(cpu_of(rq)); > > + > > + p->last_dequeue_time = now; > > p->last_dequeue_cpu = cpu_of(rq); > > + > > +#ifdef CONFIG_SMP > > + /* this rq becomes idle, update its cache hot timeout */ > > + if (sched_feat(SIS_CACHE) && !rq->nr_running && > > + p->avg_hot_dur) > > + rq->cache_hot_timeout = max(rq->cache_hot_timeout, now + p->avg_hot_dur); > > As per the discussion in the rfc patch, you mentioned that SIS_CACHE only honors the average sleep time > of the latest dequeued task and that we don't know how much of the cache is polluted by the latest task. > > So I was wondering what made you to put max here. > Thanks for taking a look. Yes, previously SIS_CACHE only honors the latest dequeue task. But as Mathieu pointed out[1], the latest dequeue task might not have enough time to scribble the cache footprint of some older dequeue tasks, and we should honor the sleep time of those older dequeue tasks. Consider the following scenario: task p1 is dequeued with an average sleep time of 2 msec. Then p2 is scheduled in on this cpu, but only runs for 10 us(does not pollute the cache footprint) and dequeued with average sleep time of 1 msec. Should we tag the CPU runqueue's timeout as 2 msec or 1 msec later? We choose 2 msec. The idea is to make the timeout moving forward so the SIS_CACHE could make it easier for the p1 to be woken up on its previous CPU. [1] https://lore.kernel.org/lkml/2a47ae82-b8cd-95db-9f48-82b3df0730f3@efficios.com/ thanks, Chenyu