From nobody Wed Nov 27 02:45:48 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1701374641; cv=none; d=zohomail.com; s=zohoarc; b=aLDvl+fU1rkM36XWjapR/9r9ckAb3lJ6FiCN/zki3qZqd0eD0CxTBpUv5q1WfRfjrusqYFPIppkUKSgKWyFJF21Kf7kyGQQlYdzHdlsk0hGjvD2Z4dvZdfKfEVCNHVkbs2JejMD9DKdAswzuLnEl+DnWm9i/u32Ujmr22/UD7Jk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701374641; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=WphYCatGh7+2b1MmdVsCP88pCJ51U+xNucxKvzboOWI=; b=L6H7UlPl0bTUeuiLkbdjhcEnu4Oz7HRuBf8oq7qJf9syfmLTpYFH4ycql72KA1oesdKjngcAjq0RUumC64n5km75TQLwLtur6GHsaxjhRIpEKlnFPc2KE6KEKHhBGNqAndx9MpC1VRkIbMhGkhQofKiyjlW0Vpj9dnDsQ/xK4E4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1701374641922372.4311037152819; Thu, 30 Nov 2023 12:04:01 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r8nFW-0006W2-6l; Thu, 30 Nov 2023 15:03:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r8nFS-0006Vb-Ht; Thu, 30 Nov 2023 15:02:58 -0500 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r8nFQ-00022c-By; Thu, 30 Nov 2023 15:02:58 -0500 Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-6cdea2f5918so842610b3a.2; Thu, 30 Nov 2023 12:02:55 -0800 (PST) Received: from localhost.localdomain ([2406:7400:56:3a45:dcc3:8696:be12:127c]) by smtp.gmail.com with ESMTPSA id n23-20020a056a000d5700b006cdd406e784sm1596630pfv.136.2023.11.30.12.02.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 12:02:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701374574; x=1701979374; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=WphYCatGh7+2b1MmdVsCP88pCJ51U+xNucxKvzboOWI=; b=IscU0b6XuZTDN2XZ3DQ8PvJzk8pWOOpOkM70TrtCftc9nQYHm3EngC41SVSMFqf5F7 WHC9JRTrE5mRiEEvXWgF0FMEGMDsaYWjPrlg6ZkQ8dEJDcmKcqQcklBsMsn6YXjQabLw BJySmyD7JXeVl6J0dga76rgNW42jtCejKW52XrS8vVu4MCcwyJs3vcEOUwTKHSu1NjuX sQ6c0FxxsfnISWUv26nCI+sKSV+aJ2j62tNtmQArGBncWqCqStmTPpGY553kwTNbgyWV slG8bxBfrJkqee4svS7KcZcw/ngWBz+9uWgXTmbU+pAgpyV5twEqlUQwnBYh6ykXFhT7 pRog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701374574; x=1701979374; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=WphYCatGh7+2b1MmdVsCP88pCJ51U+xNucxKvzboOWI=; b=wtXW+LphqlT/DcX6jr9cOHMsjiSQBiMkFhXsWT82hBAmerdV0SwaOtyKV6/G9dLV8M +vG5u/fCWtQuYE9iqqXpIaxmJuZkQSYPA/UY0AVxcZzRa8jefgL+Nd6LT4EnBMuATu2z zipcEZ5j5gTsXGrj7L08hdCp8nWQy07BrrSULDCOE6gVN4QmElJOHkXk76qJrcAIAsdw 5tVr1oenwtgEXvnvFPHnVtqGnWWExQ//N94ZiC3JGGvDTlqLAYCpicVEHRsUTECas4uE mSNpZoKLkJuEieN7oiVAjTSvwG5LMmkF7IDjfyhsf33ju3kH68pAqrLpquSMm0iAyCJy +AiQ== X-Gm-Message-State: AOJu0YyD5KSSOzmwjSSJ+hCOzTS7b5qCH54qEvETTOFIicwHmEHZK37o sBfUbeKBDTVlcRkKAMqVXl5FplQ8AO6y2A== X-Google-Smtp-Source: AGHT+IH8nOm40xyp6pxZ24fTFc0b+m8Z/UeezzeKMOZCP89Av9DZXoR3kxy4MAj2TfpEICNTkOmNEQ== X-Received: by 2002:a05:6a00:4ac4:b0:6be:265:1bf5 with SMTP id ds4-20020a056a004ac400b006be02651bf5mr23062336pfb.24.1701374573490; Thu, 30 Nov 2023 12:02:53 -0800 (PST) From: Jai Arora To: qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, pbonzini@redhat.com, peter.maydell@linaro.org, alex.bennee@linaro.org, Jai Arora Subject: [PATCH v4] accel/kvm: Turn DPRINTF macro use into tracepoints Date: Fri, 1 Dec 2023 01:32:36 +0530 Message-Id: <2e454e52639560c4768006ec2a93dcf6ba02b210.1701373822.git.arorajai2798@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::430; envelope-from=arorajai2798@gmail.com; helo=mail-pf1-x430.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1701374642731000001 Content-Type: text/plain; charset="utf-8" Patch removes DRPINTF macro and adds multiple tracepoints to capture different kvm events. We also drop the DPRINTFs that don't add any additional information than trace_kvm_run_exit already does. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1827 Signed-off-by: Jai Arora --- v4: Adds changes in commit message requested by Alex Bennee ps. I tried using git notes for the change log May be it did not reflect. Thanks for the feedback and review accel/kvm/kvm-all.c | 28 ++++++---------------------- accel/kvm/trace-events | 7 ++++++- 2 files changed, 12 insertions(+), 23 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index e39a810a4e..80ac7b35b7 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -69,16 +69,6 @@ #define KVM_GUESTDBG_BLOCKIRQ 0 #endif =20 -//#define DEBUG_KVM - -#ifdef DEBUG_KVM -#define DPRINTF(fmt, ...) \ - do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0) -#else -#define DPRINTF(fmt, ...) \ - do { } while (0) -#endif - struct KVMParkedVcpu { unsigned long vcpu_id; int kvm_fd; @@ -331,7 +321,7 @@ static int do_kvm_destroy_vcpu(CPUState *cpu) struct KVMParkedVcpu *vcpu =3D NULL; int ret =3D 0; =20 - DPRINTF("kvm_destroy_vcpu\n"); + trace_kvm_destroy_vcpu(); =20 ret =3D kvm_arch_destroy_vcpu(cpu); if (ret < 0) { @@ -341,7 +331,7 @@ static int do_kvm_destroy_vcpu(CPUState *cpu) mmap_size =3D kvm_ioctl(s, KVM_GET_VCPU_MMAP_SIZE, 0); if (mmap_size < 0) { ret =3D mmap_size; - DPRINTF("KVM_GET_VCPU_MMAP_SIZE failed\n"); + trace_kvm_failed_get_vcpu_mmap_size(); goto err; } =20 @@ -443,7 +433,6 @@ int kvm_init_vcpu(CPUState *cpu, Error **errp) PAGE_SIZE * KVM_DIRTY_LOG_PAGE_OFFSET); if (cpu->kvm_dirty_gfns =3D=3D MAP_FAILED) { ret =3D -errno; - DPRINTF("mmap'ing vcpu dirty gfns failed: %d\n", ret); goto err; } } @@ -2821,7 +2810,7 @@ int kvm_cpu_exec(CPUState *cpu) struct kvm_run *run =3D cpu->kvm_run; int ret, run_ret; =20 - DPRINTF("kvm_cpu_exec()\n"); + trace_kvm_cpu_exec(); =20 if (kvm_arch_process_async_events(cpu)) { qatomic_set(&cpu->exit_request, 0); @@ -2848,7 +2837,7 @@ int kvm_cpu_exec(CPUState *cpu) =20 kvm_arch_pre_run(cpu, run); if (qatomic_read(&cpu->exit_request)) { - DPRINTF("interrupt exit requested\n"); + trace_kvm_interrupt_exit_request(); /* * KVM requires us to reenter the kernel after IO exits to com= plete * instruction emulation. This self-signal will ensure that we @@ -2878,7 +2867,7 @@ int kvm_cpu_exec(CPUState *cpu) =20 if (run_ret < 0) { if (run_ret =3D=3D -EINTR || run_ret =3D=3D -EAGAIN) { - DPRINTF("io window exit\n"); + trace_kvm_io_window_exit(); kvm_eat_signals(cpu); ret =3D EXCP_INTERRUPT; break; @@ -2900,7 +2889,6 @@ int kvm_cpu_exec(CPUState *cpu) trace_kvm_run_exit(cpu->cpu_index, run->exit_reason); switch (run->exit_reason) { case KVM_EXIT_IO: - DPRINTF("handle_io\n"); /* Called outside BQL */ kvm_handle_io(run->io.port, attrs, (uint8_t *)run + run->io.data_offset, @@ -2910,7 +2898,6 @@ int kvm_cpu_exec(CPUState *cpu) ret =3D 0; break; case KVM_EXIT_MMIO: - DPRINTF("handle_mmio\n"); /* Called outside BQL */ address_space_rw(&address_space_memory, run->mmio.phys_addr, attrs, @@ -2920,11 +2907,9 @@ int kvm_cpu_exec(CPUState *cpu) ret =3D 0; break; case KVM_EXIT_IRQ_WINDOW_OPEN: - DPRINTF("irq_window_open\n"); ret =3D EXCP_INTERRUPT; break; case KVM_EXIT_SHUTDOWN: - DPRINTF("shutdown\n"); qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); ret =3D EXCP_INTERRUPT; break; @@ -2959,6 +2944,7 @@ int kvm_cpu_exec(CPUState *cpu) ret =3D 0; break; case KVM_EXIT_SYSTEM_EVENT: + trace_kvm_run_exit_system_event(cpu->cpu_index, run->system_ev= ent.type); switch (run->system_event.type) { case KVM_SYSTEM_EVENT_SHUTDOWN: qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN= ); @@ -2976,13 +2962,11 @@ int kvm_cpu_exec(CPUState *cpu) ret =3D 0; break; default: - DPRINTF("kvm_arch_handle_exit\n"); ret =3D kvm_arch_handle_exit(cpu, run); break; } break; default: - DPRINTF("kvm_arch_handle_exit\n"); ret =3D kvm_arch_handle_exit(cpu, run); break; } diff --git a/accel/kvm/trace-events b/accel/kvm/trace-events index 399aaeb0ec..f61a21019a 100644 --- a/accel/kvm/trace-events +++ b/accel/kvm/trace-events @@ -25,4 +25,9 @@ kvm_dirty_ring_reaper(const char *s) "%s" kvm_dirty_ring_reap(uint64_t count, int64_t t) "reaped %"PRIu64" pages (to= ok %"PRIi64" us)" kvm_dirty_ring_reaper_kick(const char *reason) "%s" kvm_dirty_ring_flush(int finished) "%d" - +kvm_destroy_vcpu(void) "" +kvm_failed_get_vcpu_mmap_size(void) "" +kvm_cpu_exec(void) "" +kvm_interrupt_exit_request(void) "" +kvm_io_window_exit(void) "" +kvm_run_exit_system_event(int cpu_index, uint32_t event_type) "cpu_index %= d, system_even_type %d" --=20 2.25.1