From patchwork Fri Jan 20 10:00:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= X-Patchwork-Id: 13109586 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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 58D18C25B50 for ; Fri, 20 Jan 2023 10:05:50 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.481617.746654 (Exim 4.92) (envelope-from ) id 1pIoH7-0007I2-KV; Fri, 20 Jan 2023 10:05:33 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 481617.746654; Fri, 20 Jan 2023 10:05:33 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pIoH7-0007GB-Cj; Fri, 20 Jan 2023 10:05:33 +0000 Received: by outflank-mailman (input) for mailman id 481617; Fri, 20 Jan 2023 10:05:31 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pIoD8-0001b3-FH for xen-devel@lists.xenproject.org; Fri, 20 Jan 2023 10:01:26 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 65e5e489-98a9-11ed-b8d1-410ff93cb8f0; Fri, 20 Jan 2023 11:01:24 +0100 (CET) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 6514D22A07; Fri, 20 Jan 2023 10:01:24 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 381F41390C; Fri, 20 Jan 2023 10:01:24 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id UedeDHRmymNzRQAAMHmgww (envelope-from ); Fri, 20 Jan 2023 10:01:24 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 65e5e489-98a9-11ed-b8d1-410ff93cb8f0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1674208884; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LDP/2l4XV0mX1a+kmKrjEYO+V+0LM+WGrR3gQ8QJU00=; b=Y5HVigNP9PQCWUPsTpJnYBdmzoiC/ZtbT9qctkOR8Ui/6xfcKNMQCLfebIV8PskFdSR4zV keXB2rnZjC7J48GSB+6uBQSAxT4AphZRjWIr8/7+gq0vz1xNKL3J8O3ILblxTnBaOuOwqm GccoU/E1e98yvYjJLF3A2/F1ecX+2gY= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Wei Liu , Julien Grall , Anthony PERARD Subject: [PATCH v2 09/13] tools/xenstore: add TDB access trace support Date: Fri, 20 Jan 2023 11:00:24 +0100 Message-Id: <20230120100028.11142-10-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230120100028.11142-1-jgross@suse.com> References: <20230120100028.11142-1-jgross@suse.com> MIME-Version: 1.0 Add a new trace switch "tdb" and the related trace calls. The "tdb" switch is off per default. Signed-off-by: Juergen Gross Reviewed-by: Julien Grall --- tools/xenstore/xenstored_core.c | 8 +++++++- tools/xenstore/xenstored_core.h | 6 ++++++ tools/xenstore/xenstored_transaction.c | 7 ++++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_core.c index 558ef491b1..49e196e7ae 100644 --- a/tools/xenstore/xenstored_core.c +++ b/tools/xenstore/xenstored_core.c @@ -589,6 +589,8 @@ static void get_acc_data(TDB_DATA *key, struct node_account_data *acc) if (old_data.dptr == NULL) { acc->memory = 0; } else { + trace_tdb("read %s size %zu\n", key->dptr, + old_data.dsize + key->dsize); hdr = (void *)old_data.dptr; acc->memory = old_data.dsize; acc->domid = hdr->perms[0].id; @@ -655,6 +657,7 @@ int do_tdb_write(struct connection *conn, TDB_DATA *key, TDB_DATA *data, errno = EIO; return errno; } + trace_tdb("store %s size %zu\n", key->dptr, data->dsize + key->dsize); if (acc) { /* Don't use new_domid, as it might be a transaction node. */ @@ -682,6 +685,7 @@ int do_tdb_delete(struct connection *conn, TDB_DATA *key, errno = EIO; return errno; } + trace_tdb("delete %s\n", key->dptr); if (acc->memory) { domid = get_acc_domid(conn, key, acc->domid); @@ -731,6 +735,8 @@ struct node *read_node(struct connection *conn, const void *ctx, goto error; } + trace_tdb("read %s size %zu\n", key.dptr, data.dsize + key.dsize); + node->parent = NULL; talloc_steal(node, data.dptr); @@ -2746,7 +2752,7 @@ static void set_quota(const char *arg, bool soft) /* Sorted by bit values of TRACE_* flags. Flag is (1u << index). */ const char *const trace_switches[] = { - "obj", "io", "wrl", "acc", + "obj", "io", "wrl", "acc", "tdb", NULL }; diff --git a/tools/xenstore/xenstored_core.h b/tools/xenstore/xenstored_core.h index 3e0734a6c6..419a144396 100644 --- a/tools/xenstore/xenstored_core.h +++ b/tools/xenstore/xenstored_core.h @@ -303,8 +303,14 @@ extern unsigned int trace_flags; #define TRACE_IO 0x00000002 #define TRACE_WRL 0x00000004 #define TRACE_ACC 0x00000008 +#define TRACE_TDB 0x00000010 extern const char *const trace_switches[]; int set_trace_switch(const char *arg); +#define trace_tdb(...) \ +do { \ + if (trace_flags & TRACE_TDB) \ + trace("tdb: " __VA_ARGS__); \ +} while (0) extern TDB_CONTEXT *tdb_ctx; extern int dom0_domid; diff --git a/tools/xenstore/xenstored_transaction.c b/tools/xenstore/xenstored_transaction.c index 1aa9d3cb3d..19a1175d1b 100644 --- a/tools/xenstore/xenstored_transaction.c +++ b/tools/xenstore/xenstored_transaction.c @@ -366,8 +366,11 @@ static int finalize_transaction(struct connection *conn, if (tdb_error(tdb_ctx) != TDB_ERR_NOEXIST) return EIO; gen = NO_GENERATION; - } else + } else { + trace_tdb("read %s size %zu\n", key.dptr, + key.dsize + data.dsize); gen = hdr->generation; + } talloc_free(data.dptr); if (i->generation != gen) return EAGAIN; @@ -391,6 +394,8 @@ static int finalize_transaction(struct connection *conn, set_tdb_key(i->trans_name, &ta_key); data = tdb_fetch(tdb_ctx, ta_key); if (data.dptr) { + trace_tdb("read %s size %zu\n", ta_key.dptr, + ta_key.dsize + data.dsize); hdr = (void *)data.dptr; hdr->generation = ++generation; *is_corrupt |= do_tdb_write(conn, &key, &data,