Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4773867pxj; Tue, 22 Jun 2021 07:46:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxEpVx/u0YkAWYKrfP9rPWQzpVrsAy0cferLcAjUmAYtKC9EOvjASe4+eagJHfXnn0AMeya X-Received: by 2002:a17:906:254d:: with SMTP id j13mr4500103ejb.27.1624373194707; Tue, 22 Jun 2021 07:46:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624373194; cv=none; d=google.com; s=arc-20160816; b=LW2sbJe6jloK+qm9BMvwesxMZYa320fLzkBcaju0nUqPZ4Rna+DDMvQYb6+aJr/gG6 IZ29k9ippX9mOCtx6Melz/fV4+gVHXPr8OqtauHWpRzzTF1jG0CM/oh+lVNzXZKcXQu+ xOZyo3oWheo7YhKIGyx0xsjKdpV2pP7NQSyagw+fH7GaN2RErwpB+HhnVnSdi4xdiI+g bkhSxZ0B5csLPyrszd4qteaSx4IALTN7KQXurK54aI/v7KibFzGJrPHXaeJ/CovELa+7 6wKcqWU1hm8Q0Wqpqln8xSSg2ZicbOcX0B/T6rA6kixzH4L/TrL01ohgvjpVmBfjBUSi q+Yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=XceVVVWYSn/QRpaUtGZpz57/pqLlFwPeXc0ztXrJBhU=; b=PYajp68hetgySMoRjnQAySXq/7m7m7iagVREYJnzva6KJsqAl9BHf+cXtRBEkEd1jy zKTnfUMvVOOenQIuzCSVaWLd9vYmrlrHQE+LrVrnnu4zC1t5LO3WChk30pIyHp336XA7 tXkVxmvBzTU4rot6qhkkOrALuzgnMexzuj8f8mvvK8Npu/DNV/M1kKSMcBruDY3IVZHU WFtPmInJFXwks8eHEB73EbhHpANQXyJa9NqsrfPUjKzAEG+IVfOt8iqj1A3gzKGv0zEI S0Qm4ORqVp7lL8iLKmSPQ8hrxn8ddXHnRbXvLSWUT+Uc2elmRrq6jTj7jr+givwpKW8V HkUg== 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 dq10si937902ejc.351.2021.06.22.07.46.10; Tue, 22 Jun 2021 07:46:34 -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 S232052AbhFVOqk (ORCPT + 99 others); Tue, 22 Jun 2021 10:46:40 -0400 Received: from mail-oi1-f170.google.com ([209.85.167.170]:33606 "EHLO mail-oi1-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232042AbhFVOqi (ORCPT ); Tue, 22 Jun 2021 10:46:38 -0400 Received: by mail-oi1-f170.google.com with SMTP id s17so1192275oij.0; Tue, 22 Jun 2021 07:44:23 -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=XceVVVWYSn/QRpaUtGZpz57/pqLlFwPeXc0ztXrJBhU=; b=dhDlnSd0Ci4c7Gg2feaHKRYY4OrFMNUHwO9AcjkKIwgutbqqpVluAczjoKDbnV+4ng tgob3vt1Fri8g3TWBqxFgUyeVm0fD8IRMBSRS5pHv+LI/FMns0/hAIEDmRUx/51Usk15 SQvr0rdz8qVJ5a5rGuljyxqvg7tWbyPRo5D4FJfabNBzD94SG2Uyu2z4VJgJubPAwWKg vkRasWvePikbBiEwYdow8upwc7l9ofyxm9dxwOGvvW3MdGiYd/g3o4v2bFLz8bLxIUdk Sb7DtR3iFXUgSBFmALYL3pvtqk5zwO3m+DI4/jviUIqd4N5wSTVJHcHUpVoRtiHniqhr cZlw== X-Gm-Message-State: AOAM5309UmOcLLRsz2LBAxFfacz9OgUP2gvceethbPdONI3P9XE6+B73 TRTwTQ+YnJVSWvW0uHFDRPLjCfdvXL4wqZpz1sQ= X-Received: by 2002:aca:f0d5:: with SMTP id o204mr3455379oih.71.1624373062707; Tue, 22 Jun 2021 07:44:22 -0700 (PDT) MIME-Version: 1.0 References: <20210622075925.16189-1-lukasz.luba@arm.com> <20210622075925.16189-3-lukasz.luba@arm.com> <2f7d855c-5232-ddbe-8403-db3596dcebc5@arm.com> In-Reply-To: <2f7d855c-5232-ddbe-8403-db3596dcebc5@arm.com> From: "Rafael J. Wysocki" Date: Tue, 22 Jun 2021 16:44:11 +0200 Message-ID: Subject: Re: [RFC PATCH 2/4] cpuidle: Add Active Stats calls tracking idle entry/exit To: Lukasz Luba Cc: "Rafael J. Wysocki" , Linux Kernel Mailing List , Daniel Lezcano , Linux PM , Amit Kucheria , "Zhang, Rui" , Dietmar Eggemann , Chris Redpath , Beata.Michalska@arm.com, Viresh Kumar , "Rafael J. Wysocki" , Amit Kachhap Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 22, 2021 at 3:59 PM Lukasz Luba wrote: > > > > On 6/22/21 1:33 PM, Rafael J. Wysocki wrote: > > On Tue, Jun 22, 2021 at 9:59 AM Lukasz Luba wrote: > >> > >> The Active Stats framework tracks and accounts the activity of the CPU > >> for each performance level. It accounts the real residency, > > > > No, it doesn't. It just measures the time between the entry and exit > > and that's not the real residency (because it doesn't take the exit > > latency into account, for example). > > It's 'just' a 'model' and as other models has limitations, but it's > better than existing one, which IPA has to use: > cpu_util + currect_freq_at_sampling_time But the idle duration is already measured by cpuidle as last_residency_ns. Why does it need to be measured once more in addition to that? > > > >> when the CPU was not idle, at a given performance level. This patch adds needed calls > >> which provide the CPU idle entry/exit events to the Active Stats > >> framework. > > > > And it adds overhead to overhead-sensitive code. > > > > AFAICS, some users of that code will not really get the benefit, so > > adding the overhead to it is questionable. > > > > First, why is the existing instrumentation in the idle loop insufficient? > > The instrumentation (tracing) cannot be used at run time AFAIK. I need > this idle + freq information combined in a running platform, not for > post-processing (like we have in LISA). The thermal governor IPA would > use them for used power estimation. What about snapshotting last_residency_ns in the CPU wakeup path? > > > > Second, why do you need to add locking to this code? > > The idle entry/exit updates the CPU's accounting data structure. > There is a reader of those data structures: thermal governor, > run from different CPU, which is the reason why I put locking for them. So please consider doing it in a lockless manner and avoid running this code when it is not needed in the first place.