Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2527800lqp; Mon, 25 Mar 2024 01:13:09 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWkx5GkirU1vy8uqABaWjPb1u5G/CeeJKt08LwKzyGsP5+ImJc9HiqoTvKy3VR2a5vGbQkY9xp3PxtDujTVuhQjKzl9nXhdLfTHz42qJg== X-Google-Smtp-Source: AGHT+IE7I6zbfL0OVwIg+jEn6KrhmW2+Ffg8P9itrVWYcmkmlAxgN5PYBGlcD0EV7mUGZGW19iGZ X-Received: by 2002:a05:622a:14d1:b0:431:1b54:3afe with SMTP id u17-20020a05622a14d100b004311b543afemr8345280qtx.65.1711354389464; Mon, 25 Mar 2024 01:13:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711354389; cv=pass; d=google.com; s=arc-20160816; b=ly9Wm2X8+D4z+BnVOck9zV4VHMMQLnGE6uyuTCFRsTR62AbarQSzkiU3/I5UwdtcKq vGLh5nmio1KBcWYXa4Fckq8Cvd8bJvrhTg8cEhGKctkBYAYq99hkLMm0TzcDaix6t+IW fcSOmULTHI2sBrVX1lvek7sjg/8e2swMWUnyi9mvCsHeB4UZEKB4FbdCQm0J5mqJOGDO /prMhT+429m4LQL0z2J6v/JhAJvlamB5BzCd/yukSeuqmUMH2fLLgPaDMkO/P9voCqBl zx8P09cEQF4g/7WWv3DbpwyZYRYadc/MMQPGowpcTd4obANEjZJG2OiAt042bBlQJBti QYig== 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=gSelrNnJlY98Yrtxxxj4/SGP26mg3DgJ/NYdExusw8c=; fh=E1lN7e0yjzCNgT44lRgb37g7i9cM2Wwl2dGjk+wbVZI=; b=DYwoF02Ch5UeI5Sjq7yXxn6LLXBKNvO6tTYxWK0BedL2X0unO81GW5nO+5ZgNb4z3b 28TDyEnnvzcgJ9PeikCaomIcmmjJ8EEHICL3Vz6QMlOXDti9l/MIiW1iG09X8Cm+O+Xm oqqYO00SXuDyaYP0VWdrIhfuvwCAcWe9/kdFnHCCOxnKDkh3XWBdal71yVoz8UQjaZwz l5QLMU2gZHIL5UdJW3lcyUt4xQ9GoNkCBK5VmTpU+nqRbTocux7efTQ2VgYFnE0NuzbT e3ldonrD/EZR7xjNc3SslAQ8eAWAU5Pjem65+3kNnJ3Wr7gx9CKqqGmrII0zCDaXL3qB T93w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Nxjstq+I; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-115989-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-115989-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id b9-20020a05622a020900b0043134197952si4859076qtx.341.2024.03.25.01.13.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 01:13:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-115989-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=@kernel.org header.s=k20201202 header.b=Nxjstq+I; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-115989-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-115989-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 3436A1C2F5F1 for ; Mon, 25 Mar 2024 08:13:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7BC92399900; Mon, 25 Mar 2024 03:05:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Nxjstq+I" 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 97D9B15EFA6; Sun, 24 Mar 2024 23:18:42 +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=1711322322; cv=none; b=sBsI55FbzEMmCsqNmoFZJYYHoRqbC2dcWb4K6bgh7GfeF2oaRjT+jznRJ819JFwNVkyxaR2JK33Nn/8AFXmNFZlqHaeaqhE5HsFQ7dNVpc/EsZTiWUnenowoppykuWrOVCRxWy4BCAkQZoK5WaAnq8JlAhp9tkcbWcM+XxgFsxw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711322322; c=relaxed/simple; bh=/q7kX7w8e2y4D3v/bVrOi9LBx7ZC0xSu+jKkWdgha84=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y8s9P9PHTe6IjF3us3TQxlf05YXiEX5UkKRRNPadFAZRdMe3hv8e/kC08ud5UjBFNqYgH+Xs+uujYXuVlPS1dohdq0ZiogaVEVmwfpJ6JLVxA4WyI9SNWqpk4giMwwMt2hS+e8up3LcVbyCxTnI3BjtshMJCFSNrDddHG0LHZNk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Nxjstq+I; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id C2726C43390; Sun, 24 Mar 2024 23:18:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711322322; bh=/q7kX7w8e2y4D3v/bVrOi9LBx7ZC0xSu+jKkWdgha84=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Nxjstq+IIPQv+TJdgu3xFlQaTTdCUFpBXzpMajeV3jV6TLapvNjGhlfQoXyjk0Rg4 zCktU8umfgVOmGnH2ll5CdzJijZji3x17aMh3UfF0wXimRXcvOK8jDBQOkTOJDiEBh tWk9Cdy4xA2aNvdK+WKa1ifdSFLjcCSemUekGhcefOqDH5Q73vNPsHBVGvhqsvVkLe aC3lUn1ABM5ZZHF6/j6bVrjGs0n+uLefWuFL3ZgXSjjkjsQbCKf9otTy4WOls1BqDF 8ZkPzw4uNW0a7yiwcXrsmBQAz0E2HQCJ7+oQHYGMMxYe7WgcKRec9dB4yhDxOTLaRh 6rE+Z6CgSEXyw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Mete Durlu , Heiko Carstens , Christian Borntraeger , Sasha Levin Subject: [PATCH 6.1 405/451] s390/vtime: fix average steal time calculation Date: Sun, 24 Mar 2024 19:11:21 -0400 Message-ID: <20240324231207.1351418-406-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324231207.1351418-1-sashal@kernel.org> References: <20240324231207.1351418-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 9436f3053b88c..003c926a0f4de 100644 --- a/arch/s390/kernel/vtime.c +++ b/arch/s390/kernel/vtime.c @@ -210,13 +210,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