From nobody Tue Nov 26 15:46:58 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1706888379; cv=none; d=zohomail.com; s=zohoarc; b=KSvtnsgYujqJaXBlPjt5KsIQm621cyU36auaGJme2bHoSmwLvvbZJepPQEhOd5n+fbN6cSt0AXHXWHVQ3p5djMdYeV2H9UOiVARciguMnATXdImqHrB+1NYSrFKq8895GGklyTgZWqvMiVr6elqKgCQ+HEkfzjYuksasBXMltUY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706888379; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=w0fahzk6p7Uj8He02ARe/ArkwaOEVmzA6eqTYfNKviw=; b=Ksxi3aovN42WT1fBa6xIjnNF0ynmNsnU+Z6DMSJaNigD/2qZZfTCrWw6IQDKGD1m38LkPYR/T4fC9hI7iJyXXYYKCq5HJNZCHkOrbrYNxcWD1tjeDKQrOAnNVtfGvGPHOq/D3ZgYVg9xfUrbyBzcUG/nX6pO/1HMivx4+5qCRys= 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 1706888379642233.3011062063008; Fri, 2 Feb 2024 07:39:39 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rVvb6-0000Nh-7I; Fri, 02 Feb 2024 10:36:56 -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 1rVvb4-0000Mf-JS for qemu-devel@nongnu.org; Fri, 02 Feb 2024 10:36:54 -0500 Received: from mail-lj1-x231.google.com ([2a00:1450:4864:20::231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rVvb2-0004Wr-Eu for qemu-devel@nongnu.org; Fri, 02 Feb 2024 10:36:54 -0500 Received: by mail-lj1-x231.google.com with SMTP id 38308e7fff4ca-2d07d74be60so19392301fa.3 for ; Fri, 02 Feb 2024 07:36:52 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id k2-20020a05600c1c8200b0040fafd84095sm214735wms.41.2024.02.02.07.36.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 07:36:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706888211; x=1707493011; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=w0fahzk6p7Uj8He02ARe/ArkwaOEVmzA6eqTYfNKviw=; b=Wnu6+r8GvE5IDJ53s2pb5aC7dR5eqXIG5/abg6yoqM5Qk03hFwGRI7XRwi0XVND8NK 3iStqFR95a00qB1jPV4bV3hHWJ37tl5HzAj/BdXd6mHpr3w2e0fUZnAK65Zd4lktP9sm kfnKirE6FLNm40w7IiKfRXIDctJoMeAMCYgtyHXtMxTiV7wpI26yZj8PiHeks4ZJmneD Uip10XVjMcUm6zwpi+2A3aP2RvRgohxxkToaVAhn97YY6D42ori0XgFBK4OGK/X3Ba4y rLUvB6h2IwUW8DVqVlJlGvoXZJK/+48xpaxObTc93AYsLW71pDmcTogq/BIZFygezkZR iveA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706888211; x=1707493011; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=w0fahzk6p7Uj8He02ARe/ArkwaOEVmzA6eqTYfNKviw=; b=LMF9s0v8H39A78xDT+cJKaEHbQW5Jk2kJX8FZZXfWEguWuundgAEjZXPYfReB20TiL psBcZeMNXQwcrEqXE9gebukR9+jXlWSuzySiEMgd/l4qMYxCCAKzPI9Y9qkiMAqKMRi8 U5Mxu8nWKFoTDe0s+U5GcEn95PR8JHoc8NNqcVqn0yh3Ss+54OzwlRfbf0LgjJzokhex wWJ3b1OsLow8RHblrlYwKQYHKZ4GkorM2HU6j9trVjvnTODZslaR8YUUqSb2l3/4HRYP GbcJydccIN8eF5s0mYgAsHVh7HrlBK14yIsKm4lsJIHiy5rp13FXTXeh1kSCj0kz18VS e8IA== X-Gm-Message-State: AOJu0YwiBJuZyT4K/9IvoUZP3vEWYtgsentYOmH6FlKIu2S0bBLN7mX/ +jgk90gprPUEHaMNCKV4wQYjeA9IEqzEP0jQbOu+FGSZ12Vu/4AichAE1YCQBX6bhziXumNh1JA M X-Google-Smtp-Source: AGHT+IGT17CBaIEaX3yRzq7jGWA6DoOCrslONo1XwrI7bYvL93AHgRGZGREqgmRf0KJuArfofAqL3Q== X-Received: by 2002:ac2:4549:0:b0:511:34ff:2bb6 with SMTP id j9-20020ac24549000000b0051134ff2bb6mr1293871lfm.41.1706888210700; Fri, 02 Feb 2024 07:36:50 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 26/36] hw/xen/xen-mapcache.c: convert DPRINTF to tracepoints Date: Fri, 2 Feb 2024 15:36:27 +0000 Message-Id: <20240202153637.3710444-27-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240202153637.3710444-1-peter.maydell@linaro.org> References: <20240202153637.3710444-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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=2a00:1450:4864:20::231; envelope-from=peter.maydell@linaro.org; helo=mail-lj1-x231.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, 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 @linaro.org) X-ZM-MESSAGEID: 1706888380416100001 From: Manos Pitsidianakis Tracing DPRINTFs to stderr might not be desired. A developer that relies on tracepoints should be able to opt-in to each tracepoint and rely on QEMU's log redirection, instead of stderr by default. This commit converts DPRINTFs in this file that are used for tracing into tracepoints. Signed-off-by: Manos Pitsidianakis Reviewed-by: Alex Benn=C3=A9e Message-id: 2fbe1fbc59078e384761c932e97cfa4276a53d75.1706544115.git.manos.p= itsidianakis@linaro.org Signed-off-by: Peter Maydell --- hw/xen/xen-mapcache.c | 54 +++++++++++++++++++------------------------ hw/xen/trace-events | 11 +++++++++ 2 files changed, 35 insertions(+), 30 deletions(-) diff --git a/hw/xen/xen-mapcache.c b/hw/xen/xen-mapcache.c index f7d974677d1..336c2123767 100644 --- a/hw/xen/xen-mapcache.c +++ b/hw/xen/xen-mapcache.c @@ -22,16 +22,6 @@ #include "trace.h" =20 =20 -//#define MAPCACHE_DEBUG - -#ifdef MAPCACHE_DEBUG -# define DPRINTF(fmt, ...) do { \ - fprintf(stderr, "xen_mapcache: " fmt, ## __VA_ARGS__); \ -} while (0) -#else -# define DPRINTF(fmt, ...) do { } while (0) -#endif - #if HOST_LONG_BITS =3D=3D 32 # define MCACHE_BUCKET_SHIFT 16 # define MCACHE_MAX_SIZE (1UL<<31) /* 2GB Cap */ @@ -145,8 +135,7 @@ void xen_map_cache_init(phys_offset_to_gaddr_t f, void = *opaque) =20 size =3D mapcache->nr_buckets * sizeof (MapCacheEntry); size =3D (size + XC_PAGE_SIZE - 1) & ~(XC_PAGE_SIZE - 1); - DPRINTF("%s, nr_buckets =3D %lx size %lu\n", __func__, - mapcache->nr_buckets, size); + trace_xen_map_cache_init(mapcache->nr_buckets, size); mapcache->entry =3D g_malloc0(size); } =20 @@ -286,7 +275,9 @@ tryagain: test_bits(address_offset >> XC_PAGE_SHIFT, test_bit_size >> XC_PAGE_SHIFT, mapcache->last_entry->valid_mapping)) { - trace_xen_map_cache_return(mapcache->last_entry->vaddr_base + addr= ess_offset); + trace_xen_map_cache_return( + mapcache->last_entry->vaddr_base + address_offset + ); return mapcache->last_entry->vaddr_base + address_offset; } =20 @@ -368,7 +359,9 @@ tryagain: QTAILQ_INSERT_HEAD(&mapcache->locked_entries, reventry, next); } =20 - trace_xen_map_cache_return(mapcache->last_entry->vaddr_base + address_= offset); + trace_xen_map_cache_return( + mapcache->last_entry->vaddr_base + address_offset + ); return mapcache->last_entry->vaddr_base + address_offset; } =20 @@ -402,10 +395,10 @@ ram_addr_t xen_ram_addr_from_mapcache(void *ptr) } } if (!found) { - fprintf(stderr, "%s, could not find %p\n", __func__, ptr); + trace_xen_ram_addr_from_mapcache_not_found(ptr); QTAILQ_FOREACH(reventry, &mapcache->locked_entries, next) { - DPRINTF(" "HWADDR_FMT_plx" -> %p is present\n", reventry->pa= ddr_index, - reventry->vaddr_req); + trace_xen_ram_addr_from_mapcache_found(reventry->paddr_index, + reventry->vaddr_req); } abort(); return 0; @@ -416,7 +409,7 @@ ram_addr_t xen_ram_addr_from_mapcache(void *ptr) entry =3D entry->next; } if (!entry) { - DPRINTF("Trying to find address %p that is not in the mapcache!\n"= , ptr); + trace_xen_ram_addr_from_mapcache_not_in_cache(ptr); raddr =3D 0; } else { raddr =3D (reventry->paddr_index << MCACHE_BUCKET_SHIFT) + @@ -443,9 +436,12 @@ static void xen_invalidate_map_cache_entry_unlocked(ui= nt8_t *buffer) } } if (!found) { - DPRINTF("%s, could not find %p\n", __func__, buffer); + trace_xen_invalidate_map_cache_entry_unlocked_not_found(buffer); QTAILQ_FOREACH(reventry, &mapcache->locked_entries, next) { - DPRINTF(" "HWADDR_FMT_plx" -> %p is present\n", reventry->pa= ddr_index, reventry->vaddr_req); + trace_xen_invalidate_map_cache_entry_unlocked_found( + reventry->paddr_index, + reventry->vaddr_req + ); } return; } @@ -463,7 +459,7 @@ static void xen_invalidate_map_cache_entry_unlocked(uin= t8_t *buffer) entry =3D entry->next; } if (!entry) { - DPRINTF("Trying to unmap address %p that is not in the mapcache!\n= ", buffer); + trace_xen_invalidate_map_cache_entry_unlocked_miss(buffer); return; } entry->lock--; @@ -502,9 +498,8 @@ void xen_invalidate_map_cache(void) if (!reventry->dma) { continue; } - fprintf(stderr, "Locked DMA mapping while invalidating mapcache!" - " "HWADDR_FMT_plx" -> %p is present\n", - reventry->paddr_index, reventry->vaddr_req); + trace_xen_invalidate_map_cache(reventry->paddr_index, + reventry->vaddr_req); } =20 for (i =3D 0; i < mapcache->nr_buckets; i++) { @@ -562,24 +557,23 @@ static uint8_t *xen_replace_cache_entry_unlocked(hwad= dr old_phys_addr, entry =3D entry->next; } if (!entry) { - DPRINTF("Trying to update an entry for "HWADDR_FMT_plx \ - "that is not in the mapcache!\n", old_phys_addr); + trace_xen_replace_cache_entry_unlocked(old_phys_addr); return NULL; } =20 address_index =3D new_phys_addr >> MCACHE_BUCKET_SHIFT; address_offset =3D new_phys_addr & (MCACHE_BUCKET_SIZE - 1); =20 - fprintf(stderr, "Replacing a dummy mapcache entry for "HWADDR_FMT_plx \ - " with "HWADDR_FMT_plx"\n", old_phys_addr, new_phys_addr); + trace_xen_replace_cache_entry_dummy(old_phys_addr, new_phys_addr); =20 xen_remap_bucket(entry, entry->vaddr_base, cache_size, address_index, false); if (!test_bits(address_offset >> XC_PAGE_SHIFT, test_bit_size >> XC_PAGE_SHIFT, entry->valid_mapping)) { - DPRINTF("Unable to update a mapcache entry for "HWADDR_FMT_plx"!\n= ", - old_phys_addr); + trace_xen_replace_cache_entry_unlocked_could_not_update_entry( + old_phys_addr + ); return NULL; } =20 diff --git a/hw/xen/trace-events b/hw/xen/trace-events index 67a6c419260..a65dc0e55fd 100644 --- a/hw/xen/trace-events +++ b/hw/xen/trace-events @@ -60,3 +60,14 @@ cpu_ioreq_config_write(void *req, uint32_t sbdf, uint32_= t reg, uint32_t size, ui xen_map_cache(uint64_t phys_addr) "want 0x%"PRIx64 xen_remap_bucket(uint64_t index) "index 0x%"PRIx64 xen_map_cache_return(void* ptr) "%p" +xen_map_cache_init(uint64_t nr_buckets, uint64_t size) "nr_buckets =3D 0x%= "PRIx64" size 0x%"PRIx64 +xen_replace_cache_entry_dummy(uint64_t old_phys_addr, uint64_t new_phys_ad= dr) "Replacing a dummy mapcache entry for 0x%"PRIx64" with 0x%"PRIx64 +xen_invalidate_map_cache_entry_unlocked_not_found(void *p) "could not find= %p" +xen_invalidate_map_cache_entry_unlocked_found(uint64_t addr, void *p) " = 0x%"PRIx64" -> %p is present" +xen_invalidate_map_cache_entry_unlocked_miss(void *buffer) "Trying to unma= p address %p that is not in the mapcache" +xen_replace_cache_entry_unlocked_could_not_update_entry(uint64_t old_phys_= addr) "Unable to update a mapcache entry for 0x%"PRIx64 +xen_ram_addr_from_mapcache_not_found(void *p) "could not find %p" +xen_ram_addr_from_mapcache_found(uint64_t addr, void *p) " 0x%"PRIx64" -= > %p is present" +xen_ram_addr_from_mapcache_not_in_cache(void *p) "Trying to find address %= p that is not in the mapcache" +xen_replace_cache_entry_unlocked(uint64_t old_phys_addr) "Trying to update= an entry for 0x%"PRIx64" that is not in the mapcache" +xen_invalidate_map_cache(uint64_t paddr_index, void *vaddr_req) "Locked DM= A mapping while invalidating mapcache 0x%"PRIx64" -> %p is present" --=20 2.34.1