From patchwork Thu Jan 25 18:14:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Andryuk X-Patchwork-Id: 13531488 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 B9774C47258 for ; Thu, 25 Jan 2024 18:15:49 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.671698.1045181 (Exim 4.92) (envelope-from ) id 1rT4GA-0004X5-31; Thu, 25 Jan 2024 18:15:30 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 671698.1045181; Thu, 25 Jan 2024 18:15:30 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rT4G9-0004Wy-V9; Thu, 25 Jan 2024 18:15:29 +0000 Received: by outflank-mailman (input) for mailman id 671698; Thu, 25 Jan 2024 18:15:29 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rT4G9-0004GD-8a for xen-devel@lists.xenproject.org; Thu, 25 Jan 2024 18:15:29 +0000 Received: from mail-qk1-x733.google.com (mail-qk1-x733.google.com [2607:f8b0:4864:20::733]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id b7bd1c09-bbad-11ee-8a42-1f161083a0e0; Thu, 25 Jan 2024 19:15:28 +0100 (CET) Received: by mail-qk1-x733.google.com with SMTP id af79cd13be357-78313f4d149so610365385a.1 for ; Thu, 25 Jan 2024 10:15:28 -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 wg8-20020a05620a568800b00781b8f4c89asm5265899qkn.43.2024.01.25.10.15.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 10:15:26 -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: b7bd1c09-bbad-11ee-8a42-1f161083a0e0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706206527; x=1706811327; 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=YyEbMZdJfecnQ9Hzg5AB7rtSEVHtymjTaGyNCauyTks=; b=lXkC4e+HiRB2trX7vR+kWAhNGoBR2laQbKVfsVYOGq7wgZka7tOvGETFFYQKgUaEmv DqJ3969bItTnbt4aO0hbMtotTDAJZMlL4dDiPUF9lyb28I/7nu9AEiRdTAdYRtp7L1Yk 7FrqbJ5smL9jCiYLxihvE2pgBoY/V8pHNKF1+t0MOx2ox49hFhBpZKmHx4/4jbygfBAo aT6vnObae4bIrpeiB6OLh56ee7644OQ4qGqxItOaZSN7ejdViD0UpvSAOHosH0/RTrND eB4BQ0YE4+37lonSUqRQq3prqwEKMVdrZP544PmytY/UMJ/pA+HKJa38vZTHnMnA9xEi 0u7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706206527; x=1706811327; 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=YyEbMZdJfecnQ9Hzg5AB7rtSEVHtymjTaGyNCauyTks=; b=rQM57gvaELl73F5Q8Twy7bzCgKCRElF5uWYW4r+DTn2W1z5PZa7454KoBvNDTkzgD9 ii8GmhT1Mg1y9+iKn33FrcH6f8jPrgRcUxYtytJ4HyP5+JOcb1j/sk7mLPpio9JAaFeB YsvvEjvAKWnC0zLmLIY8R5RsrQ7n30XN5mvClc87iJ9F29XXLS2UGLA/tFtTiYMsIuQS d0RQ1QCq9/2GBjSNTPH/52gQh+mNCRp7vKeGhFKHieMZOX2ygrvovy7B+loSLITx/d4G s6hcFXN6324eJ3j4CckDIzXnaBNhx066DHxMgXe07F7Ws3YJ+OBvcd2J5r7V48MHSTUz yIOQ== X-Gm-Message-State: AOJu0Yzyw6Q1QN5fdp82tkumKLqIxG4HHTtKVbGKZsuby+A0sriTK34V R0/WHgOML8kZeG2dx8an34l4OuXgGIlkL4jSh7xHYtlMPIG0lxE+FPtFUFxs X-Google-Smtp-Source: AGHT+IG6CrsocHLAqBMNBRYNbbTEsI51rayRyRzMxZzvh6CjXbmVn3O61ug+Dsl6MG48ddQCoucSbg== X-Received: by 2002:a05:620a:22f7:b0:783:3b4a:b55b with SMTP id p23-20020a05620a22f700b007833b4ab55bmr1288900qki.53.1706206526712; Thu, 25 Jan 2024 10:15:26 -0800 (PST) From: Jason Andryuk To: xen-devel@lists.xenproject.org Cc: Jason Andryuk , Jan Beulich Subject: [PATCH v3 1/2] pmstat: Limit hypercalls under HWP Date: Thu, 25 Jan 2024 13:14:53 -0500 Message-ID: <20240125181454.50534-2-jandryuk@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240125181454.50534-1-jandryuk@gmail.com> References: <20240125181454.50534-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 v3: Add Jan's R-b --- 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 Thu Jan 25 18:14:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Andryuk X-Patchwork-Id: 13531487 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 3ABF9C47422 for ; Thu, 25 Jan 2024 18:15:47 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.671699.1045191 (Exim 4.92) (envelope-from ) id 1rT4GD-0004nm-9m; Thu, 25 Jan 2024 18:15:33 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 671699.1045191; Thu, 25 Jan 2024 18:15:33 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rT4GD-0004nZ-6W; Thu, 25 Jan 2024 18:15:33 +0000 Received: by outflank-mailman (input) for mailman id 671699; Thu, 25 Jan 2024 18:15:32 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rT4GC-0004GD-F9 for xen-devel@lists.xenproject.org; Thu, 25 Jan 2024 18:15:32 +0000 Received: from mail-qk1-x72a.google.com (mail-qk1-x72a.google.com [2607:f8b0:4864:20::72a]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id b990f26d-bbad-11ee-8a42-1f161083a0e0; Thu, 25 Jan 2024 19:15:31 +0100 (CET) Received: by mail-qk1-x72a.google.com with SMTP id af79cd13be357-783b0813e48so70209485a.1 for ; Thu, 25 Jan 2024 10:15:31 -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 wg8-20020a05620a568800b00781b8f4c89asm5265899qkn.43.2024.01.25.10.15.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 10:15:29 -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: b990f26d-bbad-11ee-8a42-1f161083a0e0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706206530; x=1706811330; 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=8Cyl/tzhVyURcOp/nlofd5b74JJYkMUzcH4H5kjvyLE=; b=LhjLdVhRzPbpca1iKmVk0uBO+lU67vwnUZy9sOlHed0DMtNzFFm9ETK9Oxmbo4LCO7 k5rA9NNq0w/jouCiIxInQ2z/pvwba3lF1dHiv1tW+wNQH+xKwERS3zhdQHopVzhUbCHR T5IlSbQFmYVP1rPd/02FFQyF+w2CYir9ywEjGzQEOTGvySx1WJ2yYAw23spvTfm3RoEu 3qy8nc6eNQurDryFHSCwpcBgQYNumps1rcLbUDdFj2UgkfDaXI4v1e+aybf/8Q876E++ 0JclIGdRYSpyVZmH6RIEqojU9Ifll3HI6+v8Ho/iiXCyrQ+qClMWOS5TF9yOkSG+yru4 X3WA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706206530; x=1706811330; 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=8Cyl/tzhVyURcOp/nlofd5b74JJYkMUzcH4H5kjvyLE=; b=lIOHP8q0x99XeIJRCbaoDr5ES0fNvAkxm5zpGnp3bx9y7VbzLZDPtyjSD2KjH/Lb+8 KOu1bn6N/E3QTnUgPz1xENEWlkXrc6gZ2Uq2Ub7EdeplYW9enA6AgJmDnne21n7gV/t5 t2kJgxYbEGrFxhOK3tbRzB3yxYqd0xAoxiZNuSAcc3yGhiwISiyKwMI6Yvj2EAzufJV0 Ee4ImKreQ62rxCBNgR1AySud6+rz7Flgf0ch4SMQlumbGVZ9Y8MPEZ6Lcv3Pq6bLshf6 rzlxz7VU3IAPhQIoJJOnDqZNYEsoSNDqYGS3SisVxGEMU/+ZUDWkj+6p/xgXvJvqZJZi WK0Q== X-Gm-Message-State: AOJu0YyoBD0nIa8sF4JnrfW6AgIKAyJrzNy+QMavOIiun2Jhk/T1o9Qf APOblpTi7FPiq2w+wWLB4/kKUWhIIDsUeIwrlUtq4tq6lLx8VXut6fPcwrga X-Google-Smtp-Source: AGHT+IHIGKvvx5bRtA8gFtzC3UIz69okIYgMu7Dy5xhL55yABZzc84JQCJWdijmUREAcIQtOM3hCoQ== X-Received: by 2002:a05:620a:2116:b0:783:8b88:e4df with SMTP id l22-20020a05620a211600b007838b88e4dfmr306321qkl.14.1706206529887; Thu, 25 Jan 2024 10:15:29 -0800 (PST) From: Jason Andryuk To: xen-devel@lists.xenproject.org Cc: Jason Andryuk , Wei Liu , Anthony PERARD Subject: [PATCH v3 2/2] xenpm: Print message for disabled commands Date: Thu, 25 Jan 2024 13:14:54 -0500 Message-ID: <20240125181454.50534-3-jandryuk@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240125181454.50534-1-jandryuk@gmail.com> References: <20240125181454.50534-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 mirrors 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 Acked-by: Jan Beulich --- v2: New v3: Quote subcommands in error message Fix style errors s/mirros/mirrors/ in commit message --- tools/misc/xenpm.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/tools/misc/xenpm.c b/tools/misc/xenpm.c index d982482a3f..336d246346 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); @@ -383,8 +391,12 @@ 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 ) + { + 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 +444,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 +485,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++ )