From nobody Mon Apr 13 03:41:38 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=quarantine dis=quarantine) header.from=suse.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1772718776347112.80974848574454; Thu, 5 Mar 2026 05:52:56 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1246681.1545818 (Exim 4.92) (envelope-from ) id 1vy984-0001aH-KE; Thu, 05 Mar 2026 13:52:40 +0000 Received: by outflank-mailman (output) from mailman id 1246681.1545818; Thu, 05 Mar 2026 13:52:40 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vy984-0001ZW-Fu; Thu, 05 Mar 2026 13:52:40 +0000 Received: by outflank-mailman (input) for mailman id 1246681; Thu, 05 Mar 2026 13:52:39 +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 1vy983-00008m-Dt for xen-devel@lists.xenproject.org; Thu, 05 Mar 2026 13:52:39 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 91e25457-189a-11f1-9ccf-f158ae23cfc8; Thu, 05 Mar 2026 14:52:37 +0100 (CET) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 958FC3ED7C; Thu, 5 Mar 2026 13:52:37 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 756F13EA68; Thu, 5 Mar 2026 13:52:37 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id TT6VG6WKqWmETgAAD6G6ig (envelope-from ); Thu, 05 Mar 2026 13:52:37 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version 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: 91e25457-189a-11f1-9ccf-f158ae23cfc8 Authentication-Results: smtp-out1.suse.de; none From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Julien Grall , Anthony PERARD Subject: [PATCH 05/11] tools/xenstored: split acc[] array in struct domain Date: Thu, 5 Mar 2026 14:52:02 +0100 Message-ID: <20260305135208.2208663-6-jgross@suse.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260305135208.2208663-1-jgross@suse.com> References: <20260305135208.2208663-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Queue-Id: 958FC3ED7C X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Spam-Score: -4.00 X-Spam-Level: X-Spam-Flag: NO X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-ZM-MESSAGEID: 1772718776772158500 Content-Type: text/plain; charset="utf-8" Prepare using per-domain quota by splitting the acc[] array in struct domain into an array with the current accounting data, and an array of type struct quota for the per-domain quota and the seen max value of the domain. Signed-off-by: Juergen Gross Reviewed-by: Anthony PERARD --- tools/xenstored/domain.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/tools/xenstored/domain.c b/tools/xenstored/domain.c index 694ae58973..9bd3ac7aca 100644 --- a/tools/xenstored/domain.c +++ b/tools/xenstored/domain.c @@ -140,10 +140,8 @@ struct domain bool introduced; =20 /* Accounting data for this domain. */ - struct acc { - unsigned int val; - unsigned int max; - } acc[ACC_N]; + unsigned int acc_val[ACC_N]; + struct quota acc[ACC_N]; =20 /* Memory quota data for this domain. */ bool soft_quota_reported; @@ -410,7 +408,7 @@ bool domain_check_quota_add(struct domain *d, enum acci= tem what, int add) if (add < 0 || !d) return false; =20 - return domain_check_quota_val(d, what, d->acc[what].val + add); + return domain_check_quota_val(d, what, d->acc_val[what] + add); } =20 static bool check_indexes(XENSTORE_RING_IDX cons, XENSTORE_RING_IDX prod) @@ -582,7 +580,7 @@ static int domain_tree_remove_sub(const void *ctx, stru= ct connection *conn, ret =3D WALK_TREE_SKIP_CHILDREN; } =20 - return domain->acc[ACC_NODES].val ? ret : WALK_TREE_SUCCESS_STOP; + return domain->acc_val[ACC_NODES] ? ret : WALK_TREE_SUCCESS_STOP; } =20 static void domain_tree_remove(struct domain *domain) @@ -590,7 +588,7 @@ static void domain_tree_remove(struct domain *domain) int ret; struct walk_funcs walkfuncs =3D { .enter =3D domain_tree_remove_sub }; =20 - if (domain->acc[ACC_NODES].val) { + if (domain->acc_val[ACC_NODES]) { ret =3D walk_node_tree(domain, NULL, "/", &walkfuncs, domain); if (ret =3D=3D WALK_TREE_ERROR_STOP) syslog(LOG_ERR, @@ -774,7 +772,7 @@ int domain_get_quota(const void *ctx, struct connection= *conn, continue; resp =3D talloc_asprintf_append(resp, "%-17s: %8u (max %8u)\n", quota_adm[i].name, - d->acc[i].val, d->acc[i].max); + d->acc_val[i], d->acc[i].max); if (!resp) return ENOMEM; } @@ -1637,10 +1635,10 @@ static int domain_acc_add_valid(struct domain *d, e= num accitem what, int add) { unsigned int val; =20 - assert(what < ARRAY_SIZE(d->acc)); + assert(what < ARRAY_SIZE(d->acc_val)); =20 - if ((add < 0 && -add > d->acc[what].val) || - (add > 0 && (INT_MAX - d->acc[what].val) < add)) { + if ((add < 0 && -add > d->acc_val[what]) || + (add > 0 && (INT_MAX - d->acc_val[what]) < add)) { /* * In a transaction when a node is being added/removed AND the * same node has been added/removed outside the transaction in @@ -1651,7 +1649,7 @@ static int domain_acc_add_valid(struct domain *d, enu= m accitem what, int add) return (add < 0) ? 0 : INT_MAX; } =20 - val =3D d->acc[what].val + add; + val =3D d->acc_val[what] + add; domain_acc_valid_max(d, what, val); =20 return val; @@ -1710,10 +1708,10 @@ static int domain_acc_add(struct connection *conn, = unsigned int domid, } =20 trace_acc("global change domid %u: what=3D%u %u add %d\n", domid, what, - d->acc[what].val, add); - d->acc[what].val =3D domain_acc_add_valid(d, what, add); + d->acc_val[what], add); + d->acc_val[what] =3D domain_acc_add_valid(d, what, add); =20 - return d->acc[what].val; + return d->acc_val[what]; } =20 void acc_drop(struct connection *conn) @@ -1757,7 +1755,7 @@ static int domain_reset_global_acc_sub(const void *k,= void *v, void *arg) unsigned int i; =20 for (i =3D 0; i < ACC_N; i++) - d->acc[i].max =3D d->acc[i].val; + d->acc[i].max =3D d->acc_val[i]; =20 return 0; } @@ -2193,7 +2191,7 @@ static int domain_check_acc_init_sub(const void *k, v= oid *v, void *arg) * If everything is correct incrementing the value for each node will * result in dom->nodes being 0 at the end. */ - dom->nodes =3D -d->acc[ACC_NODES].val; + dom->nodes =3D -d->acc_val[ACC_NODES]; =20 if (hashtable_add(domains, &dom->domid, dom)) { talloc_free(dom); @@ -2248,7 +2246,7 @@ static int domain_check_acc_cb(const void *k, void *v= , void *arg) if (!d) return 0; =20 - d->acc[ACC_NODES].val +=3D dom->nodes; + d->acc_val[ACC_NODES] +=3D dom->nodes; =20 return 0; } --=20 2.53.0