Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp1057983rdg; Fri, 13 Oct 2023 09:02:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG4xH2ZvFetZRyP+aiqYX6IGqPdjMRS1OOlPuGBIJBXE2n5RyDlxORsHp0kpNQ+PH7PsmX6 X-Received: by 2002:a05:6358:441d:b0:143:8574:4311 with SMTP id z29-20020a056358441d00b0014385744311mr32208512rwc.12.1697212930617; Fri, 13 Oct 2023 09:02:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697212930; cv=none; d=google.com; s=arc-20160816; b=Oma/V/m18oefRSyZX+kRxeSIJ1TcWNFRJLf1Bpx0B9qvflKyLA81HV3qj03au8CucU sDozU+G8Fu6rh+VB11V+UM7a5puZhXsTDqAxE2Qoy1d29MP0qoVEWjvVua3jSQ4dgZyY 3B6CXoGUu8EwnwG8Em4fupfwrtjio6F4Nmo5Jf9sEnlD6WJD3HYSgSTRl7YCUed1fm0p hx6UJJ8XXCPqhDqsG3umCYxB43kXh92XyRBOmrHHD3F3FlXnP9k+UXv+Mw5NMkyUr1UT DCQqUC85tH1Rryf2W9cWfZu315hsgixVQvrvlq4s+8qrG/OdrC2jQG6qpzolJmc9T9wr r5AA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=R1BXEjw/tdVpUH9FfenMcwOFEve9DMEy/SsDnd6XIV8=; fh=e2V6D7HslNkSxahOU5vFlL1oWCaAbnqjXk69xc4n/QY=; b=behg4gA9xE2cyqAMKt4BBprC8/f3MjE3hZ6hERHVo0XltcGXJxWkSDYNufv3to2ocu GKbbnxEyVC0ugKqzW6wqu9Kp5RN52lpha2uwEl45HLxbQWNh7TxYdtoRFlZJZm3uTep4 RBAmp1GloTMpzBVGatscWrIbzLGnWbYaC5WIygZqn6GSGDa3sTL2mhAYyLInaWxQIwKD tRSliH0HcZd7px3b5TbuWVIPGEgeJ8lFuRigQcgUKLlvajbWDp3kRnnHxnBBndA3azFu ZxKgyw2wIc0AZaowjLSxohZdgUm0Kuw30D9RjzUJtVc5ByWeB2Q/SNKtjrQD+pZDSJzp rGEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=g+CaL7TN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id h12-20020a63574c000000b0059bb496956csi4835511pgm.202.2023.10.13.09.02.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 09:02:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=g+CaL7TN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id C9DA780491C2; Fri, 13 Oct 2023 09:02:07 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232529AbjJMQB6 (ORCPT + 99 others); Fri, 13 Oct 2023 12:01:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232452AbjJMQB5 (ORCPT ); Fri, 13 Oct 2023 12:01:57 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C0BEB7; Fri, 13 Oct 2023 09:01:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=R1BXEjw/tdVpUH9FfenMcwOFEve9DMEy/SsDnd6XIV8=; b=g+CaL7TNnTOSCiZ8cFDSFAoPWe P4/WPfJckr/usSf+r9yzJT1lS4xprCch7vI7na4OF1+wDRkfh9hV43y2+MQiSygejZqJwwLCqj1Ko qdjwNr1NdfCOq++uUQvWWjkdxyDIN2/vMLnhH0SHt02IFOd2WuyAO1QQc9+x234lQ6jV3F5/JCZQS YRjSra9iyBZBfy8wKY8BOyV/JRR+lnVLZqM3ER4TDgEWKECQ2ma5a6nihfEv+5NGDfApEEaMQYiU4 yMijICBewF3eqYM94tkOI9/4sIRvmpdn9FGPS8t0dkSCwDip2AtFHHz0Oq8mgXmnqTes/JxSoko9h O/UVkEJA==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qrKbP-002rBl-2p; Fri, 13 Oct 2023 16:01:30 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 030C83002E1; Fri, 13 Oct 2023 18:01:29 +0200 (CEST) Date: Fri, 13 Oct 2023 18:01:28 +0200 From: Peter Zijlstra To: Meng Li Cc: "Rafael J . Wysocki" , Huang Rui , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org, linux-acpi@vger.kernel.org, Shuah Khan , linux-kselftest@vger.kernel.org, Nathan Fontenot , Deepak Sharma , Alex Deucher , Mario Limonciello , Shimmer Huang , Perry Yuan , Xiaojian Du , Viresh Kumar , Borislav Petkov , Oleksandr Natalenko , Wyes Karny Subject: Re: [RESEND PATCH V9 3/7] cpufreq: amd-pstate: Enable amd-pstate preferred core supporting. Message-ID: <20231013160128.GB36211@noisy.programming.kicks-ass.net> References: <20231013033118.3759311-1-li.meng@amd.com> <20231013033118.3759311-4-li.meng@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231013033118.3759311-4-li.meng@amd.com> X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Fri, 13 Oct 2023 09:02:08 -0700 (PDT) On Fri, Oct 13, 2023 at 11:31:14AM +0800, Meng Li wrote: > +#define AMD_PSTATE_PREFCORE_THRESHOLD 166 > +#define AMD_PSTATE_MAX_CPPC_PERF 255 > +static void amd_pstate_init_prefcore(struct amd_cpudata *cpudata) > +{ > + int ret, prio; > + u32 highest_perf; > + static u32 max_highest_perf = 0, min_highest_perf = U32_MAX; What serializes these things? Also, *why* are you using u32 here, what's wrong with something like: int max_hp = INT_MIN, min_hp = INT_MAX; > + > + ret = amd_pstate_get_highest_perf(cpudata->cpu, &highest_perf); > + if (ret) > + return; > + > + cpudata->hw_prefcore = true; > + /* check if CPPC preferred core feature is enabled*/ > + if (highest_perf == AMD_PSTATE_MAX_CPPC_PERF) { Which effectively means <255 (also, seems to suggest MAX_CPPC_PERF might not be the best name, hmm?) Should you not write '>= 255' then? Just in case something 'funny' happens? > + pr_debug("AMD CPPC preferred core is unsupported!\n"); > + cpudata->hw_prefcore = false; > + return; > + } > + > + if (!amd_pstate_prefcore) > + return; > + > + /* The maximum value of highest perf is 255 */ > + prio = (int)(highest_perf & 0xff); If for some weird reason you get 0x1ff or whatever above (dodgy BIOS never happens, right) then this makes sense how? Perhaps stop sending patches at break-nek speed and think for a little while on how to write this and not be confused? > + /* > + * The priorities can be set regardless of whether or not > + * sched_set_itmt_support(true) has been called and it is valid to > + * update them at any time after it has been called. > + */ > + sched_set_itmt_core_prio(prio, cpudata->cpu); > + > + if (max_highest_perf <= min_highest_perf) { > + if (highest_perf > max_highest_perf) > + max_highest_perf = highest_perf; > + > + if (highest_perf < min_highest_perf) > + min_highest_perf = highest_perf; > + > + if (max_highest_perf > min_highest_perf) { > + /* > + * This code can be run during CPU online under the > + * CPU hotplug locks, so sched_set_itmt_support() > + * cannot be called from here. Queue up a work item > + * to invoke it. > + */ > + schedule_work(&sched_prefcore_work); > + } > + } Not a word about what serializes these variables. > +}