Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3441266imu; Sun, 11 Nov 2018 15:10:09 -0800 (PST) X-Google-Smtp-Source: AJdET5csOCKmnqluxQRy9P7NYN4q0ZMA+W9RA27IHK1dKca/AdzOy3myJlVqsTyVp0GUE2dvMK0V X-Received: by 2002:a62:c184:: with SMTP id i126-v6mr17998216pfg.53.1541977809040; Sun, 11 Nov 2018 15:10:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541977809; cv=none; d=google.com; s=arc-20160816; b=Nk/G2DNeWHJKkK7WU2j0NX4+jftZy1PIHCqSyCcHttvlVtttz7Ys6l5Q6swaFWMBjZ VDys6zdKx9J2ZQM88Bmw6vPrNXRIS5QNZxhJlriDYKY0RcCmNB0847fpw2Pc482QHiW9 kMlo7cDzhN8J4x4kYqMFQLzoay/UFVHkrdAmIbCmDde/2CY7TTROx2wxcIMopZn61J3M zGkV7KCcH17Jr7o0U8xr0BsOEMZVoz/ug0d4QdHkqMM5EehYD6mNohf4VE+Bvhx6NlD/ FUCVuHQo3I+ptRATu2Nj4iUwu0627CBqOcTOsRJB6km42tm4XaMz/AKKHvptUNvjFsiB zrdA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=hR3VxYviRUzAsS0bLst4oJCFcK8V4bljEw6wSENER50=; b=JK2Zw6p6nhVhaK7rZutWwZOe99w65I4PpfIMvY0VEAYCETSOIuvD+AW7XmiLOJi/JI 938xdmf+c97S3XpS8J/oTq9wP4SGsuujsdxRQl5qLMPbZsTwvWC0EeCaIWuE14boZu16 DdACyF86tNv4/sjSC7dYZqSy7VVCzlDzAN2Ua2i98wgGGtaROcNDCHytP6evrs7xMgCL 7A21TG4DG3Je44BWcY1Mt96zlzFHBvu5XJqWrm7Hb8YVslUGlLlpT9I8xbSXQTD+CKy0 y/5NJEHm1VwXcL+0dmxJkySNfnRNzuEY0VAdBSbwIpA4HZq/i4nW4If4pku+MyXDh8hY Ag+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IXbWU0Ay; 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 f17-v6si16086017pfa.123.2018.11.11.15.09.54; Sun, 11 Nov 2018 15:10:09 -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; dkim=pass header.i=@kernel.org header.s=default header.b=IXbWU0Ay; 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 S2390813AbeKLI60 (ORCPT + 99 others); Mon, 12 Nov 2018 03:58:26 -0500 Received: from mail.kernel.org ([198.145.29.99]:51200 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390163AbeKLIWE (ORCPT ); Mon, 12 Nov 2018 03:22:04 -0500 Received: from localhost (unknown [206.108.79.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 967CC2241B; Sun, 11 Nov 2018 22:32:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975527; bh=0GvoLWeBF7BhuYJ0kGeqZyLu+qji5apaBmK+OWK+uuo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IXbWU0Ayww0zcSQZuvYd2TryDsWUh8JhJCdPn2m/vRCGjZZI+ooIkG4TVzl7MOE0E EdLUEgytOwUocaBiLeQs+W7F2AOJCXiGC1plPDouB+fYXwSs5JLDhWg+dwOfulcejf j7UvYk7Gxew7lD+EJy+eJp9ST9NE7axFQbs0uoWo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Waldemar Rymarkiewicz , "Rafael J. Wysocki" , Viresh Kumar Subject: [PATCH 4.14 007/222] cpufreq: conservative: Take limits changes into account properly Date: Sun, 11 Nov 2018 14:21:44 -0800 Message-Id: <20181111221648.560775246@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221647.665769131@linuxfoundation.org> References: <20181111221647.665769131@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Rafael J. Wysocki commit da5e79bc70b84971d2b3a55fb252e34e51d81d48 upstream. 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. Fixes: abb6627910a1 (cpufreq: conservative: Fix next frequency selection) Fixes: 00bfe05889e9 (cpufreq: conservative: Decrease frequency faster for deferred updates) Reported-by: Waldemar Rymarkiewicz Cc: All applicable Signed-off-by: Rafael J. Wysocki Acked-by: Waldemar Rymarkiewicz Acked-by: Viresh Kumar Signed-off-by: Greg Kroah-Hartman --- drivers/cpufreq/cpufreq_conservative.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/drivers/cpufreq/cpufreq_conservative.c +++ b/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;