Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp1807009ybc; Wed, 13 Nov 2019 04:44:12 -0800 (PST) X-Google-Smtp-Source: APXvYqxpcUUDexVRXjOk0/36A2KhEq+2RAYp8JZd85gMdyq9PZ8klgJl4cktiFW/nzgH/w5Pjzt1 X-Received: by 2002:a17:906:80d5:: with SMTP id a21mr2524436ejx.114.1573649052010; Wed, 13 Nov 2019 04:44:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573649052; cv=none; d=google.com; s=arc-20160816; b=qzXd00W+TwrCE+ddGx2GaQo++zSlHQiZGv1J0aSyofD4u/YJxsecpRP9ObDbdKyZOq zsWVssEdq3XebnP68MXlDuPGn8djkpAMtisONJvVVdxrVTrXLKOVMGmLSHCiYxNAeqC3 pxfbNwDcntn0cUWUqoOjb161DhkpSysw3XJy6dTCFmtOu3H7WEa8P7ZmmvCwatRE/LDl pe+EK+mTLWBc8vv3Q1Yku/ZpDASn24JcZRDX8L8hw/UniCV1d+qdxi47rL4icoVFrpNn bv+qtzIlEBZB5P8aIhP9y+SXE1TR5wgCftv4JglKoNk1IavVykNWvruOzSBWIZ7cvWgv tavA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=HO4f+moC/0JACGU7qT7Qcr/pA5HaMGVTv7OISFlYoro=; b=NMTYRXBXDuRnbx583Vj4ZHrdR5CMI2QkdXM6bJpXG9ioJnQTmohtGKm1FQDM3K8Msv deG9FPjyCe3WVpgJNkg+tFxKo50S14znSnOfq558EOpZHi7BSPYvzM9YHlQQX5hzcRp/ 9eDwgDx/1AuPgQc5RoOez9Lrjt8eNEfpjk30RJYlh4U0uG4VWr68a6ZXzr2uFjnPAOaz 6rIxymGXE5pzmYKCsCbJkNC0ngYWNECDuBwt71lO4hntIFJ3CWT7GO5Cq080FZBvXPIf 7+aCvsgOeF2q6uj+DUQeH7FK1BafZTiKDkmEnmzAzj6PWvUBilx5WaIeZCNCIhjbUeuG NaSg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i24si1072523ejh.35.2019.11.13.04.43.46; Wed, 13 Nov 2019 04:44:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727126AbfKMMlU (ORCPT + 99 others); Wed, 13 Nov 2019 07:41:20 -0500 Received: from mx2.suse.de ([195.135.220.15]:39084 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726350AbfKMMlS (ORCPT ); Wed, 13 Nov 2019 07:41:18 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 0BBB4B3C0; Wed, 13 Nov 2019 12:41:16 +0000 (UTC) From: Giovanni Gherdovich To: Srinivas Pandruvada , Thomas Gleixner , Ingo Molnar , Peter Zijlstra , Borislav Petkov , Len Brown , "Rafael J . Wysocki" Cc: x86@kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Mel Gorman , Matt Fleming , Viresh Kumar , Juri Lelli , Paul Turner , Vincent Guittot , Quentin Perret , Dietmar Eggemann , Doug Smythies , Giovanni Gherdovich Subject: [PATCH v4 0/6] Add support for frequency invariance for (some) x86 Date: Wed, 13 Nov 2019 13:46:48 +0100 Message-Id: <20191113124654.18122-1-ggherdovich@suse.cz> X-Mailer: git-send-email 2.16.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org v3 at https://lore.kernel.org/lkml/20191111180549.12166-1-ggherdovich@suse.cz/ Changes wrt v3: - Add definition of function set_arch_max_freq if !CONFIG_SMP - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Cover Letter from v3: v2 at https://lore.kernel.org/lkml/20191002122926.385-1-ggherdovich@suse.cz/ Changes wrt v2: - Removing the tick_disable mechanism. Frequency scale-invariance isn't just about helping schedutil choose better frequencies, but also providing the scheduler load balancer with better metrics. All users of PELT signals benefit from this feature. The tick_disable patch disabled frequency invariant calculation when a specific driver is in use (intel_pstate in active mode). - static_branch_enable(&arch_scale_freq_key) is now called earlier, right after we learn that X86_FEATURE_APERFMPERF is available. Previously Peter Z. commented "if we can't tell the max_freq we don't want to use the invariant stuff.". I've decided to do it differently: if we can't tell the max_freq, then it's because the CPU encodes max_freq in MSRs in a way this patch doesn't understand, and we assume max_p is the max_freq which seems like a safe bet. As a reminder, max_freq=max_p is encoded by setting arch_max_freq=1024 as default value. I'm open to feedback. - Refactoring the switch case statement in set_cpu_max_freq() as Rafael W. Now the first patch doesn't hint at what the following patch will bring along. - Handling the case were turbo is disabled at runtime and a _PPC ACPI notification is issued, as requested by Rafael W. This happens eg. when some laptop model is disconnected from AC. (Patch #6) - Handling all Intel x86_64 micro-arches. - A note for Srinivas P., who expressed concern for Atoms: on Atom CPUs the max_freq is set to the highest turbo level, as a power-efficiency oriented measure. In this way the ratio curr_freq/max_freq tends to be lower, PELT signals are consequently lower, and schedutil doesn't push too hard on speed. (Patches #4 and #5). - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Cover Letter from v2: v1 at https://lore.kernel.org/lkml/20190909024216.5942-1-ggherdovich@suse.cz/ Changes wrt v1: - add x86-specific implementation of arch_scale_freq_invariant() using a static key that checks for the availability of APERF and MPERF - refer to GOLDMONT_D instead of GOLDMONT_X, according to recent rename - set arch_cpu_freq to 1024 from x86_arch_scale_freq_tick_disable() to prevent PELT from being fed stale data - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Cover Letter from v1: This is a resend with of Peter Zijlstra's patch to support frequency scale-invariance on x86 from May 2018 [see 1]. I've added some modifications and included performance test results. If Peter doesn't mind, I'm slapping my name on it :) The changes from Peter's original implementation are: 1) normalizing against the 4-cores turbo level instead or 1-core turbo 2) removing the run-time search for when the above value isn't found in the various Intel MSRs -- the base frequency value is taken in that case. The section "4. KNOWN LIMITATIONS" in the first patch commit message addresses the reason why this approach was dropped back in 2018, and explains that the performance gains outweight that issue. The second patch from Srinivas is taken verbatim from the May 2018 submission as it still applies. I apologies for the length of patch #1 commit message; I've made a table of contents with summaries of each section that should make easier to skim through the content. This submission incorporates the feedback and requests for additional tests received during the presentation made at OSPM 2019 in Pisa three months ago. [1] https://lore.kernel.org/lkml/20180516044911.28797-2-srinivas.pandruvada@linux.intel.com/ Giovanni Gherdovich (6): x86,sched: Add support for frequency invariance x86,sched: Add support for frequency invariance on SKYLAKE_X x86,sched: Add support for frequency invariance on XEON_PHI_KNL/KNM x86,sched: Add support for frequency invariance on ATOM_GOLDMONT* x86,sched: Add support for frequency invariance on ATOM x86: intel_pstate: handle runtime turbo disablement/enablement in freq. invariance arch/x86/include/asm/topology.h | 28 ++++ arch/x86/kernel/smpboot.c | 324 +++++++++++++++++++++++++++++++++++++++- drivers/cpufreq/intel_pstate.c | 1 + kernel/sched/core.c | 1 + kernel/sched/sched.h | 7 + 5 files changed, 360 insertions(+), 1 deletion(-) -- 2.16.4