From nobody Mon Feb 9 13:00:29 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 1BC3CC001E0 for ; Fri, 21 Jul 2023 23:00:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231168AbjGUXAS (ORCPT ); Fri, 21 Jul 2023 19:00:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231132AbjGUXAO (ORCPT ); Fri, 21 Jul 2023 19:00:14 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE84B3A93 for ; Fri, 21 Jul 2023 16:00:12 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-c5a479bc2d4so2311570276.1 for ; Fri, 21 Jul 2023 16:00:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1689980412; x=1690585212; 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=hx05lOSKevEnFTjhQmIFaPmCZWGUtEHn8FPIM5Bki+UcSqPi4IntQeAWTUj+y16Q3C VsMT2vKpEPje3bE2F0xUf0GMW5chsQEeSL/rUzNBHYE0ccg3hQtfK6AT50tUNffQ+8JG 2lay9BL2a9yTqI12d+ssVhmL3OUE4QhP5T2TLWlFFWWHXSAqQObIEcB/e+q7NdsNjEj4 UCEjIIafqyus+s+Yz/Sjnh+LhYRgVyo596begODfAr9zRbpusbnFttvuh4cZFl+MJM9s LeXrJ1BKKbDZ6/OgzBfbvkzPH93TO2gneJJqKXJtvdEHeUxwyOVwVtabahG+/177jK4Z NLSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689980412; x=1690585212; 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=A7ZfkFDWIfS9UqBtNV6HVmtsYJqPPkFny0iK5wyX+y62xwSZ0hUl6cY7r9PWhY6fwc kUEW3o1j1ij6RUdgX0b9/MPXzeD1oUMqrwlJIwfZiDDI/phHdLrTrQZbSPk2PuawgV3l wpWXtfT4hys2z2I46bSyTxxuIwywO2iDx7bu7CK0llQ9f1H07XDG6iPvEIalcqKbcw8z SYhktFjFyGItS3G4YikrGbvIaDIws+0P0RSTcPF9mT1oBnTi5ulubatCx+FEIzmOGLTr sgj8ss401iD62e0H0sPnAwx3YKUNd7xsd5YThniTLgUV6LDHuAhwEmJ29ov6rmPOiwqJ 2bxA== X-Gm-Message-State: ABy/qLa1Dz8WAUjT9oo334FO/OiztQ3kNwfKLfT8mWeljqQGsM/6EpjK xqyLBKwj16j4sl4zqm08G3Mbd5rthTw= X-Google-Smtp-Source: APBJJlFJ/eOkeJGXEeW0uRAXDqLwIw2mNwIfFaPZWB6Xz5oFPGi7eUqiR679QoROZxoeZJEJY3G6J0NMJ0g= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6902:1388:b0:d05:38ba:b616 with SMTP id x8-20020a056902138800b00d0538bab616mr12927ybu.6.1689980411985; Fri, 21 Jul 2023 16:00:11 -0700 (PDT) Reply-To: Sean Christopherson Date: Fri, 21 Jul 2023 15:59:58 -0700 In-Reply-To: <20230721230006.2337941-1-seanjc@google.com> Mime-Version: 1.0 References: <20230721230006.2337941-1-seanjc@google.com> X-Mailer: git-send-email 2.41.0.487.g6d72f3e995-goog Message-ID: <20230721230006.2337941-2-seanjc@google.com> Subject: [PATCH v2 1/9] 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