Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2958371pxa; Tue, 25 Aug 2020 07:55:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwvApNJE5zy5+cJvD9VO1ngpG6a4m/SmU5PijFypTz5Zpg4vfwhPhFBOJ4NjX1aj3Trjkoi X-Received: by 2002:a50:aaca:: with SMTP id r10mr9411116edc.307.1598367324732; Tue, 25 Aug 2020 07:55:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598367324; cv=none; d=google.com; s=arc-20160816; b=x6kJofJY8HPPuvY4ezNewJ9AOXwajlsH1RQVTOg6FiD0YphUX+tPM2eBk3D+Tq4l4a G79axYFz0haAcfkf9WGoObHT8m+gkRvK+gOOA0e/oETXiPOoqxyayXMBJ+MSUdcXiZ9j NuzZ4I/kgihDl1vE7YSEGkDm7Fw4aOMk/oiGCkS8Da7mhMsl01bHEVcbeLXsczL1j+Nd /KOIv0r9hLB2Ae/FuTJog6nQZuzkys65jzc5cTiwNOKsCmLB+KhjeadwS0J1KTh32FgS FtoI2C97vvT/pywhdHo8uEg/Rrk8kCebqJecBBJAGdYr1nX7YRLIKUsbgQd+JdM0S8oL S1UA== 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; bh=+ylVPg9/PXce4pT2IR4gKle+fSVW1ZRt1vDCYod4rN8=; b=FdgUhiTYDDxw8zpZAmn2CMsli1Oi03Lt/q/l6BkQn9IJUlwqJCQ4r8EfN5hVbqoc7y g4npe6kpSZAC6Xh43aVU/B+l8FYTE/bP0ULbMqjAAl8bKAseGBLiLO8zv0+gZ7zfzp1y PUZvOfV3vfjYZ0FFgP7/GJIOvx8gRGXPu2+AIPBjRfq/e+rJo9aKVX03SzkhBbBiIHFp M58GD6MQLO5B3JnkxuC9KVLM4wzamHBKxEzq1isTeHC84r9V6coidkOjLYlNba3JHdmu DfGuYAjh4+3SjJeAx/Ll0t86IkRAFdXpazymp0ViK1eaD4R2usTJWTkyPQ+LDbmstoc6 vPkQ== ARC-Authentication-Results: i=1; mx.google.com; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dp1si13238385ejc.200.2020.08.25.07.55.02; Tue, 25 Aug 2020 07:55:24 -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; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726752AbgHYOwB (ORCPT + 99 others); Tue, 25 Aug 2020 10:52:01 -0400 Received: from mail-oi1-f195.google.com ([209.85.167.195]:34009 "EHLO mail-oi1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725998AbgHYOvw (ORCPT ); Tue, 25 Aug 2020 10:51:52 -0400 Received: by mail-oi1-f195.google.com with SMTP id z22so11831213oid.1; Tue, 25 Aug 2020 07:51:52 -0700 (PDT) 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=+ylVPg9/PXce4pT2IR4gKle+fSVW1ZRt1vDCYod4rN8=; b=HI0uJ5ca375SW36B0Qqv9rSR83yIsIobvbzGIRzOQokQ2xOtYOF4HMA2qnS50c7/rm ilV6/LXdBsNwKLht5ZAW6hgoJddexutbxZzuDT2PU3+tHzn33mbt7Vp30EMFjMZVJaWe nHkJSPAJyuGZ4IvSVIgVGHMjF/Ai/z/M7fB6FLbV1h/r1mmoaKPWcZXZR76BOqQ/W8pt UrGWqXRS+8QqNg3MUPPE2MXmkIqa/5tag0xRTb3h8/30+0rQOxJF/g5ckiTfQkiFYYUP mJZilsuNasJxrr/OtcZVf/gQfzuSkgPGUf2NgYEV3hO2BTrcHsrzPUMNcBcVXKUQzZpx lYdw== X-Gm-Message-State: AOAM532xjSD7xyK7iPzJX3gfTvKc9kNOwfKWAVTFHhklDXWNvq7k4ksq dR4U3xXPrCDG7tAy1os2lUNSTOuA48x+mOQORhQ= X-Received: by 2002:a05:6808:3d5:: with SMTP id o21mr1287215oie.110.1598367111572; Tue, 25 Aug 2020 07:51:51 -0700 (PDT) MIME-Version: 1.0 References: <4169555.5IIHXK4Dsd@kreacher> <2064342.aRc67yb0pC@kreacher> <61ea43fce7dd8700d94f12236a86ffec6f76a898.camel@gmail.com> In-Reply-To: <61ea43fce7dd8700d94f12236a86ffec6f76a898.camel@gmail.com> From: "Rafael J. Wysocki" Date: Tue, 25 Aug 2020 16:51:40 +0200 Message-ID: Subject: Re: [PATCH v2 2/5] cpufreq: intel_pstate: Always return last EPP value from sysfs To: Artem Bityutskiy Cc: "Rafael J. Wysocki" , Linux PM , Srinivas Pandruvada , LKML , Doug Smythies 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 Tue, Aug 25, 2020 at 8:20 AM Artem Bityutskiy wrote: > > On Mon, 2020-08-24 at 19:42 +0200, Rafael J. Wysocki wrote: > > From: "Rafael J. Wysocki" > > > > Make the energy_performance_preference policy attribute in sysfs > > always return the last EPP value written to it instead of the one > > currently in the HWP Request MSR to avoid possible confusion when > > the performance scaling algorithm is used in the active mode with > > HWP enabled (in which case the EPP is forced to 0 regardless of > > what value it has been set to via sysfs). > > Why is this a good idea, I wonder. If there was a prior discussion, > please, point to it. > > The general approach to changing settings via sysfs is often like this: > > 1. Write new value. > 2. Read it back and verify that it is the same. Because there is no > better way to verify that the kernel "accepted" the value. If the write is successful (ie. no errors returned and the value returned is equal to the number of written characters), the kernel *has* accepted the written value, but it may not have taken effect. These are two different things. The written value may take an effect immediately or it may take an effect later, depending on the current configuration etc. If you don't see the effect of it immediately, it doesn't matter that there was a failure of some sort. > Let's say I write 'balanced' to energy_performance_preference. I read > it back, and it contains 'balanced', so I am happy, I trust the kernel > changed EPP to "balanced". > > If the kernel, in fact, uses something else, I want to know about it > and have my script fail. Why do you want it to fail then? > Why caching the value and making my script _think_ it succeeded is a good idea. Because when you change the scaling algorithm or the driver's operation mode, the value you have written will take effect. In this particular case it is explained in the driver documentation that the performance scaling algorithm in the active mode overrides the sysfs value and that's the only case when it can be overridden. So whatever you write to this attribute will not take effect immediately anyway, but it may take an effect later. > In other words, in my usage scenarios at list, I prefer kernel telling > the true EPP value, not some "cached, but not used" value. An alternative is to fail writes to energy_performance_preference if the driver works in the active mode and the scaling algorithm for the scaling CPU is performance and *then* to make reads from it return the value in the register. Accepting a write and returning a different value in a subsequent read is confusing. Thanks!