Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp120028rdb; Wed, 14 Feb 2024 15:02:03 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVXy3D3oRifi5O8uoT9EYORdw9h/XpHVCnC+znDSsvJirmAVeULNKb2heAIzYYRAsrDuRGJgBbxe/9XT/a+vUxnVnVrcwyYyeJjkBbJyQ== X-Google-Smtp-Source: AGHT+IEbkAphLRfy/EhbQhy5LwyH3hpb1IrYYizF0ZkP3xJaEVZ3LVgsztydnIHv69T8Wkbp0yxT X-Received: by 2002:a19:7008:0:b0:511:a4fd:fc1a with SMTP id h8-20020a197008000000b00511a4fdfc1amr113059lfc.47.1707951722950; Wed, 14 Feb 2024 15:02:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707951722; cv=pass; d=google.com; s=arc-20160816; b=wqqno8G3+eyY9zPx+YNNc4I9u6hYqjJp5kgEWfMDBn2dRYDD7LeIliDC+YaP4jtWBu 83p4cgJVTI0amZl+5l2o2RufSAVNXHKxqURS49r7JXy1Q2PadK0kfAEICNxg6ycCPIb9 4sRQ//3G3egMqWKy89jGCMXjQgDSsev2d31/rQllMqaC+/AuqcCJ3KhY3kCG7eOlD0IH sTjRYbF9B5rPgChYDClCrGJ6AJkf63gNIWLShvlKmpqYxEXth6LMCshVQdILZb26E1EJ MPl6ObD0Ldcucm3BPczuHAZi73iQgtIMibKTJpIGkheucr/ZWlnCWjon2RSQvROdIRBt oSlw== 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=x7QawTE8JWwRUmZUjfwlDW5G0cvdCAkL24d2eFGEHmE=; b=ja59WbLwaRqgOztefoXZknsEBWrdP6hp1diwNz2APAX/0W9fR+neXKsav1PBgX2zQH vDQ4jweEm3IAZeC5uO9bQXZRsZyjmE35PJ4FpfUbOp0LG5cpykFDgFJYnc0MtDIyE14+ P9ManPwVl5BNRDJrd/q/bhhan5fqCdG7OCH69nypXqVplGLajTqHxgBxlJrr04d8op9G AZTuesYZXWS1my7nECRCGXTLi/sjJFNddjlxpAFl0D1T3w/FNe6DNGNAW3admVD36iS7 DKmtCiJuebru6PJpBwxSLxl8E0WnL0YK2w9EJoZwp97sDreUYX8Kp87qhJE7bgKtvVCE 9G6w==; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66060-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com X-Forwarded-Encrypted: i=2; AJvYcCXUSoqfjCCW+RO4ncvimn6C02tGGBwmjEC9xZkCLozIbxchjnpacKmC9zDJ0ujAt6wQeAEk4hBfRQWxHdtZQ5QyDMWegGCcp3R43+/0fQ== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id h19-20020a170906591300b00a3d3843f9b6si1152298ejq.810.2024.02.14.15.02.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 15:02:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-66060-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66060-linux.lists.archive=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 am.mirrors.kernel.org (Postfix) with ESMTPS id 445AF1F29ADF for ; Wed, 14 Feb 2024 22:37:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A721013DBBE; Wed, 14 Feb 2024 22:36:05 +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 Content-Transfer-Encoding: 8bit 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 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(-) 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, base-commit: 7455665a3521aa7b56245c0a2810f748adc5fdd4 -- 2.39.3