From nobody Sun Feb 8 23:23:20 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0EFF7EB64DD for ; Sat, 29 Jul 2023 00:49:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236305AbjG2AtO (ORCPT ); Fri, 28 Jul 2023 20:49:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236672AbjG2As4 (ORCPT ); Fri, 28 Jul 2023 20:48:56 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8DD611D for ; Fri, 28 Jul 2023 17:48:22 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-58473c4f629so21093577b3.1 for ; Fri, 28 Jul 2023 17:48:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1690591648; x=1691196448; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=zPxDuw7GeJQotzB/CPJITWYq84dGkPo6Sdy7hiPXZfA=; b=tfJreDiVdxqrWTn17eDz9CQ1prR4OaY8R72gsdHx5b0HfSm06muHlq6/VU8VmbJ/69 QTkeIaV9d0VbA+DjT9ug4lgckuxEQEmnyA+gGWYj4GDEnhCs1swodjbX/M0Sd1+mLAGP GjD90stCM9Q8l2RXDOAZpahBB9xD2Os888pcdmciu7sBhKYpsuMILtmlSIRHv8S5ZG45 umHo9TXIvRmOMlFEzXsGR045vYHfeinM2oRiITQfJst61DZLkVDEDnSYdeejwQmFgwcH IO9UnRimsDRL2mV/XKV1dI5RJZjxAvUXRoEO3btpR/9vV1d3JeH3R4Hlc5949Es//XYU pPJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690591648; x=1691196448; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=zPxDuw7GeJQotzB/CPJITWYq84dGkPo6Sdy7hiPXZfA=; b=U9hnwbnSLsb447WxN/zgnE2bJSZWxOho13/FRbl/SgVHHbAKHg0cCXEzAFPRdUIZRD DrYn3AYLg9mITgGCbqYO2RkwdYb8Bj7WDMXo0+vRp7Frhm6Dxbvy2ertr30LwLX0eNzb ojK/mIJyS3s8Zxsba/HHAkDRdaXKsR4GVmk73jafujQC3bNsbw3lClf1JDSfru7vI1xv 2Z6TKcmORjhWEe9GJYjd9M2YE22NofQxpetp/JCmcruuQWr64TvG1vzkJb7rOgeGM7QX Y5c4wu/Mi6PUXnI64X4u3KY+7l1DhkPRtBMeCI9oG01uNT1vkizUjHfC0VKrSpJIwOzm YWDg== X-Gm-Message-State: ABy/qLbLSPUDAaOPpdT3jfJ/gB4sradjDr0SF3Cu+XmZz7j3JVHwhIUN jTGQkSIEAa+gYWJNRNdi5xCPuM4fo4c= X-Google-Smtp-Source: APBJJlH5CMrCcIbJEX3F3Vv06Tdao406OfSUM981PUaHzDHpUx0xmQUNwcMXKWHraA+hv5ypdYYbC4WaYcI= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a81:4304:0:b0:565:a42c:79fe with SMTP id q4-20020a814304000000b00565a42c79femr24190ywa.1.1690591648271; Fri, 28 Jul 2023 17:47:28 -0700 (PDT) Reply-To: Sean Christopherson Date: Fri, 28 Jul 2023 17:47:12 -0700 In-Reply-To: <20230729004722.1056172-1-seanjc@google.com> Mime-Version: 1.0 References: <20230729004722.1056172-1-seanjc@google.com> X-Mailer: git-send-email 2.41.0.487.g6d72f3e995-goog Message-ID: <20230729004722.1056172-3-seanjc@google.com> Subject: [PATCH v3 02/12] KVM: x86/mmu: Delete rmap_printk() and all its usage From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Mingwei Zhang , David Matlack , Jim Mattson Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Delete rmap_printk() so that MMU_WARN_ON() and MMU_DEBUG can be morphed into something that can be regularly enabled for debug kernels. The information provided by rmap_printk() isn't all that useful now that the rmap and unsync code is mature, as the prints are simultaneously too verbose (_lots_ of message) and yet not verbose enough to be helpful for debug (most instances print just the SPTE pointer/value, which is rarely sufficient to root cause anything but trivial bugs). Alternatively, rmap_printk() could be reworked to into tracepoints, but it's not clear there is a real need as rmap bugs rarely escape initial development, and when bugs do escape to production, they are often edge cases and/or reside in code that isn't directly related to the rmaps. In other words, the problems with rmap_printk() being unhelpful also apply to tracepoints. And deleting rmap_printk() doesn't preclude adding tracepoints in the future. Signed-off-by: Sean Christopherson --- arch/x86/kvm/mmu/mmu.c | 12 ------------ arch/x86/kvm/mmu/mmu_internal.h | 2 -- 2 files changed, 14 deletions(-) diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index bc24d430db6e..8e36e07719bf 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -941,10 +941,8 @@ static int pte_list_add(struct kvm_mmu_memory_cache *c= ache, u64 *spte, int count =3D 0; =20 if (!rmap_head->val) { - rmap_printk("%p %llx 0->1\n", spte, *spte); rmap_head->val =3D (unsigned long)spte; } else if (!(rmap_head->val & 1)) { - rmap_printk("%p %llx 1->many\n", spte, *spte); desc =3D kvm_mmu_memory_cache_alloc(cache); desc->sptes[0] =3D (u64 *)rmap_head->val; desc->sptes[1] =3D spte; @@ -953,7 +951,6 @@ static int pte_list_add(struct kvm_mmu_memory_cache *ca= che, u64 *spte, rmap_head->val =3D (unsigned long)desc | 1; ++count; } else { - rmap_printk("%p %llx many->many\n", spte, *spte); desc =3D (struct pte_list_desc *)(rmap_head->val & ~1ul); count =3D desc->tail_count + desc->spte_count; =20 @@ -1018,14 +1015,12 @@ static void pte_list_remove(u64 *spte, struct kvm_r= map_head *rmap_head) pr_err("%s: %p 0->BUG\n", __func__, spte); BUG(); } else if (!(rmap_head->val & 1)) { - rmap_printk("%p 1->0\n", spte); if ((u64 *)rmap_head->val !=3D spte) { pr_err("%s: %p 1->BUG\n", __func__, spte); BUG(); } rmap_head->val =3D 0; } else { - rmap_printk("%p many->many\n", spte); desc =3D (struct pte_list_desc *)(rmap_head->val & ~1ul); while (desc) { for (i =3D 0; i < desc->spte_count; ++i) { @@ -1241,8 +1236,6 @@ static bool spte_write_protect(u64 *sptep, bool pt_pr= otect) !(pt_protect && is_mmu_writable_spte(spte))) return false; =20 - rmap_printk("spte %p %llx\n", sptep, *sptep); - if (pt_protect) spte &=3D ~shadow_mmu_writable_mask; spte =3D spte & ~PT_WRITABLE_MASK; @@ -1267,8 +1260,6 @@ static bool spte_clear_dirty(u64 *sptep) { u64 spte =3D *sptep; =20 - rmap_printk("spte %p %llx\n", sptep, *sptep); - MMU_WARN_ON(!spte_ad_enabled(spte)); spte &=3D ~shadow_dirty_mask; return mmu_spte_update(sptep, spte); @@ -1480,9 +1471,6 @@ static bool kvm_set_pte_rmap(struct kvm *kvm, struct = kvm_rmap_head *rmap_head, =20 restart: for_each_rmap_spte(rmap_head, &iter, sptep) { - rmap_printk("spte %p %llx gfn %llx (%d)\n", - sptep, *sptep, gfn, level); - need_flush =3D true; =20 if (pte_write(pte)) { diff --git a/arch/x86/kvm/mmu/mmu_internal.h b/arch/x86/kvm/mmu/mmu_interna= l.h index 4f1e4b327f40..9c9dd9340c63 100644 --- a/arch/x86/kvm/mmu/mmu_internal.h +++ b/arch/x86/kvm/mmu/mmu_internal.h @@ -11,10 +11,8 @@ #ifdef MMU_DEBUG extern bool dbg; =20 -#define rmap_printk(fmt, args...) do { if (dbg) printk("%s: " fmt, __func_= _, ## args); } while (0) #define MMU_WARN_ON(x) WARN_ON(x) #else -#define rmap_printk(x...) do { } while (0) #define MMU_WARN_ON(x) do { } while (0) #endif =20 --=20 2.41.0.487.g6d72f3e995-goog