Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp3146321rwl; Mon, 27 Mar 2023 09:49:21 -0700 (PDT) X-Google-Smtp-Source: AKy350ZilykVe79mwCXF3J2B4srCifw5m4oLISKxk3+JSj4TF1vyfIM3Umz72827a9IihF+Vi/aA X-Received: by 2002:aa7:d54f:0:b0:502:3376:7872 with SMTP id u15-20020aa7d54f000000b0050233767872mr8613945edr.35.1679935761074; Mon, 27 Mar 2023 09:49:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679935761; cv=none; d=google.com; s=arc-20160816; b=hFdVGYUJbpjp4QmFt3lldJ0vDBAno9IelQmAcn40Vm8QCpBpZ+KbaaipexDQ/Zl9AD EpwU/UGKrgHj8r7IrhiBU5A40SZzxcngqEwsuWLJwWienQdTgT0o/HOdu/33yC2Rldyv AaqF86leOqIQ198HI+rISGFwXUz3W31s1M6Zys2rys7ENOysq7RhmWCsy1XPRaIRAKnt vNDFvcYb24Jg/j3pp7uPxrjBtrIXq0YvN9+QaDqAjwnDi/JXR/NSQ8rAWpScL0QC9nIg DFZy5xnc1E2FNic1SYZKNo3tS02W3W9mzIWEqF9Z0iG7BtRhCCGI1FM+HphQv1koZmnf mZpw== 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=cnj3LwMQZ4DFicILCQkIGnFgkH8Wr70JRp5UiM+txS0=; b=xadsF1z1E3Fm3XetUqeZu3g7luhS4VU71mXMWYgpax7jsAmCKXVLBqVlPWBfB6kVKT iF/QR87w5UvP3WucziE5eOPlYZdpvCRYSe9ZHq//PGQaGdMNguTsC3GqvCijj+K8/ApB T99UAPPIFVbHzPxRF52icpQ0iD/SLpHLcsUEusOhIBBRiAaQWrOl0PGu4G8BlI8j0fn7 Xhw1JkvfiUvlyN+g+VjouUBeviDI/U1IXo6xFId7Vo99RxynihBIjLxBJCq9nw1BrkcT JpnhNmWhc04TVV68gLaLLbvIzdDjVOIE8BFxwTkKW2lQJ8a0DKfTGM5JuMlZwvK0sAUy sOeg== 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 c20-20020a056402121400b0050225335e7bsi7590876edw.583.2023.03.27.09.48.56; Mon, 27 Mar 2023 09:49:21 -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 S230107AbjC0QnC convert rfc822-to-8bit (ORCPT + 99 others); Mon, 27 Mar 2023 12:43:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232617AbjC0Qmp (ORCPT ); Mon, 27 Mar 2023 12:42:45 -0400 Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D50DE269A; Mon, 27 Mar 2023 09:42:40 -0700 (PDT) Received: by mail-ed1-f53.google.com with SMTP id y4so38855166edo.2; Mon, 27 Mar 2023 09:42:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679935359; 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=tUPHgvLfynF1cW2avQZPE6tiBmDlV9HQFs1/wQ1dwVM=; b=eoPMcnkC9rM06FqUv0sPMik9DZMBBtJWMDD0M1esxNmyTefZVqoxAt9uam7QYF9GjC H09dU2AMlCR+n1HYObC8igf8oQgIF7lf8Byxgz6oBKnG7+1yS7+Ydasog/mr6kitcvNp UYsE84Xb+ZueMC7OEWvyg4kMxLTw+4F+s6Mh2ljhgf4oQQjXlHmfYszCVZCAcwhVcw47 Pa+LSIGGQksXpJQQwVLbk3JQwvbT5AEap42xNO9uGEU5gXpf3DuV8bRjstQXJHmiN54g pc+EGqo+vQ05R3DC4l1eJFyFO/iwTgjFd+ZQz5h2JHw8Je63KrWdu6JWPJ1D9B0apeln qzyQ== X-Gm-Message-State: AAQBX9eVkACzBkA4gFqcpHzKA4qFGWtTKTVj3MCxPxdfd24NpIISbr/t SWxDnun/qsTaO/tFD1WlSDyVwWugqJGsAN8i8xM= X-Received: by 2002:a50:d54f:0:b0:502:4f7:d287 with SMTP id f15-20020a50d54f000000b0050204f7d287mr6090063edj.3.1679935359304; Mon, 27 Mar 2023 09:42:39 -0700 (PDT) MIME-Version: 1.0 References: <20230207051105.11575-1-ricardo.neri-calderon@linux.intel.com> <20230207051105.11575-15-ricardo.neri-calderon@linux.intel.com> In-Reply-To: <20230207051105.11575-15-ricardo.neri-calderon@linux.intel.com> From: "Rafael J. Wysocki" Date: Mon, 27 Mar 2023 18:42:28 +0200 Message-ID: Subject: Re: [PATCH v3 14/24] thermal: intel: hfi: Update the IPC class of the current task 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: > > Use Intel Thread Director classification to update the IPC class of a > task. Implement the arch_update_ipcc() interface of the scheduler. > > 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: > * Removed the implementation of arch_has_ipc_classes(). > > Changes since v1: > * Adjusted the result the classification of Intel Thread Director to start > at class 1. Class 0 for the scheduler means that the task is > unclassified. > * Redefined union hfi_thread_feedback_char_msr to ensure all > bit-fields are packed. (PeterZ) > * Removed CONFIG_INTEL_THREAD_DIRECTOR. (PeterZ) > * Shortened the names of the functions that implement IPC classes. > * Removed argument smt_siblings_idle from intel_hfi_update_ipcc(). > (PeterZ) > --- > arch/x86/include/asm/topology.h | 6 ++++++ > drivers/thermal/intel/intel_hfi.c | 32 +++++++++++++++++++++++++++++++ > 2 files changed, 38 insertions(+) > > diff --git a/arch/x86/include/asm/topology.h b/arch/x86/include/asm/topology.h > index 458c891a8273..ffcdac3f398f 100644 > --- a/arch/x86/include/asm/topology.h > +++ b/arch/x86/include/asm/topology.h > @@ -227,4 +227,10 @@ void init_freq_invariance_cppc(void); > #define arch_init_invariance_cppc init_freq_invariance_cppc > #endif > > +#if defined(CONFIG_IPC_CLASSES) && defined(CONFIG_INTEL_HFI_THERMAL) > +void intel_hfi_update_ipcc(struct task_struct *curr); > + > +#define arch_update_ipcc intel_hfi_update_ipcc > +#endif /* defined(CONFIG_IPC_CLASSES) && defined(CONFIG_INTEL_HFI_THERMAL) */ > + > #endif /* _ASM_X86_TOPOLOGY_H */ > diff --git a/drivers/thermal/intel/intel_hfi.c b/drivers/thermal/intel/intel_hfi.c > index b06021828892..530dcf57e06e 100644 > --- a/drivers/thermal/intel/intel_hfi.c > +++ b/drivers/thermal/intel/intel_hfi.c > @@ -72,6 +72,17 @@ union cpuid6_edx { > u32 full; > }; > > +#ifdef CONFIG_IPC_CLASSES > +union hfi_thread_feedback_char_msr { > + struct { > + u64 classid : 8; > + u64 __reserved : 55; > + u64 valid : 1; > + } split; > + u64 full; > +}; > +#endif > + > /** > * struct hfi_cpu_data - HFI capabilities per CPU > * @perf_cap: Performance capability > @@ -174,6 +185,27 @@ static struct workqueue_struct *hfi_updates_wq; > #ifdef CONFIG_IPC_CLASSES > static int __percpu *hfi_ipcc_scores; > > +void intel_hfi_update_ipcc(struct task_struct *curr) > +{ > + union hfi_thread_feedback_char_msr msr; > + > + /* We should not be here if ITD is not supported. */ > + if (!cpu_feature_enabled(X86_FEATURE_ITD)) { > + pr_warn_once("task classification requested but not supported!"); > + return; > + } > + > + rdmsrl(MSR_IA32_HW_FEEDBACK_CHAR, msr.full); > + if (!msr.split.valid) > + return; > + > + /* > + * 0 is a valid classification for Intel Thread Director. A scheduler > + * IPCC class of 0 means that the task is unclassified. Adjust. > + */ > + curr->ipcc = msr.split.classid + 1; > +} Wouldn't it be better to return the adjusted value from this function and let the caller store it where appropriate? It doesn't look like it is necessary to pass the task_struct pointer to it. > + > static int alloc_hfi_ipcc_scores(void) > { > if (!cpu_feature_enabled(X86_FEATURE_ITD)) > --