Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp911465pxj; Thu, 27 May 2021 14:47:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy6NP5u+EclFako1gmy1GVLdDPTbvup57Pr1i5yLmfXUnNWEIS1pfDNPB44KjbJmcdRz25x X-Received: by 2002:a02:6d6c:: with SMTP id e44mr5372801jaf.81.1622152079245; Thu, 27 May 2021 14:47:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622152079; cv=none; d=google.com; s=arc-20160816; b=wanyGpMgNnt1dYYtpl3s9amPeyX47Sq4QWPsN09oO4aDfDEUI2tz9//JLw3qAC5840 Rd8m8Vki2AbaYxwGHIIG5EN09W4TQP4pVPlPlMKacuNBtBn7LiGBI4XqbXlu1Fzrwn6f VpvogrlLGhmhRXWQ8o9QLKkfB0dLd2sHMzjGiV6siXUXLVs98FGzT+gvmFdOmGhbHpJy ZkXIxibbO/omGYVaR/J6C6NlIsYddi4TqEl/f1jWFojNMVJLXc43AtR8sngXhnHHo+ni zaF6YulZGBwIg8p3mVeg9RPvn5pEtb+LHmXJTyxxYAkzXQ0Shun4pN7Jr2Ed45PSkyzX FZ3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=e7TuQas5vOB/Qm5x2DGjiF8GlZabAcszpDODVb/SURQ=; b=05Gb/BbMFOO5LUhNXHSo+H2sh2j86lprmMgQvxbj/BrYHV09LQTnkIlMSjJM5dtZOc ePDqhZSEylKmuRPB3pbS9FANgSXNG4nzp/BEuL8OYqwL4Tha69ZF524clPaZ2h4QxW1F 8JbR3W+33LTdJARJ2D5KNd2jwZSiHCUPOEQbOs6/lydEsjx4Krp98NPZrjs40W0st0pm a1OCTio0pFmH7lHSRE0HL0JChX0jVQtd5guCcxHSDBNvAwuz0r9WbLD5PaiSxewmw2kE tP9M8FBBC7jpldl1LJApmJRvNbt9j/dFpD8X3TfbOhsUaxQhSkQkzK3bYcAKNENGYrU9 xdhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tMqNjOC+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z13si3551449ioi.0.2021.05.27.14.47.45; Thu, 27 May 2021 14:47:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tMqNjOC+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236935AbhE0PQL (ORCPT + 99 others); Thu, 27 May 2021 11:16:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:43926 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236990AbhE0PPV (ORCPT ); Thu, 27 May 2021 11:15:21 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D476561358; Thu, 27 May 2021 15:13:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622128427; bh=vbYEyiu46r8f7LglZL8phVdZXdj3Uoh7h2G8G9S/Dik=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tMqNjOC+z8lz7uceVAx1u/mzhbQB5lmiV9SUlxxv42Lj97CjBbdagqVvc6/RTC0Sk KgYPBEn31CPHqqOfnURoZxKv3jtXyRnCFhXREBuxnWoYYg73RWq3Mc1z87dr34tVnY FABVnTmYbOScyjV0y0e7NsVNhLE0A7G0t0BykroY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thomas Gleixner , Wanpeng Li , Sean Christopherson , Christian Borntraeger Subject: [PATCH 5.12 5/7] context_tracking: Move guest exit vtime accounting to separate helpers Date: Thu, 27 May 2021 17:13:06 +0200 Message-Id: <20210527151139.413722748@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210527151139.241267495@linuxfoundation.org> References: <20210527151139.241267495@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wanpeng Li commit 88d8220bbf06dd8045b2ac4be1046290eaa7773a upstream. Provide separate vtime accounting functions for guest exit instead of open coding the logic within the context tracking code. This will allow KVM x86 to handle vtime accounting slightly differently when using tick-based accounting. Suggested-by: Thomas Gleixner Signed-off-by: Wanpeng Li Co-developed-by: Sean Christopherson Signed-off-by: Sean Christopherson Signed-off-by: Thomas Gleixner Reviewed-by: Christian Borntraeger Link: https://lore.kernel.org/r/20210505002735.1684165-3-seanjc@google.com Signed-off-by: Greg Kroah-Hartman --- include/linux/context_tracking.h | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) --- a/include/linux/context_tracking.h +++ b/include/linux/context_tracking.h @@ -137,15 +137,20 @@ static __always_inline void context_trac __context_tracking_exit(CONTEXT_GUEST); } -static __always_inline void guest_exit_irqoff(void) +static __always_inline void vtime_account_guest_exit(void) { - context_tracking_guest_exit(); - - instrumentation_begin(); if (vtime_accounting_enabled_this_cpu()) vtime_guest_exit(current); else current->flags &= ~PF_VCPU; +} + +static __always_inline void guest_exit_irqoff(void) +{ + context_tracking_guest_exit(); + + instrumentation_begin(); + vtime_account_guest_exit(); instrumentation_end(); } @@ -166,12 +171,17 @@ static __always_inline void guest_enter_ static __always_inline void context_tracking_guest_exit(void) { } +static __always_inline void vtime_account_guest_exit(void) +{ + vtime_account_kernel(current); + current->flags &= ~PF_VCPU; +} + static __always_inline void guest_exit_irqoff(void) { instrumentation_begin(); /* Flush the guest cputime we spent on the guest */ - vtime_account_kernel(current); - current->flags &= ~PF_VCPU; + vtime_account_guest_exit(); instrumentation_end(); } #endif /* CONFIG_VIRT_CPU_ACCOUNTING_GEN */