Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp3163355rwl; Mon, 27 Mar 2023 10:03:35 -0700 (PDT) X-Google-Smtp-Source: AK7set/5fIvs5mAeCvwxJctUnRLdiUnQWaVYjXO6/IlatKoZD2G1irxdFoggia2HJHQSyu0F38Hx X-Received: by 2002:a05:6a20:bf25:b0:d9:a38d:3ec7 with SMTP id gc37-20020a056a20bf2500b000d9a38d3ec7mr9116784pzb.29.1679936615111; Mon, 27 Mar 2023 10:03:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679936615; cv=none; d=google.com; s=arc-20160816; b=pq1bgpv03KkTlYvwdn2Ud13UzPJtbAofSYwRBpqJujyVOaMQ45y1iIsKrY+ROzt4lX H0MErmQ/6o8acdZq2jUUAQK4SfufLjkm911wZOloVQeMnCYxQ0UDRzLaIa7bAZpcwcnh BiAhXVRuc8paScEJfrX1ZduvGZAQkV8AzbHjMrRezQdaPvBtQnVwv1akfQ5/UXBdN2mV hbclyXcaP3y+ogmSnq9FdiaACYCS2qOIe4FSDF2Q8Cyg/HcfMBc0jIeJbBQ9c6nFGhcw qCwP9lfdhpZ3xAwOGqzqKEbCzSClOxXewDGnPibqrB12dmhFXdjh+nyGVdr1bMckK2+o pQJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=3euDVTXEogDJKed1jsCn+iMVxcZnV3bjxKw8cRtTNj4=; b=mjM0rGXdW4SMJLFhOrfVokkiiX7raDLx4pXboqXltDC/UctnuDr66wprNRh1LJ/QNz /sehVG7v7Cd0tRyRO9nG6TIONOsRhmtX2UpcW8PjkLe1WPt0nRTuKJ1WlIHwmpRSWRQu 26tB7A9U+TcDFK8gXklnFRbHQOx/BM+Nfep2IwqVk3s5af0fqahma+N/+GYsH8TwPTWT r77RvByjeNpzBTa+bxYHHWoatoknakzNF6M42BwqKmBFZ6dBaQeFF3Sk8AzpDEm22CzY 6XmM0dmt/IT+tLqY26UDV55kLErEdgqDgIwROPhx3nCGBeRkTJiKiye4WX+k21PiBH7f lmfg== ARC-Authentication-Results: i=1; mx.google.com; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e23-20020a63db17000000b00502b278306fsi26667477pgg.568.2023.03.27.10.03.22; Mon, 27 Mar 2023 10:03:35 -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; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232479AbjC0QyY convert rfc822-to-8bit (ORCPT + 99 others); Mon, 27 Mar 2023 12:54:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232712AbjC0QyJ (ORCPT ); Mon, 27 Mar 2023 12:54:09 -0400 Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8694E40CE; Mon, 27 Mar 2023 09:53:53 -0700 (PDT) Received: by mail-ed1-f45.google.com with SMTP id w9so38960519edc.3; Mon, 27 Mar 2023 09:53:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679936032; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uN+Iaybb1iiVqV2uil6/2jZC7AiW3B44s8UTj7v5RWo=; b=nNHlSN6bJ2IoNiK8RfuQD7oAT9WH9VEMm+F5Ly3zoYW/IgSsdrfb3X9Etc8U80M3LZ Gx56MHxM//z7oUBGhOY6Azbcq4SHSBwrCYok6Rio00JCJNb3ggHm/NEOByqaICYKgRGY /qw63QU3AJ2KkopofgXfp8gx2TatILeXeV520h0izqd7/CX0Y+1Sa9fX9KWJmC+16NBZ m0O/Lpxymlhvsw7FZJyTJE/M2DKrd/9qYyw3/dCpY6Y5ODtz5AJSKPrI4LhbWoT4fqhX dfBadT0BQVc0cM6Lr3gcVQjNeQXujZn68g8tyHj1VsjtpWXz50MdhC9/5fWrkDuUhoAQ Dtig== X-Gm-Message-State: AAQBX9fFRFKpfOhqNXgXTefM/Dm+FUR3cOuAhVD7CBYHomrrlIAXQ0yU OeBAnL03fikf59TrsGG0UBhXKKtoj4iLGKTt5mQ= X-Received: by 2002:a50:d6d6:0:b0:4fb:c8e3:1adb with SMTP id l22-20020a50d6d6000000b004fbc8e31adbmr5998695edj.3.1679936031994; Mon, 27 Mar 2023 09:53:51 -0700 (PDT) MIME-Version: 1.0 References: <20230207051105.11575-1-ricardo.neri-calderon@linux.intel.com> <20230207051105.11575-18-ricardo.neri-calderon@linux.intel.com> In-Reply-To: <20230207051105.11575-18-ricardo.neri-calderon@linux.intel.com> From: "Rafael J. Wysocki" Date: Mon, 27 Mar 2023 18:53:40 +0200 Message-ID: Subject: Re: [PATCH v3 17/24] thermal: intel: hfi: Enable the Intel Thread Director To: Ricardo Neri Cc: "Peter Zijlstra (Intel)" , Juri Lelli , Vincent Guittot , 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, "Tim C . Chen" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=0.5 required=5.0 tests=FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no 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 On Tue, Feb 7, 2023 at 6:02 AM Ricardo Neri wrote: > > Enable Intel Thread Director from the CPU hotplug callback: globally from > CPU0 and then enable the thread-classification hardware in each logical > processor individually. > > Also, initialize the number of classes supported. > > Let the scheduler know that it can start using IPC classes. > > 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 For the changes in intel_hfi.c Acked-by: Rafael J. Wysocki > --- > Changes since v2: > * Use the new sched_enable_ipc_classes() interface to enable the use of > IPC classes in the scheduler. > > Changes since v1: > * None > --- > arch/x86/include/asm/msr-index.h | 2 ++ > drivers/thermal/intel/intel_hfi.c | 40 +++++++++++++++++++++++++++++-- > 2 files changed, 40 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h > index ad35355ee43e..0ea25cc9c621 100644 > --- a/arch/x86/include/asm/msr-index.h > +++ b/arch/x86/include/asm/msr-index.h > @@ -1106,6 +1106,8 @@ > /* Hardware Feedback Interface */ > #define MSR_IA32_HW_FEEDBACK_PTR 0x17d0 > #define MSR_IA32_HW_FEEDBACK_CONFIG 0x17d1 > +#define MSR_IA32_HW_FEEDBACK_THREAD_CONFIG 0x17d4 > +#define MSR_IA32_HW_FEEDBACK_CHAR 0x17d2 > > /* x2APIC locked status */ > #define MSR_IA32_XAPIC_DISABLE_STATUS 0xBD > diff --git a/drivers/thermal/intel/intel_hfi.c b/drivers/thermal/intel/intel_hfi.c > index 7ea6acce7107..35d947f47550 100644 > --- a/drivers/thermal/intel/intel_hfi.c > +++ b/drivers/thermal/intel/intel_hfi.c > @@ -48,6 +48,8 @@ > /* Hardware Feedback Interface MSR configuration bits */ > #define HW_FEEDBACK_PTR_VALID_BIT BIT(0) > #define HW_FEEDBACK_CONFIG_HFI_ENABLE_BIT BIT(0) > +#define HW_FEEDBACK_CONFIG_ITD_ENABLE_BIT BIT(1) > +#define HW_FEEDBACK_THREAD_CONFIG_ENABLE_BIT BIT(0) > > /* CPUID detection and enumeration definitions for HFI */ > > @@ -72,6 +74,15 @@ union cpuid6_edx { > u32 full; > }; > > +union cpuid6_ecx { > + struct { > + u32 dont_care0:8; > + u32 nr_classes:8; > + u32 dont_care1:16; > + } split; > + u32 full; > +}; > + > #ifdef CONFIG_IPC_CLASSES > union hfi_thread_feedback_char_msr { > struct { > @@ -506,6 +517,11 @@ void intel_hfi_online(unsigned int cpu) > > init_hfi_cpu_index(info); > > + if (cpu_feature_enabled(X86_FEATURE_ITD)) { > + msr_val = HW_FEEDBACK_THREAD_CONFIG_ENABLE_BIT; > + wrmsrl(MSR_IA32_HW_FEEDBACK_THREAD_CONFIG, msr_val); > + } > + > /* > * Now check if the HFI instance of the package/die of @cpu has been > * initialized (by checking its header). In such case, all we have to > @@ -561,8 +577,22 @@ void intel_hfi_online(unsigned int cpu) > */ > rdmsrl(MSR_IA32_HW_FEEDBACK_CONFIG, msr_val); > msr_val |= HW_FEEDBACK_CONFIG_HFI_ENABLE_BIT; > + > + if (cpu_feature_enabled(X86_FEATURE_ITD)) > + msr_val |= HW_FEEDBACK_CONFIG_ITD_ENABLE_BIT; > + > wrmsrl(MSR_IA32_HW_FEEDBACK_CONFIG, msr_val); > > + /* > + * We have all we need to support IPC classes. Task classification is > + * now working. > + * > + * All class scores are zero until after the first HFI update. That is > + * OK. The scheduler queries these scores at every load balance. > + */ > + if (cpu_feature_enabled(X86_FEATURE_ITD)) > + sched_enable_ipc_classes(); > + > unlock: > mutex_unlock(&hfi_instance_lock); > return; > @@ -640,8 +670,14 @@ static __init int hfi_parse_features(void) > */ > hfi_features.class_stride = nr_capabilities; > > - /* For now, use only one class of the HFI table */ > - hfi_features.nr_classes = 1; > + if (cpu_feature_enabled(X86_FEATURE_ITD)) { > + union cpuid6_ecx ecx; > + > + ecx.full = cpuid_ecx(CPUID_HFI_LEAF); > + hfi_features.nr_classes = ecx.split.nr_classes; > + } else { > + hfi_features.nr_classes = 1; > + } > > /* > * The header contains change indications for each supported feature. > -- > 2.25.1 >