Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp4807192imm; Mon, 15 Oct 2018 23:40:48 -0700 (PDT) X-Google-Smtp-Source: ACcGV62A0LZH/5DbYfLdsPPKCyrZHKU8oAO5wfK4mA6Gt5EmPqyhMG5kxUe/5VETfmhNwB8G3QFA X-Received: by 2002:a17:902:b83:: with SMTP id 3-v6mr4455489plr.250.1539672048184; Mon, 15 Oct 2018 23:40:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539672048; cv=none; d=google.com; s=arc-20160816; b=hv+M/w3fvgzHLRErAPR2+MIWPZ4M/VzfUxg2WYjSpErTobpn2g0lyYn1KFx1l2e2Rl dNewwnrcPXnFSXB4HiuInD4/by+Cgk7hDIyVhqoafdN1rUlYD4WvlApZRk+SYetAsLwz Wi0n3uEYvq/mfhC2qioChucUv9GRvYxHRO5PIlkMD/1D8t5cLLQZWQ2kCqb5g6iREbF6 jzaSidpoWlg2yvjmMvcmXMCNengGG814C94Tev//yWq73NPoRSNJBxDrHpKiTpcD58Vh eXSdQCnYJey7j4qzKUQ/V5nryQOwn0Su32aLYem4jcNhaMQkU1RdNlCs4nX2uBrFbvbI geKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=jL5P6guJvFKgwyFoHXbej2jNX+mJ2O2UGscPCmJHkEE=; b=sK99cVD6L2+j2k1LZxRJkw4EEcDiDCMh1Cd/xzT9rGa6mrqm67zveYj5QZNU/4HArJ MQPvC/FNY3Xbudt9hm/7tjj/KbtLrJ10xfIK5P+ruJxgscCJcemeUAIjvCMQ9SEfNbVW N+K2WxPepz1LhsilfZhHBV/EkxED0Jw7fkaHwMhpT3l77kHKesvq5c6/QTFPXtjVOINu s+z5u8UdLR6QzIxTZyPKBEnLSOaQF7do/PM7lJdXuZ7GWdONetOl+Wd2zuFSzJ7U/M27 Gg7UELSvsWOAQT9SYCQId2ND5ltSQ6o42e5LQ4AjGh5lDXeb5yoyLjHfM7XpfCRPf8ed wDIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=jU66lAem; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g38-v6si12954692pgm.193.2018.10.15.23.40.32; Mon, 15 Oct 2018 23:40:48 -0700 (PDT) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=jU66lAem; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727547AbeJPO2X (ORCPT + 99 others); Tue, 16 Oct 2018 10:28:23 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:35524 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727094AbeJPO2X (ORCPT ); Tue, 16 Oct 2018 10:28:23 -0400 Received: by mail-lj1-f194.google.com with SMTP id o14-v6so19789313ljj.2; Mon, 15 Oct 2018 23:39:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=jL5P6guJvFKgwyFoHXbej2jNX+mJ2O2UGscPCmJHkEE=; b=jU66lAemMRr0HsDcumG6nNVDZ7GJzgWBsR1A6MIGm+1rZsHlcwzCr1j6k6EkqPv4QR T00z7R2apws674qmyPJR9JAkAriOCraX74TDPmxD0jdUv/zEZmzfZDQiXUet4kOCYjpQ q1DT74G1Dxlbajq7wBftY6SG7uVjh1h6rT7jfMD6TOqeNlgK5vG6u3GE15FM1dB/SlcP V7ftuxVrloHK9Vy/J5mYUpXRa01fL1yqQ+C2qWKKx+sgDsN+Xog+SUD7TVcJUdNrWvOu YC5MScM1+QNiBnG9ChWfeYO5cTE6zEM0WrQUitbBHh2/0/9mduqhx5mc1ii5TFEFQRoQ u7Lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=jL5P6guJvFKgwyFoHXbej2jNX+mJ2O2UGscPCmJHkEE=; b=H3stfUm83twHWTmYVGvTW2s7sQuyUm7gMlLJTlk2rjDYJdkQAux6SuktP6oTYdj/iE z02pL6zD5dPAjmTis5ptJCvRUaXLCArjjRssDkXi47lPOD2czXP1iQlB0+YIX3pyf/Fs gyyr/haMU6hC2QJiQj/gOZIGAYh85ApMp2jAcgnlKSas1MvBD+nwW5T59I/cCMGMK+is cc4e66pi1q/UGyALLXBrRrayDlqm7oooldq1CWnVTjGf1byuLC+myOJSu8yEFPC7ZprB TwSKyIG8I1RFQSm+jSyZlrcdh0POe0LzSrw8Wq+9GSbACHgwh9uAuK7ibd5V+lSBAkmC fVtA== X-Gm-Message-State: ABuFfogMnth48IcMuso8n890R3k7e2iyceQQAfAZiHF4sq9IRpFawB2M J4DxRR59EyZP5hqY5Ygv5JJ0yzyKhRaCtPytTChEK79ETms= X-Received: by 2002:a2e:52ca:: with SMTP id n71-v6mr12395178lje.54.1539671966155; Mon, 15 Oct 2018 23:39:26 -0700 (PDT) MIME-Version: 1.0 References: <20181008150901.19667-1-waldemar.rymarkiewicz@gmail.com> <5406371.vuaACy5i7F@aspire.rjw.lan> In-Reply-To: <5406371.vuaACy5i7F@aspire.rjw.lan> From: Waldemar Rymarkiewicz Date: Tue, 16 Oct 2018 08:38:49 +0200 Message-ID: Subject: Re: [PATCH] cpufreq: conservative: Take limits changes into account properly To: "Rafael J. Wysocki" Cc: linux-pm@vger.kernel.org, Viresh Kumar , Waldemar Rymarkiewicz , linux-kernel@vger.kernel.org, "Bartholomae, Thomas" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 15 Oct 2018 at 23:24, Rafael J. Wysocki wrote: > > From: Rafael J. Wysocki > > If the policy limits change between invocations of cs_dbs_update(), > the requested frequency value stored in dbs_info may not be updated > and the function may use a stale value of it next time. Moreover, if > idle periods are takem into account by cs_dbs_update(), the requested > frequency value stored in dbs_info may be below the min policy limit, > which is incorrect. > > To fix these problems, always update the requested frequency value > in dbs_info along with the local copy of it when the previous > requested frequency is beyond the policy limits and avoid decreasing > the requested frequency below the min policy limit when taking > idle periods into account. > > Reported-by: Waldemar Rymarkiewicz > Signed-off-by: Rafael J. Wysocki > --- > drivers/cpufreq/cpufreq_conservative.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > Index: linux-pm/drivers/cpufreq/cpufreq_conservative.c > =================================================================== > --- linux-pm.orig/drivers/cpufreq/cpufreq_conservative.c > +++ linux-pm/drivers/cpufreq/cpufreq_conservative.c > @@ -80,8 +80,10 @@ static unsigned int cs_dbs_update(struct > * changed in the meantime, so fall back to current frequency in that > * case. > */ > - if (requested_freq > policy->max || requested_freq < policy->min) > + if (requested_freq > policy->max || requested_freq < policy->min) { > requested_freq = policy->cur; > + dbs_info->requested_freq = requested_freq; > + } > > freq_step = get_freq_step(cs_tuners, policy); > > @@ -92,7 +94,7 @@ static unsigned int cs_dbs_update(struct > if (policy_dbs->idle_periods < UINT_MAX) { > unsigned int freq_steps = policy_dbs->idle_periods * freq_step; > > - if (requested_freq > freq_steps) > + if (requested_freq > policy->min + freq_steps) > requested_freq -= freq_steps; > else > requested_freq = policy->min; Looks good. Acked-by: Waldemar Rymarkiewicz