Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2401522lqp; Sun, 24 Mar 2024 17:59:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVcY5XeLyPMX5IUUozeEw1CzYy9ZpgWh4FPRLHRV1mlEy1eAxb5eXkzdIBrtAIUxNYRDGoo+yk+3xd6RtzRSNT9eCsCummW0FMr5vGkPQ== X-Google-Smtp-Source: AGHT+IEE2vFF7z5WTubAtLHZCTYHz1A5UAmQuGbkC6AfHF0fXQG+kWoYmJZX8RmUTG6nZ+kwIEiD X-Received: by 2002:a05:622a:1894:b0:431:3637:c345 with SMTP id v20-20020a05622a189400b004313637c345mr5886092qtc.5.1711328356464; Sun, 24 Mar 2024 17:59:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711328356; cv=pass; d=google.com; s=arc-20160816; b=qfRQT+WIkMb3/dNqTTUen3Fus/sbPhftehOrfOoLNEfHVdZ3yhj8hqYBNPHN7hLvG9 l5yOtdE9krU76TycUOTxlNYw4FGhaVGDg2mOss/az6T6NeW2v38ylqtspuMNYlvR6f3S mzT5S/wTryXwnI3EClOLpIf4+rZO/fjFTqPX6pLoXWn4X8L1pI0GILRnGsbPahbZia5b 1R50jAMu/Wu82aUCCaFgx/6V+w1Pk/HhQc8cZDjjYlOHk2LlQDe24Apnf7cV6udl3gPr gTihSRRox52TmjTqcup1rqyQqegyKMIT4yUj2jxENZP+cfwa9rfno+e7ZT6o1Mrm6Qsm 1K3w== 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=D/yLY3/dCObMjYtbs7qSkogdhd8kgnlkCyR8wm8RtzM=; fh=E1lN7e0yjzCNgT44lRgb37g7i9cM2Wwl2dGjk+wbVZI=; b=bPjrjoWWyZpEJKGKKHOvCvYuhAJhAIkwshyI68DOXedm32yH1uVNhe9vAHEG7x+PT2 g2C8U8PWk0ljt6rty0RC7J9vXMow/iQMktZs1SSAu9Sa6kIXAkLUsQJoP0EPbyco38fU dT5n/Rd/RJ+6GWBpxURzql7f5m601XrzskOTcxAliGeMMPa7XmetJX4NIPDt88XowaeD BYtimGtRjUeVgyssSSB9U1z6ux95HdF7slqiAILOtkXtcukCwVbFCLbtDlQRl9tLj1gO TCb7es+7+ta7Zz+1WylIT+ZJZcB+ngxhn8NvMOZiTOT7qUM888fgxv4JLEKG+4131Odf d9dw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EDYz5rOg; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113538-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113538-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 ge5-20020a05622a5c8500b004312359aa67si4386039qtb.409.2024.03.24.17.59.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 17:59:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-113538-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=EDYz5rOg; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113538-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113538-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 36A381C24641 for ; Mon, 25 Mar 2024 00:59:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B1A581C1316; Sun, 24 Mar 2024 22:45:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="EDYz5rOg" 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 C1E5E1C09DA; Sun, 24 Mar 2024 22:45:39 +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=1711320339; cv=none; b=mJ0okVEBEIHjyeK0IAv3MpBO8p8JAUE92blPCeejU3/VozIU9nYJVMnroKz+lAt5ne94RFWrqgWKjNk2YmNMZg4iumAqJRHHL97R9wIPR4lC2uBWI+fCNJCo2rRrTAT5I/Rd9Ru7xXLwKNxJOSv6HridxB4mXIzH/L1e/5YxOtc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320339; c=relaxed/simple; bh=pIMAx/5guFWCXZz7a5DmmTIE8rbWEEKno25pg9I15Mo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FSytQ3G4MAO+Cr8ptaFRbXkbpAqzJo2HucU4g5ZUEcKt/zC2BFA4WDXmj4zi6yuYEeQIPoAQqP8yYuwhELOGKVWHbV/soMdsuD5vPoXzmwZniVdQBHOUUbRl2xky5dazTMKwtlxjdwVlne0p6f4L/lkAvsaf7NAEEVuYWwbICBc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=EDYz5rOg; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E770BC433C7; Sun, 24 Mar 2024 22:45:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711320339; bh=pIMAx/5guFWCXZz7a5DmmTIE8rbWEEKno25pg9I15Mo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EDYz5rOgpHanP2McQkJP9Z4irqkvzMSwQreX12c+B3TL8fmyKnsEHUFLhcPoV5QfC XpA/gLI9eyaPKz/2F+P/oooZCLGOg1/7Jg/RFqi5c41POOdpqJnEGRCAVyM/fkJNq+ baLa1EnezaokxVUAzoUw+z3NwaI7nHR6P6yTSdJawUyaNqqTPvnhrhGrHWuuzlLRvf dfb664NgRHEgWq/3Wm7yA9AOUy4aaYU4qtmOANKSXjR0n+fF4+qYTh1kar+3nsY0Hl mwCMwyN8d+M4mp7S/Eq0itrcTdm2gqeGmekWrlIB1cMHAM55azjF6UcFpzbjp67rPG iJdy8tlc7KpQg== 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.8 647/715] s390/vtime: fix average steal time calculation Date: Sun, 24 Mar 2024 18:33:46 -0400 Message-ID: <20240324223455.1342824-648-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324223455.1342824-1-sashal@kernel.org> References: <20240324223455.1342824-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 e0a88dcaf5cb7..24a18e5ef6e8e 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