From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EE39FC433F5 for ; Tue, 28 Sep 2021 22:04:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D3AA26136A for ; Tue, 28 Sep 2021 22:04:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243020AbhI1WGg (ORCPT ); Tue, 28 Sep 2021 18:06:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242929AbhI1WGe (ORCPT ); Tue, 28 Sep 2021 18:06:34 -0400 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD685C061749 for ; Tue, 28 Sep 2021 15:04:52 -0700 (PDT) Received: by mail-pl1-x635.google.com with SMTP id j15so88071plh.7 for ; Tue, 28 Sep 2021 15:04:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=s8TgaTkuAOfttq5Ji23XuWmZEPg/t1pbW45rjrv+GjY=; b=LOKBGSSThTGJmZr52wMlTVIXy7gN0kcixsV7n11azJM+wFcpy4hdoZIRhH6FjCUukF R3ek08fGm45mGkuiA0+Kxm49I86GkQOabdwCzh/L7J8ZtTUESfVtBd1ViQEJJ5vZmB0j gVM3+sKMqY01a6pRSxMH/JV7N2k8jZaoTStvXT/CW+6ekMegbYoSEeVNZm/knJC1H2Iz JpHolIs35AjaAocSgJu4Q8l0875P6gOMqZFX8yYi8BLrJDNQk0tBeB5SUgTVoQJk7Bxc TaQ1FhIIJDiukqtBzIRTPyLdyC5LfChFTqz2xnOAHZ/G/Ty6/PTiLDypDINxMIzqkG+p MNEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=s8TgaTkuAOfttq5Ji23XuWmZEPg/t1pbW45rjrv+GjY=; b=NnO9UtUVRtEZn8CLoh3x1Z8c13jIPfhVEu6gqzuvzsZFvJ7IMqjjEousoprCh1D/E1 u7oZGbfY0z1htzLCOH0zhgP4SQxbz9xta00gQy8ZaL0Z9wckOmE45HGoDMjG11+sB31M JN7gVU0bhjsTfkVH1xpm5mJycPgyw+RDbmIYBreR3AcekD77X4Sb2DkfVXpP4cZXVMeZ /A8g2932GMRZ3tsnof4T4R+qGWCTFlwWJtyABypM2EKACzo+JcE5GRMhjMdQxbncX0GS xgWNzg9tcrA624HxOo2iIUgF8ntPgKVxQJK5AW4J4mTw+lAKgWi5T8CEHSjjnfEk+r79 8rPw== X-Gm-Message-State: AOAM532yGVcU+r6VIA7ak6vk01fq3WSY0hPDf1pk2xDwo8qcMacTqAON 0kSYsqnn+c1ylhbKKLNBZzpXgw== X-Google-Smtp-Source: ABdhPJyZYZhKpQUljc7RVXwKUERY34mYmQfs2NuJ723fR6n2a6r5wthdOfaTSfpkU7ajTH5d6X1x0g== X-Received: by 2002:a17:90a:c982:: with SMTP id w2mr2466336pjt.30.1632866692006; Tue, 28 Sep 2021 15:04:52 -0700 (PDT) Received: from google.com (254.80.82.34.bc.googleusercontent.com. [34.82.80.254]) by smtp.gmail.com with ESMTPSA id v26sm124276pfm.175.2021.09.28.15.04.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 15:04:51 -0700 (PDT) Date: Tue, 28 Sep 2021 22:04:47 +0000 From: David Matlack To: Sean Christopherson Cc: Marc Zyngier , Huacai Chen , Aleksandar Markovic , Paul Mackerras , Christian Borntraeger , Janosch Frank , Paolo Bonzini , James Morse , Alexandru Elisei , Suzuki K Poulose , David Hildenbrand , Cornelia Huck , Claudio Imbrenda , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-mips@vger.kernel.org, kvm@vger.kernel.org, kvm-ppc@vger.kernel.org, linux-kernel@vger.kernel.org, Jing Zhang Subject: Re: [PATCH 11/14] KVM: stats: Add stat to detect if vcpu is currently blocking Message-ID: References: <20210925005528.1145584-1-seanjc@google.com> <20210925005528.1145584-12-seanjc@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210925005528.1145584-12-seanjc@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 24, 2021 at 05:55:25PM -0700, Sean Christopherson wrote: > From: Jing Zhang > > Add a "blocking" stat that userspace can use to detect the case where a > vCPU is not being run because of a vCPU/guest action, e.g. HLT or WFS on > x86, WFI on arm64, etc... Current guest/host/halt stats don't show this > well, e.g. if a guest halts for a long period of time then the vCPU could > appear pathologically blocked due to a host condition, when in reality the > vCPU has been put into a not-runnable state by the guest. > > Originally-by: Cannon Matthews > Suggested-by: Sean Christopherson > Signed-off-by: Jing Zhang > [sean: renamed stat to "blocking", massaged changelog] > Signed-off-by: Sean Christopherson Reviewed-by: David Matlack > --- > include/linux/kvm_host.h | 3 ++- > include/linux/kvm_types.h | 1 + > virt/kvm/kvm_main.c | 2 ++ > 3 files changed, 5 insertions(+), 1 deletion(-) > > diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h > index 655c2b24db2d..9bb1972e396a 100644 > --- a/include/linux/kvm_host.h > +++ b/include/linux/kvm_host.h > @@ -1453,7 +1453,8 @@ struct _kvm_stats_desc { > STATS_DESC_LOGHIST_TIME_NSEC(VCPU_GENERIC, halt_poll_fail_hist, \ > HALT_POLL_HIST_COUNT), \ > STATS_DESC_LOGHIST_TIME_NSEC(VCPU_GENERIC, halt_wait_hist, \ > - HALT_POLL_HIST_COUNT) > + HALT_POLL_HIST_COUNT), \ > + STATS_DESC_ICOUNTER(VCPU_GENERIC, blocking) > > extern struct dentry *kvm_debugfs_dir; > > diff --git a/include/linux/kvm_types.h b/include/linux/kvm_types.h > index 2237abb93ccd..c4f9257bf32d 100644 > --- a/include/linux/kvm_types.h > +++ b/include/linux/kvm_types.h > @@ -94,6 +94,7 @@ struct kvm_vcpu_stat_generic { > u64 halt_poll_success_hist[HALT_POLL_HIST_COUNT]; > u64 halt_poll_fail_hist[HALT_POLL_HIST_COUNT]; > u64 halt_wait_hist[HALT_POLL_HIST_COUNT]; > + u64 blocking; > }; > > #define KVM_STATS_NAME_SIZE 48 > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > index fe34457530c2..2980d2b88559 100644 > --- a/virt/kvm/kvm_main.c > +++ b/virt/kvm/kvm_main.c > @@ -3208,6 +3208,7 @@ bool kvm_vcpu_block(struct kvm_vcpu *vcpu) > { > bool waited = false; > > + vcpu->stat.generic.blocking = 1; > kvm_arch_vcpu_blocking(vcpu); > > prepare_to_rcuwait(&vcpu->wait); > @@ -3223,6 +3224,7 @@ bool kvm_vcpu_block(struct kvm_vcpu *vcpu) > finish_rcuwait(&vcpu->wait); > > kvm_arch_vcpu_unblocking(vcpu); > + vcpu->stat.generic.blocking = 0; > > return waited; > } > -- > 2.33.0.685.g46640cef36-goog > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2D2F2C433F5 for ; Tue, 28 Sep 2021 22:07:16 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E2D206137A for ; Tue, 28 Sep 2021 22:07:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E2D206137A Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=xoZ0SwIQQKS4ORZxPJVVzP+J2hoDA9+vecEKu/XHQTY=; b=DkpMPdtV97AmGV ZJifdNyPvEfWVsiwUc/emJEjcTVGb6c3CNmdqIbWoZn3AkJP7tj5mqhYqI+z3Ss0f+94x/EKpZ9X0 Dhu5tMk8FJHg8WnABXJeV88NrK9iXSS4HueYEf/AGLLGYyEGNz6aUlg/gSPyWOJnuhe9B4NlwQUKm GTpmAN/eweVfYRIkaa5Qx6NdCJc6YjAvgb40FBUh2YMZLn+dB4Cg2a8A1kiiB3MbTVIylHlbpUINf DaupbeaeOStO+1Hk1Cs+hAEJjnNGGSTRKFQfg5NXi8Uudg03Y2za464rFIbqzVrwgGXtnub5LpX5p YZWh0gkjTpXdU4MsQrmg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mVLDd-008xCL-Un; Tue, 28 Sep 2021 22:04:58 +0000 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mVLDZ-008xAt-Hr for linux-arm-kernel@lists.infradead.org; Tue, 28 Sep 2021 22:04:54 +0000 Received: by mail-pj1-x1031.google.com with SMTP id on12-20020a17090b1d0c00b001997c60aa29so2702844pjb.1 for ; Tue, 28 Sep 2021 15:04:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=s8TgaTkuAOfttq5Ji23XuWmZEPg/t1pbW45rjrv+GjY=; b=LOKBGSSThTGJmZr52wMlTVIXy7gN0kcixsV7n11azJM+wFcpy4hdoZIRhH6FjCUukF R3ek08fGm45mGkuiA0+Kxm49I86GkQOabdwCzh/L7J8ZtTUESfVtBd1ViQEJJ5vZmB0j gVM3+sKMqY01a6pRSxMH/JV7N2k8jZaoTStvXT/CW+6ekMegbYoSEeVNZm/knJC1H2Iz JpHolIs35AjaAocSgJu4Q8l0875P6gOMqZFX8yYi8BLrJDNQk0tBeB5SUgTVoQJk7Bxc TaQ1FhIIJDiukqtBzIRTPyLdyC5LfChFTqz2xnOAHZ/G/Ty6/PTiLDypDINxMIzqkG+p MNEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=s8TgaTkuAOfttq5Ji23XuWmZEPg/t1pbW45rjrv+GjY=; b=ytokk9VfXWg4PV2N/XWb5CSiobPqT84rUg8oFrlxtODnzcXUDJwg/MrXoN1Qdunkbq 87LMLibr+qTACLtckbdcSjilPaJwDrwg9amdecgO6+09+PG4Ucn2MJCzppqZo13Pbsl7 ZxNWpDLq10AqtR2MiYINRfphcDPikRU2Cd62VlyXHqfcP5J4SbGVQzyfsYKVN1kZPmZ7 fGlUh7yqYwN6AQFEQR46TjeIz7dFBhpXySlCRcpQ8H5fBB6kyxUAV1XHZ8J5j86HNVk6 PlPQTEFXr4vCGwuu8QRc6NEcYO/UbklMmhgVdXVVGEc4H6pexptNLcjyvKQSaLN7x3gc cMbA== X-Gm-Message-State: AOAM532PXDfMqEVDdnqnFdjqNtzXUvK2nW7/SNQppBXkg994/0kE5s0O t6VaEHYi3doa73QKNZncoJsDwQ== X-Google-Smtp-Source: ABdhPJyZYZhKpQUljc7RVXwKUERY34mYmQfs2NuJ723fR6n2a6r5wthdOfaTSfpkU7ajTH5d6X1x0g== X-Received: by 2002:a17:90a:c982:: with SMTP id w2mr2466336pjt.30.1632866692006; Tue, 28 Sep 2021 15:04:52 -0700 (PDT) Received: from google.com (254.80.82.34.bc.googleusercontent.com. [34.82.80.254]) by smtp.gmail.com with ESMTPSA id v26sm124276pfm.175.2021.09.28.15.04.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 15:04:51 -0700 (PDT) Date: Tue, 28 Sep 2021 22:04:47 +0000 From: David Matlack To: Sean Christopherson Cc: Marc Zyngier , Huacai Chen , Aleksandar Markovic , Paul Mackerras , Christian Borntraeger , Janosch Frank , Paolo Bonzini , James Morse , Alexandru Elisei , Suzuki K Poulose , David Hildenbrand , Cornelia Huck , Claudio Imbrenda , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-mips@vger.kernel.org, kvm@vger.kernel.org, kvm-ppc@vger.kernel.org, linux-kernel@vger.kernel.org, Jing Zhang Subject: Re: [PATCH 11/14] KVM: stats: Add stat to detect if vcpu is currently blocking Message-ID: References: <20210925005528.1145584-1-seanjc@google.com> <20210925005528.1145584-12-seanjc@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210925005528.1145584-12-seanjc@google.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210928_150453_625412_FAD39026 X-CRM114-Status: GOOD ( 22.58 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Sep 24, 2021 at 05:55:25PM -0700, Sean Christopherson wrote: > From: Jing Zhang > > Add a "blocking" stat that userspace can use to detect the case where a > vCPU is not being run because of a vCPU/guest action, e.g. HLT or WFS on > x86, WFI on arm64, etc... Current guest/host/halt stats don't show this > well, e.g. if a guest halts for a long period of time then the vCPU could > appear pathologically blocked due to a host condition, when in reality the > vCPU has been put into a not-runnable state by the guest. > > Originally-by: Cannon Matthews > Suggested-by: Sean Christopherson > Signed-off-by: Jing Zhang > [sean: renamed stat to "blocking", massaged changelog] > Signed-off-by: Sean Christopherson Reviewed-by: David Matlack > --- > include/linux/kvm_host.h | 3 ++- > include/linux/kvm_types.h | 1 + > virt/kvm/kvm_main.c | 2 ++ > 3 files changed, 5 insertions(+), 1 deletion(-) > > diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h > index 655c2b24db2d..9bb1972e396a 100644 > --- a/include/linux/kvm_host.h > +++ b/include/linux/kvm_host.h > @@ -1453,7 +1453,8 @@ struct _kvm_stats_desc { > STATS_DESC_LOGHIST_TIME_NSEC(VCPU_GENERIC, halt_poll_fail_hist, \ > HALT_POLL_HIST_COUNT), \ > STATS_DESC_LOGHIST_TIME_NSEC(VCPU_GENERIC, halt_wait_hist, \ > - HALT_POLL_HIST_COUNT) > + HALT_POLL_HIST_COUNT), \ > + STATS_DESC_ICOUNTER(VCPU_GENERIC, blocking) > > extern struct dentry *kvm_debugfs_dir; > > diff --git a/include/linux/kvm_types.h b/include/linux/kvm_types.h > index 2237abb93ccd..c4f9257bf32d 100644 > --- a/include/linux/kvm_types.h > +++ b/include/linux/kvm_types.h > @@ -94,6 +94,7 @@ struct kvm_vcpu_stat_generic { > u64 halt_poll_success_hist[HALT_POLL_HIST_COUNT]; > u64 halt_poll_fail_hist[HALT_POLL_HIST_COUNT]; > u64 halt_wait_hist[HALT_POLL_HIST_COUNT]; > + u64 blocking; > }; > > #define KVM_STATS_NAME_SIZE 48 > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > index fe34457530c2..2980d2b88559 100644 > --- a/virt/kvm/kvm_main.c > +++ b/virt/kvm/kvm_main.c > @@ -3208,6 +3208,7 @@ bool kvm_vcpu_block(struct kvm_vcpu *vcpu) > { > bool waited = false; > > + vcpu->stat.generic.blocking = 1; > kvm_arch_vcpu_blocking(vcpu); > > prepare_to_rcuwait(&vcpu->wait); > @@ -3223,6 +3224,7 @@ bool kvm_vcpu_block(struct kvm_vcpu *vcpu) > finish_rcuwait(&vcpu->wait); > > kvm_arch_vcpu_unblocking(vcpu); > + vcpu->stat.generic.blocking = 0; > > return waited; > } > -- > 2.33.0.685.g46640cef36-goog > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B9F3DC433F5 for ; Wed, 29 Sep 2021 07:12:49 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id 603C36137E for ; Wed, 29 Sep 2021 07:12:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 603C36137E Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.cs.columbia.edu Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 0B7614B0E6; Wed, 29 Sep 2021 03:12:49 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Authentication-Results: mm01.cs.columbia.edu (amavisd-new); dkim=softfail (fail, message has been altered) header.i=@google.com Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id edqaYqaRlFpU; Wed, 29 Sep 2021 03:12:47 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id D5EC74B15B; Wed, 29 Sep 2021 03:12:41 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 3B1884048A for ; Tue, 28 Sep 2021 18:04:54 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id GKXMx5dC+Me7 for ; Tue, 28 Sep 2021 18:04:53 -0400 (EDT) Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id 2001740191 for ; Tue, 28 Sep 2021 18:04:53 -0400 (EDT) Received: by mail-pj1-f50.google.com with SMTP id il14-20020a17090b164e00b0019c7a7c362dso2727953pjb.0 for ; Tue, 28 Sep 2021 15:04:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=s8TgaTkuAOfttq5Ji23XuWmZEPg/t1pbW45rjrv+GjY=; b=LOKBGSSThTGJmZr52wMlTVIXy7gN0kcixsV7n11azJM+wFcpy4hdoZIRhH6FjCUukF R3ek08fGm45mGkuiA0+Kxm49I86GkQOabdwCzh/L7J8ZtTUESfVtBd1ViQEJJ5vZmB0j gVM3+sKMqY01a6pRSxMH/JV7N2k8jZaoTStvXT/CW+6ekMegbYoSEeVNZm/knJC1H2Iz JpHolIs35AjaAocSgJu4Q8l0875P6gOMqZFX8yYi8BLrJDNQk0tBeB5SUgTVoQJk7Bxc TaQ1FhIIJDiukqtBzIRTPyLdyC5LfChFTqz2xnOAHZ/G/Ty6/PTiLDypDINxMIzqkG+p MNEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=s8TgaTkuAOfttq5Ji23XuWmZEPg/t1pbW45rjrv+GjY=; b=umTTzRRBfUeZ3eIW6Ql7y4VFvL227kwCCt2D/GrnrZiFsM/vrvfGlZEAKwxBKwwKTW Oj03//HPKapYsews8QWYvu5yGRoey6xVTh6bJLguzCZ2y1Ei4VWqylhqJmvMvAvr0NNn oV3gleqiOYE+IYyTdXbaTyDY1aMBqh/wmHu24Z0RUYP+nFiqUSMiaJYJLm7DM0XWcNFP njOiB+Iq0r3pmCO2YYHcNCf/X2OSIub4l5519Zq3fJoqa8yspJrYMXjsXs1mOcY589Ja Iw7fEIg2XCCDMzqLzDGKqH1y66rHCS8Mvjkf8X627BV8+AZBF4lrIpmKKJZXYGAf4xwI f3YQ== X-Gm-Message-State: AOAM531n9V3B01YJ5BMuc1CibaXWrMk2XeUPOLPqjVmVf0Wys9s7Emik XWPAlse16xOwP5S2mVaIAYFCvg== X-Google-Smtp-Source: ABdhPJyZYZhKpQUljc7RVXwKUERY34mYmQfs2NuJ723fR6n2a6r5wthdOfaTSfpkU7ajTH5d6X1x0g== X-Received: by 2002:a17:90a:c982:: with SMTP id w2mr2466336pjt.30.1632866692006; Tue, 28 Sep 2021 15:04:52 -0700 (PDT) Received: from google.com (254.80.82.34.bc.googleusercontent.com. [34.82.80.254]) by smtp.gmail.com with ESMTPSA id v26sm124276pfm.175.2021.09.28.15.04.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 15:04:51 -0700 (PDT) Date: Tue, 28 Sep 2021 22:04:47 +0000 From: David Matlack To: Sean Christopherson Subject: Re: [PATCH 11/14] KVM: stats: Add stat to detect if vcpu is currently blocking Message-ID: References: <20210925005528.1145584-1-seanjc@google.com> <20210925005528.1145584-12-seanjc@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210925005528.1145584-12-seanjc@google.com> X-Mailman-Approved-At: Wed, 29 Sep 2021 03:12:40 -0400 Cc: Wanpeng Li , kvm@vger.kernel.org, David Hildenbrand , linux-kernel@vger.kernel.org, Paul Mackerras , Claudio Imbrenda , kvmarm@lists.cs.columbia.edu, Janosch Frank , Marc Zyngier , Joerg Roedel , Huacai Chen , Christian Borntraeger , Aleksandar Markovic , kvm-ppc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Jim Mattson , Cornelia Huck , linux-mips@vger.kernel.org, Paolo Bonzini , Vitaly Kuznetsov X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu On Fri, Sep 24, 2021 at 05:55:25PM -0700, Sean Christopherson wrote: > From: Jing Zhang > > Add a "blocking" stat that userspace can use to detect the case where a > vCPU is not being run because of a vCPU/guest action, e.g. HLT or WFS on > x86, WFI on arm64, etc... Current guest/host/halt stats don't show this > well, e.g. if a guest halts for a long period of time then the vCPU could > appear pathologically blocked due to a host condition, when in reality the > vCPU has been put into a not-runnable state by the guest. > > Originally-by: Cannon Matthews > Suggested-by: Sean Christopherson > Signed-off-by: Jing Zhang > [sean: renamed stat to "blocking", massaged changelog] > Signed-off-by: Sean Christopherson Reviewed-by: David Matlack > --- > include/linux/kvm_host.h | 3 ++- > include/linux/kvm_types.h | 1 + > virt/kvm/kvm_main.c | 2 ++ > 3 files changed, 5 insertions(+), 1 deletion(-) > > diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h > index 655c2b24db2d..9bb1972e396a 100644 > --- a/include/linux/kvm_host.h > +++ b/include/linux/kvm_host.h > @@ -1453,7 +1453,8 @@ struct _kvm_stats_desc { > STATS_DESC_LOGHIST_TIME_NSEC(VCPU_GENERIC, halt_poll_fail_hist, \ > HALT_POLL_HIST_COUNT), \ > STATS_DESC_LOGHIST_TIME_NSEC(VCPU_GENERIC, halt_wait_hist, \ > - HALT_POLL_HIST_COUNT) > + HALT_POLL_HIST_COUNT), \ > + STATS_DESC_ICOUNTER(VCPU_GENERIC, blocking) > > extern struct dentry *kvm_debugfs_dir; > > diff --git a/include/linux/kvm_types.h b/include/linux/kvm_types.h > index 2237abb93ccd..c4f9257bf32d 100644 > --- a/include/linux/kvm_types.h > +++ b/include/linux/kvm_types.h > @@ -94,6 +94,7 @@ struct kvm_vcpu_stat_generic { > u64 halt_poll_success_hist[HALT_POLL_HIST_COUNT]; > u64 halt_poll_fail_hist[HALT_POLL_HIST_COUNT]; > u64 halt_wait_hist[HALT_POLL_HIST_COUNT]; > + u64 blocking; > }; > > #define KVM_STATS_NAME_SIZE 48 > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > index fe34457530c2..2980d2b88559 100644 > --- a/virt/kvm/kvm_main.c > +++ b/virt/kvm/kvm_main.c > @@ -3208,6 +3208,7 @@ bool kvm_vcpu_block(struct kvm_vcpu *vcpu) > { > bool waited = false; > > + vcpu->stat.generic.blocking = 1; > kvm_arch_vcpu_blocking(vcpu); > > prepare_to_rcuwait(&vcpu->wait); > @@ -3223,6 +3224,7 @@ bool kvm_vcpu_block(struct kvm_vcpu *vcpu) > finish_rcuwait(&vcpu->wait); > > kvm_arch_vcpu_unblocking(vcpu); > + vcpu->stat.generic.blocking = 0; > > return waited; > } > -- > 2.33.0.685.g46640cef36-goog > _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm