Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2505730lqp; Mon, 25 Mar 2024 00:09:44 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVn1ci8R6zOOCerzK3sc6qb7L9drxECZZYhHAHhjyROdtRnGgEQNQUjPAhrIDY+MWclRpzbcc8YiFgl6IG99Q9LVmyDoVEh4rZL/za/oQ== X-Google-Smtp-Source: AGHT+IFR+6mkzlqtawtfQzdHg+Vz94H0WRtFIP18LCA/M0LhJOHZOpkNyj/Km1XazOXYYh0LJPRk X-Received: by 2002:a50:9b4e:0:b0:565:9e16:60da with SMTP id a14-20020a509b4e000000b005659e1660damr3781951edj.30.1711350584087; Mon, 25 Mar 2024 00:09:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711350584; cv=pass; d=google.com; s=arc-20160816; b=dkYsB/+hlkoPFJMjO2b85iiSdhp2vohiYO37QxIn37f9g3WD62wASbpe5bplYO00RG yYmHv0c8Gg8AuYMqlvSSZYcD/fxcnSp+9Z/sqK1QP3hLzieyxEqp1oKzhydZa5o3ws+l 9BHJsOnd90pBKFJdawpvmozhMjZd4ackFIeLuUUA8O/zR6FfxvUNk5JgLl/ZMJCykraB mtwlateGppnimvc2Di/5y5WfbEYqdJbk1jUP7eeKPOYIOStZxyvvN7lzpWCaduIOK5XO lgs0YiKHLBOVF1nVxP6d71dnhZ+o3NOxcWbovHbAKlnL6NCXxYwE1DA7RzfKvb8r1sSz Odbw== 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:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=nuFxlPoJXIHvBoroSKA+OIRlSLM66EEj0KhmjwbpVrs=; fh=E1lN7e0yjzCNgT44lRgb37g7i9cM2Wwl2dGjk+wbVZI=; b=F1JdhifpDIC76pntA5xPvr0lxMShTtd47qJaXBA1yzR2URZzqZBNOmokJi36So25fp wNLHS+M1X6M+SxZkRnQ9FV9RWIiIjOCKzofvwggV1T/wT5TQD5wUsFuav/XfEKX238i6 xz49gzZhqhdWhpZ14nPp+6A2BriIImaHPJ58HhbgXRJAG6fzzmGamEPuyKtbFCtKeL0E ADXJe37kDgpoxUc27bL9XRUwuHLOT2STifQATOZoDyOCtA6JPljWdAdL1MysURMWN0T4 mvlQt9Uu9ku418HfjHT+Rjz1Lo7JcCLoWW3Wujd7xmGSBmKTz35lE2Ws5whkEiPrNZPe hLUQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ONsaFkxF; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-114914-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-114914-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id r5-20020a50d685000000b0056bb595c538si2224721edi.462.2024.03.25.00.09.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 00:09:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-114914-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ONsaFkxF; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-114914-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-114914-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 am.mirrors.kernel.org (Postfix) with ESMTPS id CB3341F2EEB2 for ; Mon, 25 Mar 2024 07:09:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 39DC92D4F32; Mon, 25 Mar 2024 00:55:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ONsaFkxF" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 E54631791EE; Sun, 24 Mar 2024 23:39:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711323584; cv=none; b=gEzZJhjMyeyVoXtvH4lWyqZsa84qYIn2EZt3H6ZZVRUO+7bNXQgcTWXe7TthIxnfVXFDzi4D2I94coSTMrWEoLmEmMzaS7fbE1UMtMInbMeNg0jOVdN6mO5JljbL0JNjolq5Z1b5QQpMJuEjCBRLUwM8PCfXFgtLmZG3xgPOIKk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711323584; c=relaxed/simple; bh=B+XH0Q8cQ8IRj9cWuauv4e/6nwzU2iYes19X+eo81GE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nicNxSf2MiEFsl+AZoPxj/o8uqX08LB793Y8Vs8NrcTYGfuMwR/t2YV77u8RUH+c47F9tDHzzbLKvpdMafqGo9NBdG0e9FJfWY+H14Uld4CwK5LMD/LQu82uZJ7zT+E4ekBl1GjIXXAoJkW756GGRpc4hYztlI6+alegjHNoZ1Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ONsaFkxF; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 189DAC43390; Sun, 24 Mar 2024 23:39:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711323583; bh=B+XH0Q8cQ8IRj9cWuauv4e/6nwzU2iYes19X+eo81GE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ONsaFkxFvr3iGDJlxEgkKqwEHYiaypMbbA3YA+PVss8+We9I3aWfYDjXHzXdIRPsu eYNu78QT8RkPquG8IoHl4um+wNQhvEvgW7IR5xNFg+yfDhCV3P/fgyJHm/d41tSNXP N9kZCp5cPYK4p9Kw/rEwBnKSdoo/0xulMY3FglZ1U4GyuVTr0c17qRKglNDfo6t24/ 81/WuKT//QN+O3sVXeydT8uwQ9Hyt5uTWbUUITwShS5SQuSsJ1+3a8/6lBgiBQoCo4 tiGbhg3DWj+QTHHNpVqk61R+fO5oKdTGdYsP0B2kjxChnU+YMYJjIpfmxtmFgGWNm8 umK4dgtEY7Ctw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Mete Durlu , Heiko Carstens , Christian Borntraeger , Sasha Levin Subject: [PATCH 5.15 290/317] s390/vtime: fix average steal time calculation Date: Sun, 24 Mar 2024 19:34:30 -0400 Message-ID: <20240324233458.1352854-291-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324233458.1352854-1-sashal@kernel.org> References: <20240324233458.1352854-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Mete Durlu [ Upstream commit 367c50f78451d3bd7ad70bc5c89f9ba6dec46ca9 ] Current average steal timer calculation produces volatile and inflated values. The only user of this value is KVM so far and it uses that to decide whether or not to yield the vCPU which is seeing steal time. KVM compares average steal timer to a threshold and if the threshold is past then it does not allow CPU polling and yields it to host, else it keeps the CPU by polling. Since KVM's steal time threshold is very low by default (%10) it most likely is not effected much by the bloated average steal timer values because the operating region is pretty small. However there might be new users in the future who might rely on this number. Fix average steal timer calculation by changing the formula from: avg_steal_timer = avg_steal_timer / 2 + steal_timer; to the following: avg_steal_timer = (avg_steal_timer + steal_timer) / 2; This ensures that avg_steal_timer is actually a naive average of steal timer values. It now closely follows steal timer values but of course in a smoother manner. Fixes: 152e9b8676c6 ("s390/vtime: steal time exponential moving average") Signed-off-by: Mete Durlu Acked-by: Heiko Carstens Acked-by: Christian Borntraeger Signed-off-by: Heiko Carstens Signed-off-by: Sasha Levin --- arch/s390/kernel/vtime.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/s390/kernel/vtime.c b/arch/s390/kernel/vtime.c index f216a1b2f8257..86137029235ac 100644 --- a/arch/s390/kernel/vtime.c +++ b/arch/s390/kernel/vtime.c @@ -211,13 +211,13 @@ void vtime_flush(struct task_struct *tsk) virt_timer_expire(); steal = S390_lowcore.steal_timer; - avg_steal = S390_lowcore.avg_steal_timer / 2; + avg_steal = S390_lowcore.avg_steal_timer; if ((s64) steal > 0) { S390_lowcore.steal_timer = 0; account_steal_time(cputime_to_nsecs(steal)); avg_steal += steal; } - S390_lowcore.avg_steal_timer = avg_steal; + S390_lowcore.avg_steal_timer = avg_steal / 2; } static u64 vtime_delta(void) -- 2.43.0