Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp1660401rdd; Thu, 11 Jan 2024 05:59:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IGaerHgPCOeZ4njLPLjjfTnBZfEF0h0J0Zmb3EkgOeDkF7st5BHaCqS8FS7m276yEeKhfEr X-Received: by 2002:a17:906:408c:b0:a28:aa2a:316d with SMTP id u12-20020a170906408c00b00a28aa2a316dmr753806ejj.59.1704981587158; Thu, 11 Jan 2024 05:59:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704981587; cv=none; d=google.com; s=arc-20160816; b=uWiWs+hbwpZ0ewW9I5/JI17wm9w15ORDHHcglEvyY0Mfhk92SVW/1ENft+eG9Ug0g2 Jp/gf4at23RFJkko3Eizzwkk/WRpo3jHauz2QzMW40uaFOa5t8ypSrqzOlRkJ8blhBdG Mh55nXJ34thaKtp0E+KAGWtvkG4o5YPwjVs5TPN4G7dHMMiME98A6AfFVDDZWwd7KCPD /A4WpsEm0fUhyXN1SLuIO56TqwxAqS+WoQ7uGuPUpd8yMMmlpGlsXcJ6Kij5Pr0uDLUI Vzq3fMyzMc5ollw4Kvfii5Mg2Q0NoqWfIQHK09PQrqJpnM3NSdoUFqqwNJibPWGg2pwl NdUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:message-id:date :subject:cc:to:from:dkim-signature; bh=ceZQ+g0HQfz+YklWq6Hsaf1JyGv0Tneq9q9AQBFCSqw=; fh=zAS72EGYhiYz2REkVX9BwzhsChOdE20/jRwc+h/sX/4=; b=vMjwUybO8vwbw+5FfY/QfGpzUBizZqWWd2LRlwZSNdJwf5vcGHM3Fma6TGAwqUYwWf e9y344ONuiYtFQWaeKRO3aq2trtVRh93S6AAu/WMZjOpKmjSZnesaQgGL5RRnEPR4ISo knGdKZVXbU/gDIuQw2z+1itvW0YwOJxcg/b1vZyben13z1GJHIv5AD4jl9KH+2briMjp 5FpgdjeWGSI//1CJbRXS/aIbmSkd2bSvyyi5LiEkob7skULaBNrzbcjrkeisfeUaX/Pf aUVh7EQhlRKy+a4G3m1TLzASoNOxUvTcFxLWc8INh3QkeiVxHJ+ftN3wu6ZGNXEGXl5n urOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ehLkLBqW; spf=pass (google.com: domain of linux-kernel+bounces-23693-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23693-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id l19-20020a17090612d300b00a28f4208352si540231ejb.740.2024.01.11.05.59.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 05:59:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-23693-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=@intel.com header.s=Intel header.b=ehLkLBqW; spf=pass (google.com: domain of linux-kernel+bounces-23693-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23693-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 am.mirrors.kernel.org (Postfix) with ESMTPS id DF7171F21948 for ; Thu, 11 Jan 2024 13:59:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9C5E53D3B1; Thu, 11 Jan 2024 13:59:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ehLkLBqW" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) (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 4C75B171B3; Thu, 11 Jan 2024 13:59:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1704981557; x=1736517557; h=from:to:cc:subject:date:message-id; bh=0UpJJ1HfJ79wY08r8lPqeB0h9S9S+PYOAwBJXQY0h70=; b=ehLkLBqW19SlxvoQnT1J7RUbxkdocrxcsiceE/AfhGIojxmJDYU/9sv1 b1cxW0CT0akTvFkBNmZFYaytokZKOwZZ8duvA80Zygax1zADmQuY9bGZ7 aPRC2zuPuImtoad2ATUd2Spp55HGlbIcHQj43l3vKbf77Jsk2UKKkEufk ancFsZRw95DdA9SV8UKdD82G2ari1yZNqQdg/tsSLXqWt+IsQqICMGdYf AxVP0/qEEarZIG5qZ0BoeR9cIRAsZKcROm+Ap+ZwwR0KvAkSnkemW0snm 1xfW05td6uLfPphQiWs/ApQAlkI2iel7umpSXsx3SPVYUbdFF07ijpuNu Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10950"; a="12340490" X-IronPort-AV: E=Sophos;i="6.04,186,1695711600"; d="scan'208";a="12340490" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jan 2024 05:59:12 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10950"; a="852958952" X-IronPort-AV: E=Sophos;i="6.04,186,1695711600"; d="scan'208";a="852958952" Received: from pasangle-nuc10i7fnh.iind.intel.com ([10.223.107.92]) by fmsmga004.fm.intel.com with ESMTP; 11 Jan 2024 05:59:09 -0800 From: Parshuram Sangle To: mtosatti@redhat.com, rafael@kernel.org, daniel.lezcano@linaro.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, jaishankar.rajendran@intel.com, parshuram.sangle@intel.com Subject: [PATCH] cpuidle: do not shrink guest poll_limit_ns below grow_start Date: Thu, 11 Jan 2024 19:29:50 +0530 Message-Id: <20240111135950.17016-1-parshuram.sangle@intel.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: While adjusting guest halt poll limit, grow block starts at guest_halt_poll_grow_start without taking intermediate values. Similar behavior is expected while shrinking the value. This avoids short interval values which are really not required. VCPU1 trace (guest_halt_poll_shrink equals 2): VCPU1 grow 10000 VCPU1 shrink 5000 VCPU1 shrink 2500 VCPU1 shrink 1250 VCPU1 shrink 625 VCPU1 shrink 312 VCPU1 shrink 156 VCPU1 shrink 78 VCPU1 shrink 39 VCPU1 shrink 19 VCPU1 shrink 9 VCPU1 shrink 4 Similar change is done in KVM halt poll flow with below patch: Link: https://lore.kernel.org/kvm/20211006133021.271905-3-sashal@kernel.org/ Co-developed-by: Rajendran Jaishankar Signed-off-by: Rajendran Jaishankar Signed-off-by: Parshuram Sangle --- drivers/cpuidle/governors/haltpoll.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/cpuidle/governors/haltpoll.c b/drivers/cpuidle/governors/haltpoll.c index 1dff3a52917d..663b7f164d20 100644 --- a/drivers/cpuidle/governors/haltpoll.c +++ b/drivers/cpuidle/governors/haltpoll.c @@ -98,10 +98,15 @@ static void adjust_poll_limit(struct cpuidle_device *dev, u64 block_ns) unsigned int shrink = guest_halt_poll_shrink; val = dev->poll_limit_ns; - if (shrink == 0) + if (shrink == 0) { val = 0; - else + } else { val /= shrink; + /* Reset value to 0 if shrunk below grow_start */ + if (val < guest_halt_poll_grow_start) + val = 0; + } + trace_guest_halt_poll_ns_shrink(val, dev->poll_limit_ns); dev->poll_limit_ns = val; } -- 2.17.1