From patchwork Wed Jan 24 20:59:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Andryuk X-Patchwork-Id: 13529676 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0892FC46CD2 for ; Wed, 24 Jan 2024 21:00:00 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.671238.1044499 (Exim 4.92) (envelope-from ) id 1rSkLf-0007FG-8v; Wed, 24 Jan 2024 20:59:51 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 671238.1044499; Wed, 24 Jan 2024 20:59:51 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rSkLf-0007F9-5X; Wed, 24 Jan 2024 20:59:51 +0000 Received: by outflank-mailman (input) for mailman id 671238; Wed, 24 Jan 2024 20:59:50 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rSkLe-0006yg-KC for xen-devel@lists.xenproject.org; Wed, 24 Jan 2024 20:59:50 +0000 Received: from mail-il1-x135.google.com (mail-il1-x135.google.com [2607:f8b0:4864:20::135]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 826c774d-bafb-11ee-9b0f-b553b5be7939; Wed, 24 Jan 2024 21:59:49 +0100 (CET) Received: by mail-il1-x135.google.com with SMTP id e9e14a558f8ab-3619e804f3aso22487495ab.2 for ; Wed, 24 Jan 2024 12:59:48 -0800 (PST) Received: from pm2-ws13.praxislan02.com (207-172-141-204.s8906.c3-0.slvr-cbr1.lnh-slvr.md.cable.rcncustomer.com. [207.172.141.204]) by smtp.gmail.com with ESMTPSA id d3-20020ac80603000000b004260b65b4f7sm4643391qth.97.2024.01.24.12.59.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 12:59:45 -0800 (PST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 826c774d-bafb-11ee-9b0f-b553b5be7939 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706129987; x=1706734787; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yUrmZO37v19vw6177GV1p1vq04J3q1Ohle6m53SQw+Q=; b=E3sApGUTKeAwNnndLJa9mIUuFmiRVnRbeZGOHA41K9Xj5masF2IwYFjejAzF2LPVdV jD/Yj1ecWSAh/9iVY8vCnjwwVIBBu4x8A9PCYo42qwEDl6OPJAYKDUlhZQBb9rID70UM NofQzt9ZU/6XiuXDCO4OPHs6QbFF6M8I5P5mCD9o3pCdERxHTj7IH3p1fvJUHa9VjKtB OCmVXQivnBKUYz+0S8puLaqyy/wiZxxj46Mtrkjp2SV0W5C56zmkwKaDWTV34m9CtftD Re41uRj1dLqqJivAYLnPzGtaQryrwlhKIfySeg48VSGU6jiBwQvP45P2GWYJ1+NA/ezc T8TA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706129987; x=1706734787; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yUrmZO37v19vw6177GV1p1vq04J3q1Ohle6m53SQw+Q=; b=OHHdET7ENNTFCUJZdW2c8zJ1MNbUdI6ltmjcVNGcu29pe8rlgbIl5Y01AZ2JmFOeY3 I6uUv1HAE3ej7CpO3E+rSQIEDCkGQaz8Dp4ikE3A9PztorjWRTFtW77YJqmK3qkm/kkk z1M964gTeUqrMSnn5uep54k9eYyBwF9tJss7ryqECK+nzzNMitTpD+5I6g2xHzUTzev8 CKxJlWf4tlsx5yNahvthQxVfjvUDNylOvB7NzjErec2onVweo4+PlCBffDDiOZN/RJ/G QAQAur+QksGeCTXN3xXDDsq35VR1vFW81TaangOd0fezoJU4JrDfXi1j4mFXmsiYBKdx xT8g== X-Gm-Message-State: AOJu0YytOBfgKp83od6q0OmSCJ4JWhXvxcD1aBUz4+PKEYlPHLOY11Zi j4tFcS6pi+mSY11lZJeuUSIOCBas/M029GLkSTjaDRlWl8P7AupztFB81Qmq X-Google-Smtp-Source: AGHT+IEHzyqRfHJmmh4174x8bgg177aZWQxWxvguQ+KgBd8RXILpqaRpZRkTTLapoQS2Fec8QSnzPQ== X-Received: by 2002:a05:6e02:1210:b0:361:a0ba:ad09 with SMTP id a16-20020a056e02121000b00361a0baad09mr40784ilq.12.1706129986876; Wed, 24 Jan 2024 12:59:46 -0800 (PST) From: Jason Andryuk To: xen-devel@lists.xenproject.org Cc: Jason Andryuk , Jan Beulich Subject: [PATCH v2 1/2] pmstat: Limit hypercalls under HWP Date: Wed, 24 Jan 2024 15:59:21 -0500 Message-ID: <20240124205922.67266-2-jandryuk@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240124205922.67266-1-jandryuk@gmail.com> References: <20240124205922.67266-1-jandryuk@gmail.com> MIME-Version: 1.0 When HWP is active, the cpufreq P-state information is not updated. In that case, return -EOPNOTSUPP instead of bogus, incomplete info. Similarly, set_cpufreq_para() is not applicable when HWP is active. Many of the options already checked the governor and were inaccessible, but SCALING_MIN/MAX_FREQ was still accessible (though it would do nothing). Add an ealier HWP check to handle all cases. Signed-off-by: Jason Andryuk Reviewed-by: Jan Beulich --- v2: Use -EOPNOTSUPP in both places xen/drivers/acpi/pmstat.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/xen/drivers/acpi/pmstat.c b/xen/drivers/acpi/pmstat.c index 85097d463c..86588ddd42 100644 --- a/xen/drivers/acpi/pmstat.c +++ b/xen/drivers/acpi/pmstat.c @@ -66,6 +66,8 @@ int do_get_pm_info(struct xen_sysctl_get_pmstat *op) return -ENODEV; if ( !cpufreq_driver.init ) return -ENODEV; + if ( hwp_active() ) + return -EOPNOTSUPP; if ( !pmpt || !(pmpt->perf.init & XEN_PX_INIT) ) return -EINVAL; break; @@ -329,6 +331,9 @@ static int set_cpufreq_para(struct xen_sysctl_pm_op *op) if ( !policy || !policy->governor ) return -EINVAL; + if ( hwp_active() ) + return -EOPNOTSUPP; + switch(op->u.set_para.ctrl_type) { case SCALING_MAX_FREQ: From patchwork Wed Jan 24 20:59:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Andryuk X-Patchwork-Id: 13529677 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 69826C46CD2 for ; Wed, 24 Jan 2024 21:00:03 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.671239.1044509 (Exim 4.92) (envelope-from ) id 1rSkLj-0007Wn-GW; Wed, 24 Jan 2024 20:59:55 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 671239.1044509; Wed, 24 Jan 2024 20:59:55 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rSkLj-0007Wa-DD; Wed, 24 Jan 2024 20:59:55 +0000 Received: by outflank-mailman (input) for mailman id 671239; Wed, 24 Jan 2024 20:59:54 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rSkLi-0006yg-8Y for xen-devel@lists.xenproject.org; Wed, 24 Jan 2024 20:59:54 +0000 Received: from mail-qt1-x82f.google.com (mail-qt1-x82f.google.com [2607:f8b0:4864:20::82f]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 84a4d3a3-bafb-11ee-9b0f-b553b5be7939; Wed, 24 Jan 2024 21:59:52 +0100 (CET) Received: by mail-qt1-x82f.google.com with SMTP id d75a77b69052e-42a446cb1baso15500591cf.0 for ; Wed, 24 Jan 2024 12:59:52 -0800 (PST) Received: from pm2-ws13.praxislan02.com (207-172-141-204.s8906.c3-0.slvr-cbr1.lnh-slvr.md.cable.rcncustomer.com. [207.172.141.204]) by smtp.gmail.com with ESMTPSA id d3-20020ac80603000000b004260b65b4f7sm4643391qth.97.2024.01.24.12.59.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 12:59:50 -0800 (PST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 84a4d3a3-bafb-11ee-9b0f-b553b5be7939 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706129990; x=1706734790; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BthpWTlw2BkiPY7xlL82j899+I8S9+DzigRUVf0kQtA=; b=AXZz6knApLhe/YDur+gQV/1/s4/5WeHOkxnosC1b7Tw7jUt81u09RWMiZNp0YLIrgD EglE6JNlfPRMWdHHNpsJmYTEu3M/EEbdVTm/gmIdi2RNJVjQA0JJx3aFZFU4NRR7OOnK 8IOioxtVZfdeshf+dR4BmCL0zEjtGpcJXtaEYf2K+QdGwe/qAKI/0iMY3L6/VvrArxqN qfSXLODtRyGtoqhUpJ3wyskWu3BJHr4p/aXdykudwPjHsTf/HfOwZ/+LAyPSi9vz40hE 1e8hqQXnfBlnz0PUpqVA5X/tmrkRp2rJj710HOj4rpA12mEcOwSXDPbdEEaa2Lh6VRcw 3idw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706129990; x=1706734790; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BthpWTlw2BkiPY7xlL82j899+I8S9+DzigRUVf0kQtA=; b=JvQ+1rmyZ9JzQxcYT6qaSMFmVNjgEG0H9nd4FSXJ6l/45MYx/vkY5h1PgNgij9Jujc bQjZGDS4HewFJwW/zBIlPA4LjyiVnzgCXU8buARSVB67hRifCYvNnTPN+pIBb171gMmZ FH851tkLzUXNr0mFcf51Q3VmzmXeSbOKRkcuU6Inl8ATIfAYOF+XOAE4QmS2YbhK3cBL VoDWFRLrAdIZfYDNOf8ZETCNViD2RUqYz6TyF32Hg58heJelBdSKNY4gEoaRDS5N+zHx Ypo7VrdlsYWxofSef/9ByEaO5rpmg94x7eJCNBjB0LnRwQ/EGN3QjjOrKQvIzt4X7GB8 jP6w== X-Gm-Message-State: AOJu0Yy+DZ7ubjEfS94szcK0x2DvQAkjJZA6XdK9bBIfv1e0pL9Tkm3v 6xIIbOM0QorwllzOGen87QAVDBIVuRJdEbnWS9aiq5jCZDoqCzco2nmd4Vkw X-Google-Smtp-Source: AGHT+IEL1N+v8/fKPf+QXUL4GVjzna7A1Yy/9ub/38bNbJfUs/Q8gv0AwbvyW/uXPcE7s0Sw9GJOuQ== X-Received: by 2002:a05:622a:138e:b0:42a:5dc5:fdc8 with SMTP id o14-20020a05622a138e00b0042a5dc5fdc8mr1387749qtk.63.1706129990612; Wed, 24 Jan 2024 12:59:50 -0800 (PST) From: Jason Andryuk To: xen-devel@lists.xenproject.org Cc: Jason Andryuk , Wei Liu , Anthony PERARD Subject: [PATCH v2 2/2] xenpm: Print message for disabled commands Date: Wed, 24 Jan 2024 15:59:22 -0500 Message-ID: <20240124205922.67266-3-jandryuk@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240124205922.67266-1-jandryuk@gmail.com> References: <20240124205922.67266-1-jandryuk@gmail.com> MIME-Version: 1.0 xenpm get-cpufreq-states currently just prints no output when cpufreq is disabled or HWP is running. Have it print an appropriate message. The cpufreq disabled one mirros the cpuidle disabled one. cpufreq disabled: $ xenpm get-cpufreq-states Either Xen cpufreq is disabled or no valid information is registered! Under HWP: $ xenpm get-cpufreq-states P-State information not supported. Try get-cpufreq-average or start. Also allow xenpm to handle EOPNOTSUPP from the pmstat hypercalls. EOPNOTSUPP is returned when HWP is active in some cases and allows the differentiation from cpufreq being disabled. Signed-off-by: Jason Andryuk --- v2: New tools/misc/xenpm.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/tools/misc/xenpm.c b/tools/misc/xenpm.c index d982482a3f..79c618590b 100644 --- a/tools/misc/xenpm.c +++ b/tools/misc/xenpm.c @@ -362,7 +362,15 @@ static int show_pxstat_by_cpuid(xc_interface *xc_handle, int cpuid) ret = get_pxstat_by_cpuid(xc_handle, cpuid, &pxstatinfo); if ( ret ) + { + if ( ret == -ENODEV ) + fprintf(stderr, + "Either Xen cpufreq is disabled or no valid information is registered!\n"); + else if ( ret == -EOPNOTSUPP ) + fprintf(stderr, + "P-State information not supported. Try get-cpufreq-average or start.\n"); return ret; + } print_pxstat(cpuid, &pxstatinfo); @@ -382,9 +390,11 @@ void pxstat_func(int argc, char *argv[]) { /* show pxstates on all cpus */ int i; - for ( i = 0; i < max_cpu_nr; i++ ) - if ( show_pxstat_by_cpuid(xc_handle, i) == -ENODEV ) + for ( i = 0; i < max_cpu_nr; i++ ) { + int ret = show_pxstat_by_cpuid(xc_handle, i); + if ( ret == -ENODEV || ret == -EOPNOTSUPP ) break; + } } else show_pxstat_by_cpuid(xc_handle, cpuid); @@ -432,7 +442,7 @@ static uint64_t *sum, *sum_cx, *sum_px; static void signal_int_handler(int signo) { - int i, j, k; + int i, j, k, ret; struct timeval tv; int cx_cap = 0, px_cap = 0; xc_cputopo_t *cputopo = NULL; @@ -473,7 +483,8 @@ static void signal_int_handler(int signo) } } - if ( get_pxstat_by_cpuid(xc_handle, 0, NULL) != -ENODEV ) + ret = get_pxstat_by_cpuid(xc_handle, 0, NULL); + if ( ret != -ENODEV && ret != -EOPNOTSUPP ) { px_cap = 1; for ( i = 0; i < max_cpu_nr; i++ )