Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752372AbdFOO0L (ORCPT ); Thu, 15 Jun 2017 10:26:11 -0400 Received: from mail-pg0-f48.google.com ([74.125.83.48]:35678 "EHLO mail-pg0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751673AbdFOO0K (ORCPT ); Thu, 15 Jun 2017 10:26:10 -0400 MIME-Version: 1.0 From: cee1 Date: Thu, 15 Jun 2017 22:25:49 +0800 Message-ID: Subject: What is the math behind sched_avg_update()? To: LKML Cc: Peter Zijlstra Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 885 Lines: 34 Hi all, In update_cpu_capacity(), it will calculate CPU's capacity with RT utilization in mind. Which is introduced in commit e9e9250bc78e7f6342517214c0178a529807964b (https://lkml.org/lkml/2009/8/27/209). rq->rt_avg and rq->age_stamp are introduced for tracing RT utilization in a) update_curr_rt sched_rt_avg_update sched_avg_update b) scheduler_tick cpu_load_update_active cpu_load_update_periodic (or cpu_load_update_nohz) cpu_load_update sched_avg_update Curious about sched_avg_update(), why "rt->avg / 2^n" (where n denotes periods passed since rq->age_stamp)? - It will be a big summed value if next will meet the end of current period, assuming several RT tasks are running - But it will suddenly reduce to 1/2^n if just passed several periods So, what is the math behind sched_avg_update()? -- Regards, - cee1