Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp153281rdb; Mon, 22 Jan 2024 15:32:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IF82/bBqlbcQv8cKU7LT9h8nVaC2IOBRKdNx7xMrRxKkyy4hv+oDou76t2JtSjiRKdmv7XI X-Received: by 2002:a05:6214:248b:b0:685:7c9f:1653 with SMTP id gi11-20020a056214248b00b006857c9f1653mr8841qvb.24.1705966378730; Mon, 22 Jan 2024 15:32:58 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705966378; cv=pass; d=google.com; s=arc-20160816; b=PQwC95S3JEpd73xjKmwapnw+KolBqIM1Ibsj1ulkQcfm8o8Ggs/pMM+2uGGXBbut7M k5RavhinR1kwi9L8HidQGBlqumC2erqtJvIvibxopX51nCkopNYOOP8+Jr0zCmxLXzKM Xl+mZ2s0mrbdRDEyZ96xqhjozwW9GNLCSkyYzLODBeBJ3bHPQl6RAA1lkWsOVZWUhnXQ LxTuyOx0PVbMwT5uA16fu8w2J8wG71dPbpAZhF7CQGVs6t6gHePBaGeHzLNkuo9PXpBL n2SXJwGmT8djaPsj5W4Sk8Z35QKKVhww9CKBFt6xE4Iy4iJSFUt3qZT9S48wSC/uF2bP nrzA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=xAbPUKpzV86/Kwv4whDQChRXJ51AQudCMEw5GdVatO0=; fh=2wQ+2xN0Nv2Sfk4KArDYDa+xjo+qlUBbLRtGFGS0Fs4=; b=FSSimWTbLpTYUOSCSgDsBHc1gM+TUkPfP2pu+i5Mws+vQOQ+B8PQraBWAHHyL8xQCm yGANgUi85gw1y1TETYj2cbm75NpjFhIjwr3dRKu7wCDe1LUVZj341UvfHFSX5bEU0ijQ fe+e3WWF56jyvemNl79o3BQKrLaEKqOiuIY6kZn+EgOIK+VpY57K1VHyhec43OW2O4Qn mCA8b7wwBf4i1xf/vA0qiNoqJcGkO7RwQmbPydPWnlELxCCgEmzgzr3/hYyFxpW4kCS2 JEeXae7Ouqng16qoTRsR2almoPox0avU0yfi0l1wG7hpirSJbJBII6VmcvabTLh63Npf usyw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=kAsQDr9E; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-34296-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-34296-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id u10-20020a0cdd0a000000b006805f61541csi6812632qvk.177.2024.01.22.15.32.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 15:32:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-34296-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=kAsQDr9E; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-34296-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-34296-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 7CF591C22ED5 for ; Mon, 22 Jan 2024 23:32:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9A0724E1AD; Mon, 22 Jan 2024 23:32:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="kAsQDr9E" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3DA564BA94; Mon, 22 Jan 2024 23:32:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705966370; cv=none; b=Cc+NeFNv8VBd25yYO6nMUdahuzrkQiLasjzL/bEg/nfpIsspS1Jgrpmmc3RbfOYwQQTsBipeY6BQR6GpUO96H9rsd+2kyNaEFeQuWLVxSsg9IOLQVcKcMcpDC2kiWt2mD9ozTRBC7vZQTbLl42LAnVStQOajuJCQMpJORsvC4gc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705966370; c=relaxed/simple; bh=wdogNbU04LOAOQXqJeol5FweB9QazmHCRKAJ8Y2dXfM=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=FwEO2U65fxQRFW+YYtgoOH1pnDMpX/n/ZYUH2bPDxd9+yIcFmpqqkQ6wFzLaDy/ETZ95S8iwSYpS0MLLm4rdhUI8xIt2YHEHCiU53ye7ucyzZhu4Fkz74UWTEUmRkl/3a/6t4V8fyiCKpY07gPqSDzq+bWeyKdp/UdAcBP5MLII= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=kAsQDr9E; arc=none smtp.client-ip=192.198.163.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1705966369; x=1737502369; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=wdogNbU04LOAOQXqJeol5FweB9QazmHCRKAJ8Y2dXfM=; b=kAsQDr9E18/GFTjXsp8pqQf3EoIAP5voG6vPDRjoCpC23WCDcB7ZfxiF ysuYGmW/IkFIeKPoTr8SQ4XpV/aJUAdr3SIYGCAIoZdBuAvhO6m9aJvSL 7qtDZEMVVlTjrPk7wQ1kjz36UuBgHcqs3Sr8EcaXeIWORUz0rkZnc5WHg STJ9BceFxwgydjxwxQ83geU8qQEOYpTWih7eC08utZB5RYWo6vBlEo2ut 2Mdz+hvucFEs64aujNcGN/ZKC6wMz9xWK7uFRfx4SynIFbtlj4GSxMqpM wP/8W1mtA8ETO0Bj+2EE+ljYHV0wJu3Lzq8ffcVXWwlF5SI3MsPnW+e9q Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10961"; a="8032170" X-IronPort-AV: E=Sophos;i="6.05,212,1701158400"; d="scan'208";a="8032170" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jan 2024 15:32:48 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10961"; a="1117040507" X-IronPort-AV: E=Sophos;i="6.05,212,1701158400"; d="scan'208";a="1117040507" Received: from b04f130c83f2.jf.intel.com ([10.165.154.98]) by fmsmga005.fm.intel.com with ESMTP; 22 Jan 2024 15:32:47 -0800 From: Tim Chen To: Heiko Carstens , Thomas Gleixner , Ingo Molnar , Frederic Weisbecker Cc: Tim Chen , Gerald Schaefer , Alexander Gordeev , Vasily Gorbik , linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org Subject: [PATCH] tick-sched: Preserve number of idle sleeps across CPU hotplug events Date: Mon, 22 Jan 2024 15:35:34 -0800 Message-Id: <20240122233534.3094238-1-tim.c.chen@linux.intel.com> X-Mailer: git-send-email 2.32.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Patch 71fee48f ("tick-sched: Fix idle and iowait sleeptime accounting vs CPU hotplug") preserved total idle sleep time and iowait sleeptime across CPU hotplug events. In order to derive average sleep time per sleep event, we should also preserve number of sleeps too in idle_calls and idle_sleeps. Fix that. Fixes: 71fee48f ("tick-sched: Fix idle and iowait sleeptime accounting vs CPU hotplug") Signed-off-by: Tim Chen --- kernel/time/tick-sched.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index d2501673028d..01fb50c1b17e 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -1577,6 +1577,7 @@ void tick_cancel_sched_timer(int cpu) { struct tick_sched *ts = &per_cpu(tick_cpu_sched, cpu); ktime_t idle_sleeptime, iowait_sleeptime; + unsigned long idle_calls, idle_sleeps; # ifdef CONFIG_HIGH_RES_TIMERS if (ts->sched_timer.base) @@ -1585,9 +1586,13 @@ void tick_cancel_sched_timer(int cpu) idle_sleeptime = ts->idle_sleeptime; iowait_sleeptime = ts->iowait_sleeptime; + idle_calls = ts->idle_calls; + idle_sleeps = ts->idle_sleeps; memset(ts, 0, sizeof(*ts)); ts->idle_sleeptime = idle_sleeptime; ts->iowait_sleeptime = iowait_sleeptime; + ts->idle_calls = idle_calls; + ts->idle_sleeps = idle_sleeps; } #endif -- 2.32.0