Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2605933lqp; Mon, 25 Mar 2024 04:19:36 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX7CUIkWetxVYRwYfyIP9V73cr4A00XadLWxIsItNxDrwSSK2vv035Fhxp3enk4bSo/DVrhwTaucNqruUJzCC/tHGn4YqP8UIUVT6aNWQ== X-Google-Smtp-Source: AGHT+IHrsEgWsB5oqUyzFluQzcpwG7ePsKJ+QujRYboaXfSviXApMbqeeFnVpZlyGNm0R4dNZg6T X-Received: by 2002:a17:906:802:b0:a47:1c19:9a48 with SMTP id e2-20020a170906080200b00a471c199a48mr4614812ejd.28.1711365576271; Mon, 25 Mar 2024 04:19:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711365576; cv=pass; d=google.com; s=arc-20160816; b=cchJuQQW4bAghO171Qx9uYoXqL8Gs1HqNkz7R0ienkWTESohlDLVUlu4SfSD8g8A2b x95ULxduB0Gms/X9dc7lCkP4ieXiIWJoov6kM6Re1pVERGAAxA+WAbLx5o6BVYBaUi8D EaOEftG1SLgjNfIzc6go3Eva6xd7NJk2n2u3T6unVgWBLMoFIESHfAj23ZA9WJtUrpCm g4/0AsVQvphePyjozi77SsLC49OXvq0q5cTPPpCi89iMv6htABUXL7LQ7Sfys61g3UtR tdcXzit4APdOqOwzSMN/W611RaROOt6ggOFQxvrtAL9uBVM3DqHCZD+hP4VPFR5kxVrj jZuA== 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=ab+lyx7KHxBVlQbWxWGMN1kDMLEur+5O+kwGg+tWvdHQyuWw7UuEl7HCHn6s+EEtpB BzbCBE3vCpql79jUjL+O9lvSk+Oh+E6G+xJliKQknCO/Oo+BvwOhufrBxFzmPow3313Z QKWBWr6uIQGf9oanJbOKFy8MEek7/on+AVftvcUWrnX4eV8rGYzSVrLGeDKOh/oqXXzH 5nSdJWK7c8zSKPU3LbD95uJWqfbHmTqDJRvc8oXKkGE8XomP4mOYLA+6smoEex79nF8M CrCcz3zmquVxHaLXlvtswl2azpB1+0YJ5oWdC7dQ+Uc/SjPwMOxBGZ/wQwdR62e1xw/3 gUlA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=exXZorgK; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-115560-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-115560-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. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id kv6-20020a17090778c600b00a439ab2bbb9si2439405ejc.284.2024.03.25.04.19.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 04:19:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-115560-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=exXZorgK; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-115560-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-115560-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 EE0F21F31935 for ; Mon, 25 Mar 2024 11:19:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 75E802A8743; Mon, 25 Mar 2024 02:43:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="exXZorgK" 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 968DA1F1AE5; Sun, 24 Mar 2024 22:58:05 +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=1711321085; cv=none; b=LXo4uJdLQ2ApkmAy3Jc6nP4km9MALo42m8sTLmTirgqKl4zIfOo9ohuQK7SEKcGQOdp13yiHydhro8cJpmmTgw2ot4ui6il8bX9DLrcaqmkisebiYIOElLXrqCPhccX1F27Vkn4wBAHUF+Bvctj1M1beDk/jWBLYGP6iOWa15Gw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711321085; c=relaxed/simple; bh=pIMAx/5guFWCXZz7a5DmmTIE8rbWEEKno25pg9I15Mo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Uai0CrcIz+ZlNe7sBx3ZvOdvdhf99556s3llfk7oULPp3pb0wELKbYE7uVPhtqdsPMzdtOIzNBDadPfPyOdTcwSMWJxmdEzZi/cP1VW+qNNcZycSJYLLbTYcVo7X1OThqHYh5OJfAJIViRCXuJmw0JbKPM29ITvpyJBvEjFE1Y0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=exXZorgK; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id BA629C43394; Sun, 24 Mar 2024 22:58:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711321085; bh=pIMAx/5guFWCXZz7a5DmmTIE8rbWEEKno25pg9I15Mo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=exXZorgKhtOFdh5rlX1Ds6wM+LZVCBnvfll7SdhBldW/wEbdFhrpZnMk+xtsy3IVY AsEOfBOIQcqiSRgJDb7pCdJRCiHdGCZGFJye7G0InaQibEyY4+AQXQSh6zhhGWkq00 VEsI0dLbBFiXtVd6DtQxs7NeddoSGW+w7eo0Y+RW4wT25ny4ZI2G9Chii3PFWsUScB n41vDC4GwZBRQicVrb2QKxmf1QSdK5Guh/3zJ9oWpE/bQMq/mYlFzCPdB8z6troCAz WKHEX1aOkPI5h4LB8/Bxo30IEnskjAbm0iuVbrXLGM4UOUML1+Jv8Hwq/Z8hD1fpCK 3gx5fbruVeUkw== 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.7 649/713] s390/vtime: fix average steal time calculation Date: Sun, 24 Mar 2024 18:46:15 -0400 Message-ID: <20240324224720.1345309-650-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324224720.1345309-1-sashal@kernel.org> References: <20240324224720.1345309-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