From patchwork Mon Nov 28 13:20:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Neri X-Patchwork-Id: 26750 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp5656767wrr; Mon, 28 Nov 2022 05:14:24 -0800 (PST) X-Google-Smtp-Source: AA0mqf5cY9MXBDJMeO7d/5+f5ypx/4cbiiN7jdSM7pwAemULSDFwwj4RJ8NDmm5YGTn/zy8UlIsB X-Received: by 2002:a63:e712:0:b0:477:7f69:2749 with SMTP id b18-20020a63e712000000b004777f692749mr28057245pgi.372.1669641264567; Mon, 28 Nov 2022 05:14:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669641264; cv=none; d=google.com; s=arc-20160816; b=Ve/jNshY54v29Fttsrcw/+cw1e6FI7cPBJRFDTqWQT9hdMQKdaGuvu1nf1MljVLTpP ie4NZecjVu26n6DiB9VuBiZUEPPyycHxYedgXoBdjbtMhoGBmSsmDaYzcCzWhHeCX860 mOstNTFjqhsTI+fES2xkhMHAo9qgrK2CNouguXGqt50ZYpUQOzi6gSk3YAz003LgvDXg nP7qblEDf0c3LRMTyLXk4IqAWAsXus3kWcPd7OoxpCONhVsCVu5U9wNICrr06iS3wYxN PJ3+hTeVEDO8eEgmrzkikANH8zCARkVO9HaheovqqTrmSp4lENpjFXu1vKf/t133JJbO MoKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=2vRpEfOcFgBCSadpFHePE6e3zGb0qgi591/Sv8/47+s=; b=jnpxPWje23bnHY4S01XemrLSVq0Ue5YKJPq8gKuEGAqKTcQJDIHt0p5RanVy5W4R3A FTDvX69BBenPoV81LOqARsTcJA33wMpEyMJyLfT5uQEFNFdxOKDAWHRkmn+DC4Dwa2AA oz2Lf5mI+vXkbxXO+pn+ykje1cC/MgMW6o1oXqDjy5jaCcRSPP+9HzVrV2cQQae5Dspv nQsl85Iw5j3748SJwvexFG/Eszy7EMu1vuktwZYP+Ipy5laPeeIHv1vzHGY6ICr3TF2f tJMHcoEujetRugDMiIm9XC3a4d8x6sNirZGZxTjB6sci5iZnOBWIwfyzUv8kRQhA4j4c TDlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="U5vi/ORG"; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y6-20020a655b46000000b00476f2af54f6si13126093pgr.47.2022.11.28.05.14.07; Mon, 28 Nov 2022 05:14:24 -0800 (PST) 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="U5vi/ORG"; 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 S231332AbiK1NNq (ORCPT + 99 others); Mon, 28 Nov 2022 08:13:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231656AbiK1NNd (ORCPT ); Mon, 28 Nov 2022 08:13:33 -0500 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5727713D5E; Mon, 28 Nov 2022 05:13:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669641212; x=1701177212; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=bVqpVo1Q9MYSWk8Td5o+e8rn4ip/1+KMBJaJ/M8s+/Y=; b=U5vi/ORGokvMveSG0Qai9S11M08uOBRjdSHA8jXTTzLa/lPDNCuT7VvG 8B9LKyJjj3eCneQEjqVHlJNnyHMu2TGaEC8GGCNV5yTk4KHa++thsMMeb l5iCSupGVtJK7hfRJqg6g0EPqyy2ZI60zCZRjn8tZu62mSuhuZeRaBYbm fmNEFhICVDfE3Co+d5zeqdzCqk47bwvo8zk1Ff+ryj+1b69WPwhxi79Mk 34f1KPLeonfpCRCiQwyYtvxX8sENJcSDv2cDCNqvRfPErv12Jn7FFtfA3 X3ZuadxzzzstMV4a3hPI7mZIy5kQ03No4d1QBqNJ30D/3GNT/XVn9C+eo g==; X-IronPort-AV: E=McAfee;i="6500,9779,10544"; a="401117058" X-IronPort-AV: E=Sophos;i="5.96,200,1665471600"; d="scan'208";a="401117058" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Nov 2022 05:13:31 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10544"; a="749381321" X-IronPort-AV: E=Sophos;i="5.96,200,1665471600"; d="scan'208";a="749381321" Received: from ranerica-svr.sc.intel.com ([172.25.110.23]) by fmsmga002.fm.intel.com with ESMTP; 28 Nov 2022 05:13:31 -0800 From: Ricardo Neri To: "Peter Zijlstra (Intel)" , Juri Lelli , Vincent Guittot Cc: Ricardo Neri , "Ravi V. Shankar" , Ben Segall , Daniel Bristot de Oliveira , Dietmar Eggemann , Len Brown , Mel Gorman , "Rafael J. Wysocki" , Srinivas Pandruvada , Steven Rostedt , Tim Chen , Valentin Schneider , x86@kernel.org, "Joel Fernandes (Google)" , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Ricardo Neri , "Tim C . Chen" Subject: [PATCH v2 01/22] sched/task_struct: Introduce IPC classes of tasks Date: Mon, 28 Nov 2022 05:20:39 -0800 Message-Id: <20221128132100.30253-2-ricardo.neri-calderon@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221128132100.30253-1-ricardo.neri-calderon@linux.intel.com> References: <20221128132100.30253-1-ricardo.neri-calderon@linux.intel.com> X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750745758362341880?= X-GMAIL-MSGID: =?utf-8?q?1750745758362341880?= On hybrid processors, the architecture differences between the types of CPUs lead to different instructions-per-cycle (IPC) on each type of CPU. IPCs may differ further by the type of instructions. Instructions can be grouped into classes of similar IPCs. Hence, tasks can be classified into groups based on the type of instructions they execute. Add a new member task_struct::ipcc to associate a particular task to an IPC class that depends on the instructions it executes. The scheduler may use the IPC class of a task and data about the performance among CPUs of a given IPC class to improve throughput. It may, for instance, place certain classes of tasks on CPUs of higher performance. The methods to determine the classification of a task and its relative IPC score are specific to each CPU architecture. Cc: Ben Segall Cc: Daniel Bristot de Oliveira Cc: Dietmar Eggemann Cc: Joel Fernandes (Google) Cc: Len Brown Cc: Mel Gorman Cc: Rafael J. Wysocki Cc: Srinivas Pandruvada Cc: Steven Rostedt Cc: Tim C. Chen Cc: Valentin Schneider Cc: x86@kernel.org Cc: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Ricardo Neri --- Changes since v1: * Renamed task_struct::class as task::struct_ipcc. (Joel) * Use task_struct::ipcc = 0 for unclassified tasks. (PeterZ) * Renamed CONFIG_SCHED_TASK_CLASSES as CONFIG_IPC_CLASSES. (PeterZ, Joel) --- include/linux/sched.h | 10 ++++++++++ init/Kconfig | 12 ++++++++++++ 2 files changed, 22 insertions(+) diff --git a/include/linux/sched.h b/include/linux/sched.h index 68c07ae0d7ff..47ae3557ba07 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -127,6 +127,8 @@ struct task_group; __TASK_TRACED | EXIT_DEAD | EXIT_ZOMBIE | \ TASK_PARKED) +#define IPC_CLASS_UNCLASSIFIED 0 + #define task_is_running(task) (READ_ONCE((task)->__state) == TASK_RUNNING) #define task_is_traced(task) ((READ_ONCE(task->jobctl) & JOBCTL_TRACED) != 0) @@ -1525,6 +1527,14 @@ struct task_struct { union rv_task_monitor rv[RV_PER_TASK_MONITORS]; #endif +#ifdef CONFIG_IPC_CLASSES + /* + * A hardware-defined classification of task based on the number + * of instructions per cycle. + */ + unsigned int ipcc; +#endif + /* * New fields for task_struct should be added above here, so that * they are included in the randomized portion of task_struct. diff --git a/init/Kconfig b/init/Kconfig index abf65098f1b6..cd17dd4d3718 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -865,6 +865,18 @@ config UCLAMP_BUCKETS_COUNT If in doubt, use the default value. +config IPC_CLASSES + bool "IPC classes of tasks" + depends on SMP + help + If selected, each task is assigned a classification value that + reflects the type of instructions that the task executes. This + classification reflects but is not equal to the number of + instructions retired per cycle. + + The scheduler uses the classification value to improve the placement + of tasks. + endmenu #