Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp586634ybk; Wed, 13 May 2020 07:54:23 -0700 (PDT) X-Google-Smtp-Source: APiQypKfU2RDEES2g2mYLWAo3kuLE5kgs1hmXe31sOTcn8Mm1tzjoFRAiCIE9LWoBa/f5PxoXRnr X-Received: by 2002:a17:906:d7ab:: with SMTP id pk11mr18336947ejb.280.1589381662868; Wed, 13 May 2020 07:54:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589381662; cv=none; d=google.com; s=arc-20160816; b=iu2b/BzjrkslanE+L6K7TdSsiX+8bJBvAf6IAErC7wdzrUa9R2rvPKc/k7M2WByj5v BsIe8x+BQtOhRTxSVdGpwgaNprbI95W9F7o6IjJZ2o97nCCT12pzQyQLt3X7ttGWcw8r 7YOTLEvDkh8ypwR+S0KFQxbPMX7E0ApPTCf5SyPyg47uDjkG/wklHou26LUQ+QF89sZL CPGX7ahfdGR3++uxtNUOn6B3+6ZCZIXpw807OWmG/UflLvQEiTX9BfEnRzXghBoq9LLb Cx8wR3pUXx3iItXMN0I1aeu/wJc2Kr/zJ96eo0m+rlyBb3JUaKixWim1Eg5bMKyOUqnG VQ/w== 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=SAbLyrX15xBugrHqLh1DzP9lO+IcFmGTTH9e2AAiAfE=; b=BplL4n6s/ngvwHNdtuMnptxwjJFhA0Xiut+bW0YrFbQnGpBHJbGz+5mifTGZmDM29V n9GFZ6MzeCkk/9Ndim1BEK8sCFhJAOl44zjyIwswXZ6sKifUvBrQMIoH+PacscenUREf +s4NMB7xgfOkwmmMFxVzXe7j2Em6/+FGtrZJUbBxeM+yXASEEWk9bzCmyEXBBakGqKJg xYhDIawhmTdCNK69udBnKke2A7Q2+SFRiEWf0APhpMn/o+taRu2sFqcopCr4uzZcrqMR qswS1d5fH/UkbrL+YqZYDIfbjwjISrQweBfk6syyw9tlKimjwMLIDyj7SK/KDPZLKuES GfUQ== 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 w5si9385762eja.332.2020.05.13.07.53.58; Wed, 13 May 2020 07:54:22 -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 S2389047AbgEMOuB (ORCPT + 99 others); Wed, 13 May 2020 10:50:01 -0400 Received: from mail-ot1-f52.google.com ([209.85.210.52]:35778 "EHLO mail-ot1-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728345AbgEMOuA (ORCPT ); Wed, 13 May 2020 10:50:00 -0400 Received: by mail-ot1-f52.google.com with SMTP id k110so13605973otc.2; Wed, 13 May 2020 07:49:59 -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=SAbLyrX15xBugrHqLh1DzP9lO+IcFmGTTH9e2AAiAfE=; b=jYcXQOoF0Cu8lVuybGoomKrhrgs0ZOHM/5Myyw9zJJ6hitYZq0aVOl20BIlr0+i3s2 3yxMrjUo2CT8eHBgKuJmCkEpSGAXCYx4YDX+2haWOxOeKJjMRsKU37XWrS2zf6zl8v83 HC3QzHZemdenyoXz92xeMkMu1h+djoetJmvSlciV0kLg9/yPZA8WmYIk/UNwzL4HCk3v OGdY8VIeRmETlkF+ZqnHcvsnQt6cK9ps9lp1/0yh0KiclAXCWC2P1+nArNRf0YqErn9U AFiFyydpctPfP6Motq7O0fMRYhMru8wXXfGHOuA0k8xNazcciYS1qaoC2S0CeiJiToHv XXeA== X-Gm-Message-State: AGi0PuZzGgMIF2KMJvOoY1fMKWkiIY6RbamobSNRZXUNCUzMfOIqeLFM pWEumSpxRLleR+cRS+UK9Oy9/wGI/Ftwup8gPOw= X-Received: by 2002:a9d:6356:: with SMTP id y22mr7737375otk.167.1589381398522; Wed, 13 May 2020 07:49:58 -0700 (PDT) MIME-Version: 1.0 References: <20200511141055.43029-1-psampat@linux.ibm.com> <20200511141055.43029-2-psampat@linux.ibm.com> <20200512173722.GM2978@hirez.programming.kicks-ass.net> <09b8bf40-e371-e1eb-d77e-6c676f22dd29@linux.ibm.com> In-Reply-To: <09b8bf40-e371-e1eb-d77e-6c676f22dd29@linux.ibm.com> From: "Rafael J. Wysocki" Date: Wed, 13 May 2020 16:49:47 +0200 Message-ID: Subject: Re: [RFC 1/1] Weighted approach to gather and use history in TEO governor To: Pratik Sampat Cc: Peter Zijlstra , Linux Kernel Mailing List , Linux PM , Rafael Wysocki , Doug Smythies , Daniel Lezcano , "Gautham R. Shenoy" , Vaidyanathan Srinivasan , pratik.sampat@in.ibm.com, pratik.r.sampat@gmail.com 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 Wed, May 13, 2020 at 7:31 AM Pratik Sampat wrote: > > Thanks for your comment. > > > On 12/05/20 11:07 pm, Peter Zijlstra wrote: > > Just a quick note.. > > > > On Mon, May 11, 2020 at 07:40:55PM +0530, Pratik Rajesh Sampat wrote: > > > >> + /* > >> + * Rearrange the weight distribution of the state, increase the weight > >> + * by the LEARNING RATE % for the idle state that was supposed to be > >> + * chosen and reduce by the same amount for rest of the states > >> + * > >> + * If the weights are greater than (100 - LEARNING_RATE) % or lesser > >> + * than LEARNING_RATE %, do not increase or decrease the confidence > >> + * respectively > >> + */ > >> + for (i = 0; i < drv->state_count; i++) { > >> + unsigned int delta; > >> + > >> + if (idx == -1) > >> + break; > >> + if (i == idx) { > >> + delta = (LEARNING_RATE * cpu_data->state_mat[last_idx][i]) / 100; > > 100 is a crap number to divide by as a computer. We bio-puddings happend > > to have 10 digits, so 100 makes sense to us, but it does not to our > > binary friends. > > > > > Absolutely! I just wrote the code exactly the way I did the Math on paper, > definitely need to figure out an optimal way of doing things. There is no particular reason to use percent in computations at all. You may as well use 1/1024 parts instead (and then use shifts instead of divisions).