Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp1330766lqd; Thu, 25 Apr 2024 12:06:41 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWZ1zR3yJdOgzAtZFaCVGK2btRfJyaPRE5qS9zWwvRfkTLcplG0g1KDAM79IeELySbhHbJERhprZeoU9gWqDvryFo5/Dxz6nbgeJ+7jLw== X-Google-Smtp-Source: AGHT+IH7r9aduegsMu/kIg6VUPCMMPkkrGSCzjEFrmPZ7d3WHOsFIq9G/e3DM5oPeDqXeuI3Dt9b X-Received: by 2002:a19:ae03:0:b0:51b:539f:d1c2 with SMTP id f3-20020a19ae03000000b0051b539fd1c2mr203471lfc.33.1714072001134; Thu, 25 Apr 2024 12:06:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714072001; cv=pass; d=google.com; s=arc-20160816; b=sANStIzNKghkN3cX8zX8GQG/2qkwWZkwBZwfTUXiqPDBgZLW+8Qbegskin7GYF4vH6 Le9iJM4X8xhnM3F3Fd+/PvJrZcZUrc/DDEubnbeGM0mnY9L/ilHKWdn/9mYmq2DRd7G8 F65qWtOKyrtjj6MXsfDqdWGajXvpMP5XNKqQd0Xvc3Mu6sXz4ylJ4VcYebzBWvG/4NKG m+oBAyD+QjUIRr82byHJFRfLO0WV/5EgpLzc3m2pqXaXigkt9uvGO/E1xtZdo+poTKD8 E9gx2WPPZ80GR0Sl46FKMfqAliWWdKFWc5GKlWz4ccB4W9Oy/Ez2peB6aMEkwjcYa/5W lGJg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=u8eFXYIh7icLrEf4G/Pdl3r9ItwmUjCqejPDH4xfSjs=; fh=GZRYfEpFGmb5gDdEaR5uGygbJ3pdWhF82GprXoJnKHU=; b=IbGhm3svLdS9lGdT7+2VdKH1G+skdc2f0J4t21NTpB+dtPxYfC86LXNLWV9WjawX3Q kl64FqZvo7UaH90hi4Mk2VEHVlhhbauBTqGAKlUcX8EWJjbYZ5tqvsxzOBEjAFbIyVsX 8ERUKyzPozt18XKLYoiuH4L11LKLaeLIs22SKjFa6aqqxkd+hb+jCxIyeviCI+5ktMki 6T0jRkV99V7s3u/uQrH1jLVyBN3NsoWYsJzrhoFoKjN9WYnxoQmKqaGeOfP5hgA9dgul qDfsI6BU85c4c7UA7HouGtdR4Pmnpbh+oqKc4i+WSRYs2eatm6wEIRJncTA329gphc1Y gpBg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@rjwysocki.net header.s=dkim header.b=GPLdWEZD; arc=pass (i=1 spf=pass spfdomain=rjwysocki.net dkim=pass dkdomain=rjwysocki.net); spf=pass (google.com: domain of linux-kernel+bounces-159056-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159056-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id w7-20020a50d787000000b005705e81c465si10142651edi.500.2024.04.25.12.06.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 12:06:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-159056-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@rjwysocki.net header.s=dkim header.b=GPLdWEZD; arc=pass (i=1 spf=pass spfdomain=rjwysocki.net dkim=pass dkdomain=rjwysocki.net); spf=pass (google.com: domain of linux-kernel+bounces-159056-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159056-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id AE1E01F21B61 for ; Thu, 25 Apr 2024 19:06:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8BE2715250A; Thu, 25 Apr 2024 19:06:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rjwysocki.net header.i=@rjwysocki.net header.b="GPLdWEZD" Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2C66939FCF; Thu, 25 Apr 2024 19:06:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=79.96.170.134 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714071984; cv=none; b=qLhwjAxMxKurpOhoQgDFUfs664PyEXYXroVnuGTCMxDhFA8lCYQYf8ZuW41CDOjquWp57vz+5LmrT56GWBGxTl6/1jZj0W8I9U6eeDkfUnIaJHpzpzTJeq/tptL3aYVz2AZ8PTSZ7yQXDsXwJirgjH8l37BTGUo8RO+3Vnqubm4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714071984; c=relaxed/simple; bh=rXPHYPL6HdSo2STxUL4eNTS6iDEG81Dn+FvYaRVVUkU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FZcfy/2buMBvaka9C75AaGm6kDmD778ihSmUJq+l1iThTjMYqqvC1BbJD7Ci73wdm4/crvWk/9ORNqcCuS2f67x+s1cl1c74OFPPLx33AISCZ673EwgSDdfMCs7N87VOyvI6YUoXi1/H4vx9PQs0Wtxe0qvWRAi37r1oTUn89fU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rjwysocki.net; spf=pass smtp.mailfrom=rjwysocki.net; dkim=pass (2048-bit key) header.d=rjwysocki.net header.i=@rjwysocki.net header.b=GPLdWEZD; arc=none smtp.client-ip=79.96.170.134 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rjwysocki.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rjwysocki.net Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 6.0.0) id bee14970c5eba1a1; Thu, 25 Apr 2024 21:06:19 +0200 Received: from kreacher.localnet (unknown [195.136.19.94]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by cloudserver094114.home.pl (Postfix) with ESMTPSA id 27B8C66DF24; Thu, 25 Apr 2024 21:06:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rjwysocki.net; s=dkim; t=1714071979; bh=rXPHYPL6HdSo2STxUL4eNTS6iDEG81Dn+FvYaRVVUkU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=GPLdWEZDTx3IiX3Dr4V+Mt/UsJbSxEJRZ30NvCWvszJRQX79COoTLoPqhQcPh7a9O 6Lybs9ENcJDl1bbwnuUY9lX10BRBMgO/3tqq0HA3rz1X+Qu/98+KavrKv1aQDJXeE1 y487c8suXY4HQfVMyCfsrgcRWBcS8lOn89SCef1KZ1uGMhdHyhbhjGtHDn4JG0B2V6 HXUbparQ1QSOJBjtv/v4oDzM9qSIF1wAykGMtvoVO4QWHzJ5P/7rVgCtZmRuq5i3GB C5yz6QbawqH8GjmRksMKFa9HowN4Td+mn+X9JgYd2MhAg0Gqjb1V6ogXWHWmo5Q5P6 obLEv90+1LGzQ== From: "Rafael J. Wysocki" To: x86 Maintainers Cc: LKML , Linux PM , Thomas Gleixner , Peter Zijlstra , Srinivas Pandruvada , "Rafael J. Wysocki" , Dietmar Eggemann , Ricardo Neri , Tim Chen Subject: [RFC][PATCH v1 2/3] x86/sched: Introduce arch_rebuild_sched_domains() Date: Thu, 25 Apr 2024 21:04:48 +0200 Message-ID: <3227587.5fSG56mABF@kreacher> In-Reply-To: <7663799.EvYhyI6sBW@kreacher> References: <7663799.EvYhyI6sBW@kreacher> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" X-CLIENT-IP: 195.136.19.94 X-CLIENT-HOSTNAME: 195.136.19.94 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvledrudeljedgudefgecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfjqffogffrnfdpggftiffpkfenuceurghilhhouhhtmecuudehtdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkjghfggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpedvffeuiedtgfdvtddugeeujedtffetteegfeekffdvfedttddtuefhgeefvdejhfenucfkphepudelhedrudefiedrudelrdelgeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpeduleehrddufeeirdduledrleegpdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhnsggprhgtphhtthhopedutddprhgtphhtthhopeigkeeisehkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhpmhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehtghhlgieslhhinhhuthhrohhnihigrdguvgdprhgtphhtthhopehpvghtvghriiesihhnfhhrrggu vggrugdrohhrghdprhgtphhtthhopehsrhhinhhivhgrshdrphgrnhgurhhuvhgruggrsehlihhnuhigrdhinhhtvghlrdgtohhm X-DCC--Metrics: v370.home.net.pl 1024; Body=10 Fuz1=10 Fuz2=10 From: Rafael J. Wysocki Add arch_rebuild_sched_domains() for rebuilding scheduling domains and updating topology on x86 and make the ITMT code use it. First of all, this reduces code duplication somewhat and eliminates a need to use an extern variable, but it will also lay the ground for future work related to CPU capacity scaling. Signed-off-by: Rafael J. Wysocki --- arch/x86/include/asm/topology.h | 6 ++++-- arch/x86/kernel/itmt.c | 12 ++++-------- arch/x86/kernel/smpboot.c | 10 +++++++++- 3 files changed, 17 insertions(+), 11 deletions(-) Index: linux-pm/arch/x86/include/asm/topology.h =================================================================== --- linux-pm.orig/arch/x86/include/asm/topology.h +++ linux-pm/arch/x86/include/asm/topology.h @@ -235,8 +235,6 @@ struct pci_bus; int x86_pci_root_bus_node(int bus); void x86_pci_root_bus_resources(int bus, struct list_head *resources); -extern bool x86_topology_update; - #ifdef CONFIG_SCHED_MC_PRIO #include @@ -284,9 +282,13 @@ static inline long arch_scale_freq_capac extern void arch_set_max_freq_ratio(bool turbo_disabled); extern void freq_invariance_set_perf_ratio(u64 ratio, bool turbo_disabled); + +void arch_rebuild_sched_domains(void); #else static inline void arch_set_max_freq_ratio(bool turbo_disabled) { } static inline void freq_invariance_set_perf_ratio(u64 ratio, bool turbo_disabled) { } + +static inline void arch_rebuild_sched_domains(void) { } #endif extern void arch_scale_freq_tick(void); Index: linux-pm/arch/x86/kernel/itmt.c =================================================================== --- linux-pm.orig/arch/x86/kernel/itmt.c +++ linux-pm/arch/x86/kernel/itmt.c @@ -54,10 +54,8 @@ static int sched_itmt_update_handler(str old_sysctl = sysctl_sched_itmt_enabled; ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos); - if (!ret && write && old_sysctl != sysctl_sched_itmt_enabled) { - x86_topology_update = true; - rebuild_sched_domains(); - } + if (!ret && write && old_sysctl != sysctl_sched_itmt_enabled) + arch_rebuild_sched_domains(); mutex_unlock(&itmt_update_mutex); @@ -114,8 +112,7 @@ int sched_set_itmt_support(void) sysctl_sched_itmt_enabled = 1; - x86_topology_update = true; - rebuild_sched_domains(); + arch_rebuild_sched_domains(); mutex_unlock(&itmt_update_mutex); @@ -150,8 +147,7 @@ void sched_clear_itmt_support(void) if (sysctl_sched_itmt_enabled) { /* disable sched_itmt if we are no longer ITMT capable */ sysctl_sched_itmt_enabled = 0; - x86_topology_update = true; - rebuild_sched_domains(); + arch_rebuild_sched_domains(); } mutex_unlock(&itmt_update_mutex); Index: linux-pm/arch/x86/kernel/smpboot.c =================================================================== --- linux-pm.orig/arch/x86/kernel/smpboot.c +++ linux-pm/arch/x86/kernel/smpboot.c @@ -39,6 +39,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include #include #include #include @@ -125,7 +126,7 @@ static DEFINE_PER_CPU_ALIGNED(struct mwa int __read_mostly __max_smt_threads = 1; /* Flag to indicate if a complete sched domain rebuild is required */ -bool x86_topology_update; +static bool x86_topology_update; int arch_update_cpu_topology(void) { @@ -135,6 +136,13 @@ int arch_update_cpu_topology(void) return retval; } +#ifdef CONFIG_X86_64 +void arch_rebuild_sched_domains(void) { + x86_topology_update = true; + rebuild_sched_domains(); +} +#endif + static unsigned int smpboot_warm_reset_vector_count; static inline void smpboot_setup_warm_reset_vector(unsigned long start_eip)