From patchwork Wed Feb 14 22:35:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alejandro Jimenez X-Patchwork-Id: 201165 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp25178dyb; Wed, 14 Feb 2024 14:38:04 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXuSbMXlOpYOOvmRcR+jEJKfETRhAFFCgdopqoKIsfMmYZphgjh8c6sW1Lw/WR/odX9eBi4YuapAyPc584lprLUjKGaHw== X-Google-Smtp-Source: AGHT+IEL1ai7wdcVbAPBChKFxEoNkkLqWvAFB8E4bkunztxD1xH8YdpGLc7N+Z5S1IMXb1GziY+A X-Received: by 2002:a05:6871:806:b0:218:f001:10bf with SMTP id q6-20020a056871080600b00218f00110bfmr4432085oap.35.1707950283827; Wed, 14 Feb 2024 14:38:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707950283; cv=pass; d=google.com; s=arc-20160816; b=NU4rCfn9FX4EviH/yMezJgZR2sQJvYBA4V8AjlvnX12cWbvLanuLJr6Ysx1emMn59L vFFJ/1mvULFuCgSIDWKjyS5TdIXJU6Nisf9tCGHJJ4iTOQQ2s5+SbrPg1FN/VUE4zdFE fQfrX2n80wgO5qMYTkCg9LZgzXCg0PuWL7PvjMpUfUtN4kS6E3MQh0/slDX199m9ChZm /pNXQ8sdg2ZguN/CfW9ZTyND8DeatqJzOJqWBPCHqBWP1Y1JsQeAu2+CeNmazXwwmE2C udU26QTo2QwKlLTIHTlSTIIt+mMSqHwSfUd8ENRGQC5v0aE+7lY+2rIs5hUlq2qxSD8R OrWQ== 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:message-id:date:subject:cc:to :from:dkim-signature; bh=w3ig6KHMTEgTENKvlHnOdkrUoc8w9f3gJq3KxOYjllA=; fh=oI/isrLlpCeDhD18IHT3TwdFPtbCB82hOmvVThOk04w=; b=CqDUC1qvb3Hwnn+ry7YpmzRAOpXAf/avG3I8QfLTWmO26lWTcVKF5ak6bmD1b0DTAu ivwcHkk/+M+hHrmCPdv8cmPt9Jly0IrVmOlPCKZaeAz78oZMykn7WssKqwsjjbytWFkQ 14eOmW2/80LmtzeS636hjlK6iYHI/+i6eLBg+wXZ0zeuNkoB0geVWSmaCnKU/WqMWrd3 mrMer6uQdNnhIuBgUCpwvpqovY5bSluosX0kLJ0WYT6oc/FWn1ZGB+VpXo2AghLJBGls 8F2aZbtAlONUlfFRfFzD7JmZOhtLnpUxQaiVIEHuu3ZFJtAizw1hWcQBuZ+Y7XHkfgKG 8uMg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-11-20 header.b=UEn54zZ3; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel+bounces-66060-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66060-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com X-Forwarded-Encrypted: i=2; AJvYcCVfXMIFq3BGUuDGDLOjLv3ic/4lrmgEG4+KxR4OQNhm+3QfC5V2eNqbNJ4gEBt9uj08p8lE+TIMuHDXkVYaFDCi8QLfzA== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id o3-20020ac87c43000000b0042c4af9330bsi6545807qtv.260.2024.02.14.14.38.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 14:38:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-66060-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-11-20 header.b=UEn54zZ3; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel+bounces-66060-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66060-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id C0A781C25477 for ; Wed, 14 Feb 2024 22:37:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9B0F91420A6; Wed, 14 Feb 2024 22:36:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="UEn54zZ3" Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (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 3A0414502D; Wed, 14 Feb 2024 22:36:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.165.32 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707950164; cv=none; b=HkAVjzsguzy1WdMs1KIgBCA/h0Wq5phJ0GikjS94NmuwdPry9kRzLkTSuGg40flCKYuW+Xdh7PaPRbIO3hwp8qGPzqnlUOXeR5hK5ruwgR1UNsITAXvJwRF1CjH2cCdYFkipTqpK915X48LVE7ytIPZYQDUcVmNMaAAtkCjgSY4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707950164; c=relaxed/simple; bh=zSsEp6WIbwar3E1MkHiDYZQkkX71x7A1W8sVSFzBhc0=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=HWi6bzsDg1067rhG1hXSSZh6iKmliDnAx0Cmvs/Qu3gaycn93IqXU7DmfKrN74qqedeN3SwPMbrGvxAuyLlWpVWkI0Thf8O26zUgAoyk6CiJHpRsFgr65jmUI9U8Klof1A+Zal/8bLQP3Foqu9Lo3MHguov+LFKfPWz0lUeBmK4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=UEn54zZ3; arc=none smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 41ELiX8W022711; Wed, 14 Feb 2024 22:35:57 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=corp-2023-11-20; bh=w3ig6KHMTEgTENKvlHnOdkrUoc8w9f3gJq3KxOYjllA=; b=UEn54zZ3fTCl9HgEI3Uc0qg9ulaaAUOd6Wlueh9v0dePptYGUM2TWXlUcJcZ3AyxLYwJ QwwQBzr3tJhmaHgF5hZo1r4oUvyf2vtN2isMWRfhwSzq0fHuCcfJbtFzz51EAAvurJhU 3HvwsfS0/XDp1pxmec6WMDQy6JYpVTwjWYekuTFB4TUD8JRWWoEjTW5YtVOSWa8u1nGi hpuy8ZKcYs6rBTmJgRBVilLUsKIwMbGzsHbVqqFCd5xYvvmilA26uzbbclgTHql2viFS eJyIRk3Qs53o4b0Uf42L5YmIfovBpKgguIwa5m9OmqZab8OLC+mYIv7hjPZxroiaQh/y og== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3w92ppghs9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Feb 2024 22:35:57 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 41ELZirv013764; Wed, 14 Feb 2024 22:35:56 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3w6apcera3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Feb 2024 22:35:56 +0000 Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 41EMZtqc012570; Wed, 14 Feb 2024 22:35:55 GMT Received: from alaljime-dev-e4flex-vm.osdevelopmeniad.oraclevcn.com (alaljime-dev-e4flex-vm.allregionaliads.osdevelopmeniad.oraclevcn.com [100.100.249.106]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3w6apcer8u-1; Wed, 14 Feb 2024 22:35:55 +0000 From: Alejandro Jimenez To: kvm@vger.kernel.org Cc: seanjc@google.com, pbonzini@redhat.com, linux-kernel@vger.kernel.org, joao.m.martins@oracle.com, boris.ostrovsky@oracle.com, suravee.suthikulpanit@amd.com, mlevitsk@redhat.com, alejandro.j.jimenez@oracle.com Subject: [PATCH 1/1] KVM: x86: Print names of apicv inhibit reasons in traces Date: Wed, 14 Feb 2024 22:35:54 +0000 Message-Id: <20240214223554.1033154-1-alejandro.j.jimenez@oracle.com> X-Mailer: git-send-email 2.39.3 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-14_14,2024-02-14_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=985 adultscore=0 suspectscore=0 mlxscore=0 phishscore=0 bulkscore=0 malwarescore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402140170 X-Proofpoint-ORIG-GUID: yTAUtYVm6jr8_vaL4CG3EzgAtjl6F59J X-Proofpoint-GUID: yTAUtYVm6jr8_vaL4CG3EzgAtjl6F59J X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790915677215505576 X-GMAIL-MSGID: 1790915677215505576 Use the tracing infrastructure helper __print_flags() for printing flag bitfields, to enhance the trace output by displaying a string describing each of the inhibit reasons set. The kvm_apicv_inhibit_changed tracepoint currently shows the raw bitmap value, requiring the user to consult the source file where the inhbit reasons are defined to decode the trace output. Signed-off-by: Alejandro Jimenez --- checkpatch reports an error: ERROR: Macros with complex values should be enclosed in parentheses but that seems common for other patches that also use a macro to define an array of struct trace_print_flags used by __print_flags(). I did not include an example of the new traces in the commit message since they are longer than 80 columns, but perhaps that is desirable. e.g.: qemu-system-x86-6961 [055] ..... 1779.344065: kvm_apicv_inhibit_changed: set reason=2, inhibits=0x4 ABSENT qemu-system-x86-6961 [055] ..... 1779.356710: kvm_apicv_inhibit_changed: cleared reason=2, inhibits=0x0 qemu-system-x86-9912 [137] ..... 57106.196107: kvm_apicv_inhibit_changed: set reason=8, inhibits=0x300 IRQWIN|PIT_REINJ qemu-system-x86-9912 [137] ..... 57106.196115: kvm_apicv_inhibit_changed: cleared reason=8, inhibits=0x200 PIT_REINJ --- arch/x86/kvm/trace.h | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) base-commit: 7455665a3521aa7b56245c0a2810f748adc5fdd4 diff --git a/arch/x86/kvm/trace.h b/arch/x86/kvm/trace.h index b82e6ed4f024..8469e59dfce2 100644 --- a/arch/x86/kvm/trace.h +++ b/arch/x86/kvm/trace.h @@ -1372,6 +1372,27 @@ TRACE_EVENT(kvm_hv_stimer_cleanup, __entry->vcpu_id, __entry->timer_index) ); +/* + * The inhibit flags in this flag array must be kept in sync with the + * kvm_apicv_inhibit enum members in . + */ +#define APICV_INHIBIT_FLAGS \ + { BIT(APICV_INHIBIT_REASON_DISABLE), "DISABLED" }, \ + { BIT(APICV_INHIBIT_REASON_HYPERV), "HYPERV" }, \ + { BIT(APICV_INHIBIT_REASON_ABSENT), "ABSENT" }, \ + { BIT(APICV_INHIBIT_REASON_BLOCKIRQ), "BLOCKIRQ" }, \ + { BIT(APICV_INHIBIT_REASON_PHYSICAL_ID_ALIASED), "PHYS_ID_ALIASED" }, \ + { BIT(APICV_INHIBIT_REASON_APIC_ID_MODIFIED), "APIC_ID_MOD" }, \ + { BIT(APICV_INHIBIT_REASON_APIC_BASE_MODIFIED), "APIC_BASE_MOD" }, \ + { BIT(APICV_INHIBIT_REASON_NESTED), "NESTED" }, \ + { BIT(APICV_INHIBIT_REASON_IRQWIN), "IRQWIN" }, \ + { BIT(APICV_INHIBIT_REASON_PIT_REINJ), "PIT_REINJ" }, \ + { BIT(APICV_INHIBIT_REASON_SEV), "SEV" }, \ + { BIT(APICV_INHIBIT_REASON_LOGICAL_ID_ALIASED), "LOG_ID_ALIASED" } \ + +#define show_inhibit_reasons(inhibits) \ + __print_flags(inhibits, "|", APICV_INHIBIT_FLAGS) + TRACE_EVENT(kvm_apicv_inhibit_changed, TP_PROTO(int reason, bool set, unsigned long inhibits), TP_ARGS(reason, set, inhibits), @@ -1388,9 +1409,12 @@ TRACE_EVENT(kvm_apicv_inhibit_changed, __entry->inhibits = inhibits; ), - TP_printk("%s reason=%u, inhibits=0x%lx", + TP_printk("%s reason=%u, inhibits=0x%lx%s%s", __entry->set ? "set" : "cleared", - __entry->reason, __entry->inhibits) + __entry->reason, __entry->inhibits, + __entry->inhibits ? " " : "", + __entry->inhibits ? + show_inhibit_reasons(__entry->inhibits) : "") ); TRACE_EVENT(kvm_apicv_accept_irq,