Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp694236pxx; Wed, 28 Oct 2020 14:43:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxKTUas2k0WwD1Qx07BTd+rR7YfWeznaHzyLVKNyVDTaNqvX5QVT7muOSj/MEWDV5QwgQKi X-Received: by 2002:a50:e686:: with SMTP id z6mr976607edm.188.1603921427350; Wed, 28 Oct 2020 14:43:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603921427; cv=none; d=google.com; s=arc-20160816; b=qh9ErCahSvQVf6eTx5jFHtgiZ6ZMlPybdu5+z42qbL5yJJCbft1pww6/kuubdU0JOw A3b3FwOCXVPG+JRGmZTIBsNLAVxTk259Fy2vzhsryV9m+tKUvKkpP4pyhukydv3fYDbo SJAH/GDWx0BWY38IIzJrs7/j1LeaQ7Jm5GBP5CEZuHgDweP+qo/rez89GuztLc82NN1B b/3R2UmfUDw2kwZXw/o3Ea3Vba+JftBGJjcerB2NsJX9u3l1NZxfoAOnZkZ1QWl9v2EK tsXsfVJC0pSTOIwERPQOQ9Eml2FTE32laI/wJsKDjGimeqTE0nlhJWMrkKxs/j6krdLF jLyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=oUQGYHl6fL0itz3RWijtbqZBDnCCvlTy72hHOJX7pSU=; b=PiUgzHChRhlivirmNf36YdVs4m6IVbLroIzBjQ/b5s5/mH6KSu1NceEnzqfDn7rH60 DJc5GRRUqPZCnMeBpGQvbXdHJVigZxmZPNLYsvOttducr4/QE3Vz7kozDwkiZ3EWEY0g S0gkivnv9qufQy36q0s8oTpzUbo6pP3DoDbPjk+0nyoNPIAGDNh/xUTdktTJqmvOqOXO yhCLyVFI/w34kWcgJmGBl2FtVJ2VSziKlSfoPowWi5s//6lR/oxitJ3703jsOBWN+B4A b1SEXze9OKMgtVqgwgtZeztQb/35eHQnMOKHYeVKiBVHm6DJxtdRius2a54bK6D++28s 9Oeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="wnl6oBn/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e26si355956ejx.724.2020.10.28.14.43.25; Wed, 28 Oct 2020 14:43:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="wnl6oBn/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726284AbgJ1Vmc (ORCPT + 99 others); Wed, 28 Oct 2020 17:42:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726201AbgJ1Vm1 (ORCPT ); Wed, 28 Oct 2020 17:42:27 -0400 Received: from mail-il1-x143.google.com (mail-il1-x143.google.com [IPv6:2607:f8b0:4864:20::143]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE7E1C0613D1 for ; Wed, 28 Oct 2020 14:42:26 -0700 (PDT) Received: by mail-il1-x143.google.com with SMTP id z2so947918ilh.11 for ; Wed, 28 Oct 2020 14:42:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=oUQGYHl6fL0itz3RWijtbqZBDnCCvlTy72hHOJX7pSU=; b=wnl6oBn/Zw2KFaEIcPW+DYoJ9y6mSCx1bVJxZNJVS8dmkAv8U2yzrNU2SFR+/J5ZoI qLH21UEmwAqmSsLU6Fq4UKGDLHhOWBgDt36ptPjUbm6quVeflh/e5YH8n3MCqDw72/3f ZZh6gCQmzLpXxhm6Hku3R0CXNSBwi2nb81p8pauc7WFhrkAuoaAz2IjXVgOY+aKYfbQn m4Acp4WRhR8UFnibB71sCTgW/sgIHJZRXMrSRDZSdpxPL3I9/RH/AmBs5XM3HK7YY1oR XrGindx3PneZp60ijEP/JNl1BIrI04ZTN/nVFq1hqvrd5q+QN6SsA8AFH45BdXre49SJ 4Ymw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=oUQGYHl6fL0itz3RWijtbqZBDnCCvlTy72hHOJX7pSU=; b=mPaYC72Y4rk+FE8UjSF9qQq9awqhrcith2TCsJQ/cndTVQ0LZsV/QtqxacaE0F84/R 2ViRlI2ycDVnx0XfcvuQrsSj16rr+B1367hup1XIFAq+lsgbno2+2KDz3FUBXgrt8epp tQUdZ8x6b6Hi0/HlU8eTHgQTx4ZpjphJBFXdJbIypzZQ/1YXYvvXTpCTKKBYT66vjwm7 3gMm1en0tf9VevMENLgQkKEWCje9m1Bij/0VfBTbRvCqaq0cBeS8172iCSws1dD5AhKJ zo1ekBcucIJ517xA/Ql2xpw7O6M5q1htz6grSCPEcZuOpVRtTRJmCSl3BkvF5B7Rhyfo Ic+A== X-Gm-Message-State: AOAM532I2mJXpBur4VzQHG/DxMvJi9IDAJvannfewGtkwl4I5wPOZj7l CmCJouzNXMyXPdzxzdn5Is9cP9NxdOBhIQ== X-Received: by 2002:a63:4d0b:: with SMTP id a11mr5168634pgb.296.1603873311277; Wed, 28 Oct 2020 01:21:51 -0700 (PDT) Received: from localhost ([122.181.54.133]) by smtp.gmail.com with ESMTPSA id k1sm1225956pgn.66.2020.10.28.01.21.49 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Oct 2020 01:21:50 -0700 (PDT) Date: Wed, 28 Oct 2020 13:51:48 +0530 From: Viresh Kumar To: zhuguangqing83@gmail.com Cc: rjw@rjwysocki.net, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, zhuguangqing Subject: Re: [PATCH] cpufreq: schedutil: set sg_policy->next_freq to the final cpufreq Message-ID: <20201028082148.zkvcqau4p6xcihoq@vireshk-i7> References: <20201027115459.19318-1-zhuguangqing83@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201027115459.19318-1-zhuguangqing83@gmail.com> User-Agent: NeoMutt/20180716-391-311a52 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 27-10-20, 19:54, zhuguangqing83@gmail.com wrote: > From: zhuguangqing > > In the following code path, next_freq is clamped between policy->min > and policy->max twice in functions cpufreq_driver_resolve_freq() and > cpufreq_driver_fast_switch(). For there is no update_lock in the code > path, policy->min and policy->max may be modified (one or more times), > so sg_policy->next_freq updated in function sugov_update_next_freq() > may be not the final cpufreq. Understood until here, but not sure I followed everything after that. > Next time when we use > "if (sg_policy->next_freq == next_freq)" to judge whether to update > next_freq, we may get a wrong result. > > -> sugov_update_single() > -> get_next_freq() > -> cpufreq_driver_resolve_freq() > -> sugov_fast_switch() > -> sugov_update_next_freq() > -> cpufreq_driver_fast_switch() > > For example, at first sg_policy->next_freq is 1 GHz, but the final > cpufreq is 1.2 GHz because policy->min is modified to 1.2 GHz when > we reached cpufreq_driver_fast_switch(). Then next time, policy->min > is changed before we reached cpufreq_driver_resolve_freq() and (assume) > next_freq is 1 GHz, we find "if (sg_policy->next_freq == next_freq)" is > satisfied so we don't change the cpufreq. Actually we should change > the cpufreq to 1.0 GHz this time. FWIW, whenever policy->min/max gets changed, sg_policy->limits_changed gets set to true by sugov_limits() and the next time schedutil callback gets called from the scheduler, we will fix the frequency. And so there shouldn't be any issue here, unless I am missing something. -- viresh