From patchwork Mon May 8 11:47:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juergen Gross X-Patchwork-Id: 13234340 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 B0532C87FDC for ; Mon, 8 May 2023 11:48:54 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.531415.827085 (Exim 4.92) (envelope-from ) id 1pvzMB-0007S9-L8; Mon, 08 May 2023 11:48:43 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 531415.827085; Mon, 08 May 2023 11:48:43 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pvzMB-0007S0-Hc; Mon, 08 May 2023 11:48:43 +0000 Received: by outflank-mailman (input) for mailman id 531415; Mon, 08 May 2023 11:48:42 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pvzMA-0004FA-BZ for xen-devel@lists.xenproject.org; Mon, 08 May 2023 11:48:42 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 474ba90e-ed96-11ed-b226-6b7b168915f2; Mon, 08 May 2023 13:48:41 +0200 (CEST) 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-out2.suse.de (Postfix) with ESMTPS id 687D81FE43; Mon, 8 May 2023 11:48:41 +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 2AD791346B; Mon, 8 May 2023 11:48:41 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id IpQiCZnhWGRJNwAAMHmgww (envelope-from ); Mon, 08 May 2023 11:48:41 +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: 474ba90e-ed96-11ed-b226-6b7b168915f2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1683546521; 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=HoO5vhLxJfHeUF6CaN4B5hMFR55WKl59O7dl7jFaRfo=; b=Yz3s02wIMFCTIEwsPY87/4US/J/9IK8jK5QOI19zTpnkV5jTVuuwlHFacpPhig//JplOeA +2UgwIzGy6D00Eh2C19Udvu9LoX0bkWQNaQTzkRujwPMJtb9i02aAOWU/pDNJYz/eQvoih xIWnQ1eZcXqhAgqu+4Ug8dc78QTZ33I= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Wei Liu , Julien Grall , Anthony PERARD , Julien Grall Subject: [PATCH v5 08/14] tools/xenstore: add accounting trace support Date: Mon, 8 May 2023 13:47:48 +0200 Message-Id: <20230508114754.31514-9-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230508114754.31514-1-jgross@suse.com> References: <20230508114754.31514-1-jgross@suse.com> MIME-Version: 1.0 Add a new trace switch "acc" and the related trace calls. The "acc" switch is off per default. Signed-off-by: Juergen Gross Reviewed-by: Julien Grall --- tools/xenstore/xenstored_core.c | 2 +- tools/xenstore/xenstored_core.h | 1 + tools/xenstore/xenstored_domain.c | 10 ++++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_core.c index e7f86f9487..15654730a6 100644 --- a/tools/xenstore/xenstored_core.c +++ b/tools/xenstore/xenstored_core.c @@ -2750,7 +2750,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", + "obj", "io", "wrl", "acc", NULL }; diff --git a/tools/xenstore/xenstored_core.h b/tools/xenstore/xenstored_core.h index 1f811f38cb..3e0734a6c6 100644 --- a/tools/xenstore/xenstored_core.h +++ b/tools/xenstore/xenstored_core.h @@ -302,6 +302,7 @@ extern unsigned int trace_flags; #define TRACE_OBJ 0x00000001 #define TRACE_IO 0x00000002 #define TRACE_WRL 0x00000004 +#define TRACE_ACC 0x00000008 extern const char *const trace_switches[]; int set_trace_switch(const char *arg); diff --git a/tools/xenstore/xenstored_domain.c b/tools/xenstore/xenstored_domain.c index a35ed97fd7..03825ca24b 100644 --- a/tools/xenstore/xenstored_domain.c +++ b/tools/xenstore/xenstored_domain.c @@ -538,6 +538,12 @@ static struct domain *find_domain_by_domid(unsigned int domid) return (d && d->introduced) ? d : NULL; } +#define trace_acc(...) \ +do { \ + if (trace_flags & TRACE_ACC) \ + trace("acc: " __VA_ARGS__); \ +} while (0) + int acc_fix_domains(struct list_head *head, bool chk_quota, bool update) { struct changed_domain *cd; @@ -601,6 +607,8 @@ static int acc_add_changed_dom(const void *ctx, struct list_head *head, return 0; errno = 0; + trace_acc("local change domid %u: what=%u %d add %d\n", domid, what, + cd->acc[what], val); cd->acc[what] += val; return cd->acc[what]; @@ -1112,6 +1120,8 @@ static int domain_acc_add(struct connection *conn, unsigned int domid, return domain_acc_add_valid(d, what, ret); } + trace_acc("global change domid %u: what=%u %u add %d\n", domid, what, + d->acc[what], add); d->acc[what] = domain_acc_add_valid(d, what, add); return d->acc[what];