Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2374005ybl; Thu, 19 Dec 2019 12:27:21 -0800 (PST) X-Google-Smtp-Source: APXvYqzAluG9ys/2lo39V43O0XCSgkRI8iEsZMoX79sROROMSfNUgPCvjyBqQ3F1llT/ayvhU5C3 X-Received: by 2002:a05:6830:1651:: with SMTP id h17mr10236689otr.167.1576787241533; Thu, 19 Dec 2019 12:27:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576787241; cv=none; d=google.com; s=arc-20160816; b=BQCLFmCAF0/fzznfpoecCMpk8PC9sPs8Ih4nyDK+SlxhUj2YXIp6jB1vjO+LzwG3gK 2gHP3HGfG0aKxnrAUG0cq5L54hF6Qfv4kuh2z4kNiCrjIzo1G8l3mDIUlyf2XPTHli5y gb/wbpDE/r7G2VuT+397Byxzy72/DMYbptfpycUbXZZHeFhZ0eWta1sDuujpYEryqpAC HSp5JwFnTkmPbCDIG01TODAhOqmXblpVF7FJ0ivMbNGXu4Y5tF2xN9BasOmpO59tKs88 IcZCrGcWJUWzpH1M2vqhy2bdYanojdIKUAahEbiakt1xrUdtEVfuqsKaFz8hKUgrBVA3 FwKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id; bh=YhtzbHPOQKwrVDVsWgQwFqtcU4xXs4XBsl614unkyQc=; b=fJzgD8SHhD6fUIMWq0vkUWD2sk5X4FzDjfiVQwNWpJHgvaPgYpGeCh0lkgW8TlW8/p yAXFlDk32nek2eP1Wzsa9M0r81F98A/wXB05lNbXG64mK3CETg5oBBaJSfDDIMB+85R/ sw9tFJg+bnrzZ4s7aL9Ehf6omrisY428o9koHsD7EUINhyywcxGqvJZO1MG16tBj8jS5 jmA/nZQ6FStGKOQSh0NW2/ewKE1i8VTpyYxzXDlyfLg7ubsBZ+VFugbqmnii0VFgn9An iNeiRDkPSm18ThOSXPNp5mAMlyzy7q7l9zIfpUPNKYA4ig7MHxj5fII88CKnvqhsrHSU vZXg== 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 t23si3872349otk.304.2019.12.19.12.27.09; Thu, 19 Dec 2019 12:27:21 -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 S1727144AbfLSU0d (ORCPT + 99 others); Thu, 19 Dec 2019 15:26:33 -0500 Received: from mx2.suse.de ([195.135.220.15]:49788 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726908AbfLSU0d (ORCPT ); Thu, 19 Dec 2019 15:26:33 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 4AEDDB3A2; Thu, 19 Dec 2019 20:26:31 +0000 (UTC) Message-ID: <1576787539.8929.15.camel@suse.cz> Subject: Re: [PATCH v4 3/6] x86,sched: Add support for frequency invariance on XEON_PHI_KNL/KNM From: Giovanni Gherdovich To: Peter Zijlstra Cc: Srinivas Pandruvada , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Len Brown , "Rafael J . Wysocki" , 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 Date: Thu, 19 Dec 2019 21:32:19 +0100 In-Reply-To: <20191218202236.GJ11457@worktop.programming.kicks-ass.net> References: <20191113124654.18122-1-ggherdovich@suse.cz> <20191113124654.18122-4-ggherdovich@suse.cz> <20191218202236.GJ11457@worktop.programming.kicks-ass.net> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.26.6 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2019-12-18 at 21:22 +0100, Peter Zijlstra wrote: > On Wed, Nov 13, 2019 at 01:46:51PM +0100, Giovanni Gherdovich wrote: > > The scheduler needs the ratio freq_curr/freq_max for frequency-invariant > > accounting. On Xeon Phi CPUs set freq_max to the second-highest frequency > > reported by the CPU. > > > > Xeon Phi CPUs such as Knights Landing and Knights Mill typically have either > > one or two turbo frequencies; in the former case that's 100 MHz above the base > > frequency, in the latter case the two levels are 100 MHz and 200 MHz above > > base frequency. > > > > We set freq_max to the second-highest frequency reported by the CPU. This > > could be the base frequency (if only one turbo level is available) or the first > > turbo level (if two levels are available). The rationale is to compromise > > between power efficiency or performance -- going straight to max turbo would > > favor efficiency and blindly using base freq would favor performance. > > > > For reference, this is how MSR_TURBO_RATIO_LIMIT must be parsed on a Xeon Phi > > to get the available frequencies (taken from a comment in turbostat's sources): > > > > [0] -- Reserved > > [7:1] -- Base value of number of active cores of bucket 1. > > [15:8] -- Base value of freq ratio of bucket 1. > > [20:16] -- +ve delta of number of active cores of bucket 2. > > i.e. active cores of bucket 2 = > > active cores of bucket 1 + delta > > [23:21] -- Negative delta of freq ratio of bucket 2. > > i.e. freq ratio of bucket 2 = > > freq ratio of bucket 1 - delta > > [28:24]-- +ve delta of number of active cores of bucket 3. > > [31:29]-- -ve delta of freq ratio of bucket 3. > > [36:32]-- +ve delta of number of active cores of bucket 4. > > [39:37]-- -ve delta of freq ratio of bucket 4. > > [44:40]-- +ve delta of number of active cores of bucket 5. > > [47:45]-- -ve delta of freq ratio of bucket 5. > > [52:48]-- +ve delta of number of active cores of bucket 6. > > [55:53]-- -ve delta of freq ratio of bucket 6. > > [60:56]-- +ve delta of number of active cores of bucket 7. > > [63:61]-- -ve delta of freq ratio of bucket 7. > > Does it make sense to write a complete decoder and pass a @size > parameter just like the skx/glm case? > > (I've no idea on the 4 I passed in, probably wants to be something else) I see your point: it's better to have a @size parameter so that if there is a better value, we can easily change the number in the future. It also uniforms to how the others are handled. But from the little I've learned on Xeon Phi, the best parameter to characterize the choice is not the @size of the buckets, but the number of non-zero @delta's of freq ratio that you encounter while parsing the MSR. The number of those non-zero freq ratio @delta's corresponds to how many freq ratios you can have, and the documentation says this can be either 1 or 2. My "documentation" is actually the 4-pages leaflet at [1], but I breafly asked Len Brown and he said it made sense. So that's how I would parametrize the code. If I use your function, in order to extract the max_freq value I want from the Xeon Phi machine I have, @size should be a number between 31 and 68 cores (see example below). Not that there is anything wrong with 31 <= size <= 68, it's just that I can make an assumption on how many freq ratios there are and I'd like to do it. My Xeon Phi test machine: Xeon Phi CPU 7255 (Knights Mill) Max Efficiency: 1000 MHz Base Frequency: 1100 MHz 68 cores turbo: 1100 MHz 30 cores turbo: 1200 MHz You can see the above has only 1 non-zero delta freq ratio; the base freq is 1100 MHz and max turbo is 1100+100 MHz. If I could at least check a Knights Landing (which I don't have) and confirm that 31 <= size gives me the second-highest freq ratio, I'd use your function, but at the moment using @delta as a parameter seems safer. [1] https://www.intel.com/content/dam/www/public/us/en/documents/product-briefs/xeon-phi-processor-product-brief.pdf ---> footnote #3, last page: "Frequency listed is nominal (non-AVX) TDP frequency. For all-tile turbo frequency, add 100 MHz. For single-tile turbo frequency, add 200 MHz. For high-AVX instruction frequency, subtract 200 MHz."