From patchwork Tue Feb 7 05:10:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Neri X-Patchwork-Id: 53669 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2652814wrn; Mon, 6 Feb 2023 21:02:47 -0800 (PST) X-Google-Smtp-Source: AK7set+nIwkGmvANtWZUnrRuSsGw/3EWKKCpvXKCvuuwXJvkG5ZlSBNmU+wa7KKNSwb7U6PRxe2V X-Received: by 2002:a17:902:f809:b0:196:32fa:69a9 with SMTP id ix9-20020a170902f80900b0019632fa69a9mr1370956plb.51.1675746167593; Mon, 06 Feb 2023 21:02:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675746167; cv=none; d=google.com; s=arc-20160816; b=iYtBwf1DyWniPxJlWBf4+g/wNopqnE1l7r/SJhHHO23t60xxpsw37pbl9tC8IgaqR0 DJg4Iuuu7gMkTyvwo5TqS3NLB9iG59+nu/pk0/4hSP8VLi3ZpvS3ZA7Fv4Xm1y+DykbI AFhr49gxYe82vGF0N7j5BBlrg62XN7QsOd953+AaL8eU02E9o+rrB7rLLu7JX/KQ8CM5 KZzO+pD9CFieP9yOMGME+S+DysW2cgLoeYfD7FF//jtY0RcmuP9rAMHD1R9zWDcGZF0L b7XP7ABfko2B9kKDtju4tfDE8iWipRUoKot/ZM5A1FvhSLwOv61Fmc9a6qhxR7+xR4DD xC1Q== 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=4tpXAC6ZOL2TtTbMN+BSq5ZEVnqY/mOkGbKRH+3t6I8=; b=jgmqB/f5/lZOy93jNqDYT8+O4u2ZA7H+GzrL37848e/kkm4qIu57yj0rvkmLg9yt1q fSzuy+mQjrHPb+gD5oGC1z5WQUKFvGslLM6oVbkme4bD3OZVbspsvKfJhqFgGo43NtZO 8Hz1RoDuwDHzOmc6AlQ4rdJXZl8CFTKxgrx5+nq6MakwX4NVpxYQGjoypq1hyAkYepkK pr2rDEWQxxKeY0Zkc3HH6IQS71CLUJE7RO04I7DhZVF7srPg4ZBoItStSH1vXVBRzwIT PHLFZBVKUwiVzofTjdCTLVMAnmqbaJL4v44nXMYdlHl+vhg9eFlfuwVnwy8N3y1InR94 e/FA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=l6lE2P4k; 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 u2-20020a170902a60200b00196711a94f6si12480844plq.353.2023.02.06.21.02.35; Mon, 06 Feb 2023 21:02:47 -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=l6lE2P4k; 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 S230167AbjBGFCB (ORCPT + 99 others); Tue, 7 Feb 2023 00:02:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230040AbjBGFBt (ORCPT ); Tue, 7 Feb 2023 00:01:49 -0500 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C78A22B2BC; Mon, 6 Feb 2023 21:01:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675746101; x=1707282101; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=lZUt9bTzhG5+Fn6a2/x++iylr7jp1U1p86qFgAgn3yU=; b=l6lE2P4kbnF0kklERSzoSHvU0x1byi/pE8aw7AtzyiS93pW2d3z/oh6k zg/ryjKJvt6n2Gw5J54AlcUJSO0nNDtHryL7C5GQHO3FPYdHUqKSLGKDQ 3B+EzhDjmh5IRDGVGYfCGcz4jC9akVS0R96Afkys4lJuHx19dhshaui4t UwJMt3oPJ9RkPk5Kg7NbAEwrJc+z3Ja9As0/RC8U83D7PmXPiPMZBQYlT 8AlQJoNt9PSV0rpn4xOJlq0cAkJKBKU/0VZP3QmK6cv2TTGJotUN2xmz2 EaQdOl4u6rP+ZIBfae8+La3ukKKGNDMVKhEV+RWWLHW4MqPBWlHOnRfA7 w==; X-IronPort-AV: E=McAfee;i="6500,9779,10613"; a="415625738" X-IronPort-AV: E=Sophos;i="5.97,278,1669104000"; d="scan'208";a="415625738" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Feb 2023 21:01:40 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10613"; a="668657688" X-IronPort-AV: E=Sophos;i="5.97,278,1669104000"; d="scan'208";a="668657688" Received: from ranerica-svr.sc.intel.com ([172.25.110.23]) by fmsmga007.fm.intel.com with ESMTP; 06 Feb 2023 21:01:39 -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 , Lukasz Luba , Ionela Voinescu , x86@kernel.org, "Joel Fernandes (Google)" , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Ricardo Neri , "Tim C . Chen" Subject: [PATCH v3 01/24] sched/task_struct: Introduce IPC classes of tasks Date: Mon, 6 Feb 2023 21:10:42 -0800 Message-Id: <20230207051105.11575-2-ricardo.neri-calderon@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230207051105.11575-1-ricardo.neri-calderon@linux.intel.com> References: <20230207051105.11575-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?1757147213156012399?= X-GMAIL-MSGID: =?utf-8?q?1757147213156012399?= 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: Ionela Voinescu Cc: Joel Fernandes (Google) Cc: Len Brown Cc: Lukasz Luba 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 v2: * Changed the type of task_struct::ipcc to unsigned short. A subsequent patch uses bit fields to use 9 bits, along with other auxiliary members. 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 4df2b3e76b30..98f84f90a01d 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) @@ -1528,6 +1530,14 @@ struct task_struct { union rv_task_monitor rv[RV_PER_TASK_MONITORS]; #endif +#ifdef CONFIG_IPC_CLASSES + /* + * A hardware-defined classification of task that reflects but is + * not identical to the number of instructions per cycle. + */ + unsigned short 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 e76dc579cfa2..731a4b652030 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -867,6 +867,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 #