Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp381611lqo; Wed, 8 May 2024 02:42:32 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWGosHM8b9aWu5wWmsHTfpMMwC65qLOXS9fKuFMGhtg12TG5EI3MXReuvXylnMfPcqY/XpTeJMC6udW49UOdATiYcqBJohlF1etZpKDJA== X-Google-Smtp-Source: AGHT+IHHPHkWujvsyBgcLfinaYI9ug0A36aFEueiwQBa4VcQjWBEz0j122Z+dK4QSpWs4ipBHlPw X-Received: by 2002:a05:6808:1788:b0:3c7:1d7e:f7d6 with SMTP id 5614622812f47-3c9852c1968mr2406039b6e.18.1715161352172; Wed, 08 May 2024 02:42:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715161352; cv=pass; d=google.com; s=arc-20160816; b=FmgJm6/xvLfcqmGEaYLbD8VkmdDogsqn5RbneR5AfqHUlKnCWVhY0fN9Gtf+lF9Ktw DGKvPPrqirEDeDDpBUMa0bmVykKc3EafvfGOqHKwRQEyp7huSoUMJjRuVqAnJ0x3pnEv Sbx/7zMLgDjmFlAZas02nTvx2mqVRvl7K8s0oi/3hzvm6zUGFOffIUEbSJAkUIpafu7T ZmHISwEEGMKsPDRrhxWzuym+6cpdQ05jpQR0RH7BvMJXi8IJyjh1L8Hcdal8n509o6ZH c+0R+CInPqehHcRV6tCs9o5QIdwWAg/DcUS1mESpaUXDUxLNEUM14OteNAW8m7lkq7b3 Dsmw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ITaU40SFRGKxHYojpCSGh4eL/ryxiwlKRxY2NrN5Zus=; fh=6Xkb/ERHS1k8TxRT7FyH4SaVacihstZiqq+Cg3i87TY=; b=Iqxho2DS6wZR5qYzPHzkukP0Z959C0b5IGnb5YgU7x8lrCca1pp0tWdxqnsng8LCyL VEYhfwlEWykU1ahcXgs4HUYzEMdjgOhgqijCC0mFDdcUqPlUUVc0djxu/PM5GBbI6t0z yY9NJ9FE8Ve0pESr8p5GO0YWV0pVtdABLA03Zs26o5AdM8qe0q09pKV62oVfb7sTXUF1 Ad8cEYROzg3Ttx2KvwlY7UKCZ5owXn4eB26SM2xLsaRmRxCQLeN9mVPyUv7ZlmTvnbSp 2psqOCT7a36c1UUIah37tzcmfYBe8dXDbh2FeH5jspsVVBNFIcuBmPd19l/2Tzm3AYTB bqIw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@natalenko.name header.s=dkim-20170712 header.b=C1WtybD9; arc=pass (i=1 spf=pass spfdomain=natalenko.name dkim=pass dkdomain=natalenko.name dmarc=pass fromdomain=natalenko.name); spf=pass (google.com: domain of linux-kernel+bounces-172981-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172981-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=natalenko.name Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id fo6-20020ad45f06000000b006993bbcb63dsi13402054qvb.549.2024.05.08.02.42.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 02:42:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-172981-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@natalenko.name header.s=dkim-20170712 header.b=C1WtybD9; arc=pass (i=1 spf=pass spfdomain=natalenko.name dkim=pass dkdomain=natalenko.name dmarc=pass fromdomain=natalenko.name); spf=pass (google.com: domain of linux-kernel+bounces-172981-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172981-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=natalenko.name Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id CE7411C219E8 for ; Wed, 8 May 2024 09:42:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 18BAE768EF; Wed, 8 May 2024 09:42:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=natalenko.name header.i=@natalenko.name header.b="C1WtybD9" Received: from prime.voidband.net (prime.voidband.net [199.247.17.104]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2B2551DFE8; Wed, 8 May 2024 09:42:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=199.247.17.104 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715161344; cv=none; b=onh4ycT5O1FzqKlEST2ACBpnllUtzV3czkBJCKfN35r3iUwxukXkaFx0SV3uua0UWD5HdDLlWYWU3fu/ynwXNBkTo1Y2MX3ykzOxwr/LRP55fCwS4I3PtCYizc/eQX3OJbr7yuSaC6c8bMgy5wKxp4E+TeM+kMcqD8vUP3NSJhQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715161344; c=relaxed/simple; bh=tpHBLYwWAXWzFJOiiqPNurkj4onSKHEuQPtc+N0ukQ0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VfsK94TT9j5ZRhedqF6cA9oH7BBYdpCz2sa6Kk0C2kLLE807oDrwRa3dQqRPnapBSS9DmhLxJXhLl1xz9mwflCxe5uRtNPvGt2sM5LLqFK2FHlwHmfZv6UCH1xY2SB/k5ZoNnHJoewpYNijrWP04YpUpGeB+OJuB2FACaFjBWeM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=natalenko.name; spf=pass smtp.mailfrom=natalenko.name; dkim=pass (1024-bit key) header.d=natalenko.name header.i=@natalenko.name header.b=C1WtybD9; arc=none smtp.client-ip=199.247.17.104 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=natalenko.name Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=natalenko.name Received: from spock.localnet (unknown [94.142.239.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by prime.voidband.net (Postfix) with ESMTPSA id BE1EC62DD101; Wed, 08 May 2024 11:34:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=natalenko.name; s=dkim-20170712; t=1715160896; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ITaU40SFRGKxHYojpCSGh4eL/ryxiwlKRxY2NrN5Zus=; b=C1WtybD9FCqWeBqrKKxR6GaNxYDNixDpsr8122tNc9qjBkBxdK5+OZSBm8d/iIzRSScW8I aZ2o+kiJy0d3sa3ZgBToBB5vwIe5Hk6WobBHabirTBFjky7OBc17eYz9MGPXAM4RJWnTP+ avQsxBdHVgLbQwRtbyM8GLhENTKHRek= From: Oleksandr Natalenko To: rafael.j.wysocki@intel.com, Mario.Limonciello@amd.com, viresh.kumar@linaro.org, Ray.Huang@amd.com, gautham.shenoy@amd.com, Borislav.Petkov@amd.com, Perry Yuan Cc: Alexander.Deucher@amd.com, Xinmei.Huang@amd.com, Xiaojian.Du@amd.com, Li.Meng@amd.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v10 6/7] cpufreq: amd-pstate: introduce per CPU frequency boost control Date: Wed, 08 May 2024 11:34:21 +0200 Message-ID: <12430678.O9o76ZdvQC@natalenko.name> In-Reply-To: <49204c6d4a334c0bfbc589dda79b5cd7c4c28b7c.1715152592.git.perry.yuan@amd.com> References: <49204c6d4a334c0bfbc589dda79b5cd7c4c28b7c.1715152592.git.perry.yuan@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart5776929.DvuYhMxLoT"; micalg="pgp-sha256"; protocol="application/pgp-signature" --nextPart5776929.DvuYhMxLoT Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8"; protected-headers="v1" From: Oleksandr Natalenko Date: Wed, 08 May 2024 11:34:21 +0200 Message-ID: <12430678.O9o76ZdvQC@natalenko.name> MIME-Version: 1.0 Hello. On st=C5=99eda 8. kv=C4=9Btna 2024 9:21:11, SEL=C4=8C Perry Yuan wrote: > Add a new sysfs attribute file to support per CPU frequency boost > control, allowing individual CPUs to enable or disable CPB separately. >=20 > The new sysfs attribute file is located at below path, > `/sys/devices/system/cpu/cpuX/cpufreq/boost`, > where `X` represents the CPU number. >=20 > To disable CPB for a specific CPU, you can use the following command: > $ sudo bash -c "echo 0 > /sys/devices/system/cpu/cpuX/cpufreq/boost" >=20 > After disabling CPB, the CPU frequency will no longer boost beyond > the base frequency for that particular CPU. >=20 > for example: > ---------------------------------------------------------------------- > CPU NODE SOCKET CORE L1d:L1i:L2:L3 ONLINE MAXMHZ MINMHZ MHZ > 0 0 0 0 0:0:0:0 yes 4208.0000 400.0000 1666.7740 > 1 0 0 0 0:0:0:0 yes 4208.0000 400.0000 400.0000 >=20 > ---------------------------------------------------------------------- > $ sudo bash -c "echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/boost" >=20 > CPU NODE SOCKET CORE L1d:L1i:L2:L3 ONLINE MAXMHZ MINMHZ MHZ > 0 0 0 0 0:0:0:0 yes 3501.0000 400.0000 4154.3140 > 1 0 0 0 0:0:0:0 yes 4208.0000 400.0000 400.0000 >=20 > Please be aware that modifying the global variable > `amd_pstate_global_params.cpb_boost` will overwrite the individual CPU se= ttings. >=20 > Signed-off-by: Perry Yuan > --- > drivers/cpufreq/amd-pstate.c | 27 +++++++++++++++++++++++++++ > 1 file changed, 27 insertions(+) >=20 > diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c > index 11bce2c1db32..cb0055e7c842 100644 > --- a/drivers/cpufreq/amd-pstate.c > +++ b/drivers/cpufreq/amd-pstate.c > @@ -1371,6 +1371,30 @@ static int amd_pstate_cpu_boost(int cpu, bool stat= e) > return ret < 0 ? ret : 0; > } > =20 > +static ssize_t show_boost(struct cpufreq_policy *policy, char *buf) > +{ > + struct amd_cpudata *cpudata =3D policy->driver_data; > + bool boost_val; > + > + boost_val =3D READ_ONCE(cpudata->boost_state); > + > + return sysfs_emit(buf, "%u\n", boost_val); > +} > + > +static ssize_t store_boost( > + struct cpufreq_policy *policy, const char *buf, size_t count) > +{ > + bool boost_val; > + int ret; > + > + if (sscanf(buf, "%d", &boost_val) !=3D 1) This will generate warning. IIUC, sscanf() doesn't work with booleans direc= tly, so you'd probably want to read the value into an (unsigned) integer, a= nd then cast it to bool. > + return -EINVAL; > + > + ret =3D amd_pstate_cpu_boost(policy->cpu, boost_val); > + > + return ret < 0 ? ret : count; > +} > + > static ssize_t cpb_boost_show(struct device *dev, > struct device_attribute *attr, char *buf) > { > @@ -1416,6 +1440,7 @@ cpufreq_freq_attr_ro(amd_pstate_prefcore_ranking); > cpufreq_freq_attr_ro(amd_pstate_hw_prefcore); > cpufreq_freq_attr_rw(energy_performance_preference); > cpufreq_freq_attr_ro(energy_performance_available_preferences); > +cpufreq_freq_attr_rw(boost); > static DEVICE_ATTR_RW(status); > static DEVICE_ATTR_RO(prefcore); > static DEVICE_ATTR_RW(cpb_boost); > @@ -1426,6 +1451,7 @@ static struct freq_attr *amd_pstate_attr[] =3D { > &amd_pstate_highest_perf, > &amd_pstate_prefcore_ranking, > &amd_pstate_hw_prefcore, > + &boost, > NULL, > }; > =20 > @@ -1437,6 +1463,7 @@ static struct freq_attr *amd_pstate_epp_attr[] =3D { > &amd_pstate_hw_prefcore, > &energy_performance_preference, > &energy_performance_available_preferences, > + &boost, > NULL, > }; > =20 >=20 =2D-=20 Oleksandr Natalenko (post-factum) --nextPart5776929.DvuYhMxLoT Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part. Content-Transfer-Encoding: 7Bit -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEZUOOw5ESFLHZZtOKil/iNcg8M0sFAmY7Rx0ACgkQil/iNcg8 M0sozhAAwBKs7R6wasSZh5RwWS9z9V5g2aOMfwlMXNbXWMxVHZsq8E/rncUtUJ5b jjjvAYGBFcW4Z+5WWU8OTQr82MpTiXfPs7A5lSz6vbrkuF2dGfWPdrXFmA1xv1Nw SrDjQSNkzB7U3/wUFjADu5yyaORBMRrCGCl6CktG4Cnoe6pRi1tLndNqPjp7xiHm blZJTNvs7V7KV2tTpMPYgPKAadkuMfEURI7grBqe0kfy8r1z6HHQmkJVHCfoa3RF oHiwFcBBZJ3bAUG2ps/V8dsNcStYWvgDQHuKMO1ZGwvx0L3JMhY8hKFIzb92i2El 51u9zAa81QZEnEr4BjvqRIdRuH+4QkQ07gXjsmfxQwGmhJgpGTlqUoHBLUXNyD6U QZpfWsltaKpLf3ilhc/OTXclHe4eg3/hMhNUNTCg1ThKKgSRG/QCLE3vS80F2tdL Vc1RehzmUdFfxLPN+6In+w+i9eQqzrKelXME1NGOoETKyLtxu4UvUOxw+Ux8/jTD Dh9mRRFAaeiPuKnH+Eu7X1dCoCZ9flByhOJKABZO9Q3LQ3bvNUzJHEHVDsSmiKZ0 2a0FkEuC/kRwUnr1rARFjHzxoFZh94gMewyqCCehgAH1iB4dYNzHZHkDXJi1z/dD IrwctWnfVHmwTLQmx7u/4qXoTwvoxAyf4QDvhcZIlq4D5CYz1g0= =SI1r -----END PGP SIGNATURE----- --nextPart5776929.DvuYhMxLoT--