From patchwork Fri May 12 09:57:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Luba X-Patchwork-Id: 93088 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp4982515vqo; Fri, 12 May 2023 03:09:45 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7FluY6YKkQKujm3yoo6fiB10WhT/H+LCvHzpjUEvIRGkncH2er7b75Fq3iigRiOnLwXf3D X-Received: by 2002:a05:6a00:1141:b0:646:5041:9729 with SMTP id b1-20020a056a00114100b0064650419729mr20158652pfm.0.1683886185216; Fri, 12 May 2023 03:09:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683886185; cv=none; d=google.com; s=arc-20160816; b=MzCYKUs5VveZdwC6F3ymS82gCxnInOAOxXcTUFsyHFpUnprLuDGfQaYe7+A1Q1mHMC RbsFu74NdzmMDfTeNrqnayuw+6kfrJCeLO02kB/fNxFvdYA1TrEBPhUmiKFp0yBr+S6R pPISdY2Y5U7Pny3sJhQ+ps83sR53pOLjfl++s87jtLnj7sUbWm49D7MVZqm4bA0XLxmH 6DN+UXwfUScCAcjj//qk2GD/GRpRzlWutSdtgrkZ55qjxWUfU+QTf25o7SgBdbn6hKdk TdlHwiUmZ+VuANpjZmraD/SCN6u2qKrBg1oTOnC+xqxZRAXmvo2y5B8tvGbqshREvBi6 C+bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Y4XzLzFEBkmBIZ7liKgVa14SGG6rZUs6SI41g8yG728=; b=zCoIlbYxQf/vKmmct7l4edc2SkKopg1L8gPmoLM0M0OSLC/JaQSALn/exIst3l3yDF KK3GLteoRnbe1PRl7ozvEo1u8mwjaL4JT3gGebym0GlD5B63JJaVqFtxzg8E8a9cAF1T LTurcnQL+uC3q2+eD95dY5JPcCY/16h/2xAp+UZX9eZSDWQthU+fHGzGNCSYVLVUB7Ng XyWPE6zYoiDy/e7ZOUIJ3zQsFgtexJnHchwLNMVN0vIJT8FzhdK3cbi4d5IrnD9ofCKb FDIWLRsVvMviQoYF6YKVgbMmHVezQK8Wn32VlOgmZHQ6vYdcKvltzD4wd68AfkM+giB5 oW5g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j13-20020a63cf0d000000b005139e5df68asi8803524pgg.433.2023.05.12.03.09.30; Fri, 12 May 2023 03:09:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240587AbjELJ76 (ORCPT + 99 others); Fri, 12 May 2023 05:59:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239962AbjELJ7O (ORCPT ); Fri, 12 May 2023 05:59:14 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BB49712E89; Fri, 12 May 2023 02:58:46 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2FA55165C; Fri, 12 May 2023 02:59:27 -0700 (PDT) Received: from e123648.arm.com (unknown [10.57.22.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id E4FBC3F5A1; Fri, 12 May 2023 02:58:39 -0700 (PDT) From: Lukasz Luba To: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rafael@kernel.org Cc: lukasz.luba@arm.com, dietmar.eggemann@arm.com, rui.zhang@intel.com, amit.kucheria@verdurent.com, amit.kachhap@gmail.com, daniel.lezcano@linaro.org, viresh.kumar@linaro.org, len.brown@intel.com, pavel@ucw.cz, Pierre.Gondois@arm.com, ionela.voinescu@arm.com, rostedt@goodmis.org, mhiramat@kernel.org Subject: [PATCH v2 15/17] Documentation: EM: Add a runtime modifiable EM design description Date: Fri, 12 May 2023 10:57:41 +0100 Message-Id: <20230512095743.3393563-16-lukasz.luba@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230512095743.3393563-1-lukasz.luba@arm.com> References: <20230512095743.3393563-1-lukasz.luba@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765682640677232461?= X-GMAIL-MSGID: =?utf-8?q?1765682640677232461?= Document the new runtime modifiable EM design and how it can be used. Change the last section layout and allow to provide another example how to use this new API in a driver code. Signed-off-by: Lukasz Luba --- Documentation/power/energy-model.rst | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Documentation/power/energy-model.rst b/Documentation/power/energy-model.rst index e97c7f18d8bd..64c2462dc9a6 100644 --- a/Documentation/power/energy-model.rst +++ b/Documentation/power/energy-model.rst @@ -89,6 +89,26 @@ due to the workload instruction mix and data set is not modeled. Also static power which can change during runtime due to variation of SOC temperature is not modeled in EM. +2.2 Runtime modifiable EM +^^^^^^^^^^^^^^^^^^^^^^^^^ + +To better reflect power variation due to static power (leakage) the EM +supports runtime modifications of the power values. The mechanism relies on +RCU to free the modifiable EM perf_state table memory. Its user, the task +scheduler, also uses RCU to access this memory. The EM framework is +responsible for allocating the new memory for the modifiable EM perf_state +table. The old memory is freed automatically using RCU callback mechanism. +This design decision is made based on task scheduler using that data and +to prevent wrong usage of kernel modules if they would be responsible for the +memory management. +The drivers which want to modify the EM values are protected from concurrent +access using a mutex. Therefore, the drivers must use sleeping context when +they want to modify the EM. The runtime modifiable EM might also be used for +better reflecting real workload scenarios, e.g. when they pop-up on the screen +and will run for longer period, such as: games, video recoding or playing, +video calls, etc. It is up to the platform engineers to experiment and choose +the right approach for their device. + 3. Core APIs ------------