From nobody Mon Feb 9 19:05:55 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; dkim=pass; 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=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1680164245; cv=none; d=zohomail.com; s=zohoarc; b=eDDFNsdB3aux0fhwWEpaprNEpOgrHj2i9AfXubEGIv0Isgxkh7HvxpikqqKm+VlI5Aa3mN0fXmaKaE2O4XU0sU0gwSLrtkRoaIzqFAWxG6TjmqFuzWIN4m9KD2z7Glb25RAQtwDfqbr5fDXoUfmZa3OkrnU9gKLPqW4P0+Pb4kc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1680164245; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=JlFoqnoU3I4JMyJapnFZtevlraEzWmolnTL1zQ4kqcs=; b=BFw5IhHFepka65ixGxHDV9PNULUBn0ddbEeq73Kn7LzZCAcl6VkSEWjIVmd4+dYnVIULb7giqH7oeK+P6Rn/2KlmEkd+R0p4VhrTWfkWRY26IRXINm9dZ1Dj/9/2AppJbdPPT7FQRCN8l/hYuISATt/pa2aozn0yHUUA8e5P+as= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1680164245743249.91758299125672; Thu, 30 Mar 2023 01:17:25 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.516451.800553 (Exim 4.92) (envelope-from ) id 1phnSw-00029b-4c; Thu, 30 Mar 2023 08:17:02 +0000 Received: by outflank-mailman (output) from mailman id 516451.800553; Thu, 30 Mar 2023 08:17:02 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1phnSw-00029S-0a; Thu, 30 Mar 2023 08:17:02 +0000 Received: by outflank-mailman (input) for mailman id 516451; Thu, 30 Mar 2023 08:17:00 +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 1phnSu-0001Za-Eg for xen-devel@lists.xenproject.org; Thu, 30 Mar 2023 08:17:00 +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 3da95e72-ced3-11ed-b464-930f4c7d94ae; Thu, 30 Mar 2023 10:16:58 +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-out1.suse.de (Postfix) with ESMTPS id 78FDB21B24; Thu, 30 Mar 2023 08:16:58 +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 3EEC2138FF; Thu, 30 Mar 2023 08:16:58 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id KlbxDXpFJWTgEQAAMHmgww (envelope-from ); Thu, 30 Mar 2023 08:16:58 +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: 3da95e72-ced3-11ed-b464-930f4c7d94ae DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1680164218; 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=JlFoqnoU3I4JMyJapnFZtevlraEzWmolnTL1zQ4kqcs=; b=H/b2YXNveJyglmyfGcxvftTAagvblILn9lsKLxQfkpOa+gSICsOM4WNOCK/uN6T+yH/OU4 H53wOZ1/DKYrXg8mnoBzRIBLH9cx4nQgtgaAVh1GuvOszGPj7Wkdf4Kt46JGxc6Qddy6hx Ry1Dk3bmqFXYOKx3Tq9B91OYCyO6PMM= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Wei Liu , Julien Grall , Anthony PERARD , Julien Grall Subject: [PATCH v3 02/13] tools/xenstore: manage per-transaction domain accounting data in an array Date: Thu, 30 Mar 2023 10:16:33 +0200 Message-Id: <20230330081644.11480-3-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230330081644.11480-1-jgross@suse.com> References: <20230330081644.11480-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1680164247528100001 Content-Type: text/plain; charset="utf-8" In order to prepare keeping accounting data in an array instead of using independent fields, switch the struct changed_domain accounting data to that scheme, for now only using an array with one element. In order to be able to extend this scheme add the needed indexing enum to xenstored_domain.h. Signed-off-by: Juergen Gross Reviewed-by: Julien Grall --- V2: - make "what" parameter of acc_add_changed_dom() an enum type, and assert() that it won't exceed the accounting array (Julien Grall) --- tools/xenstore/xenstored_domain.c | 19 +++++++++++-------- tools/xenstore/xenstored_domain.h | 10 ++++++++++ 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/tools/xenstore/xenstored_domain.c b/tools/xenstore/xenstored_d= omain.c index dbbf97accc..609a9a13ab 100644 --- a/tools/xenstore/xenstored_domain.c +++ b/tools/xenstore/xenstored_domain.c @@ -99,8 +99,8 @@ struct changed_domain /* Identifier of the changed domain. */ unsigned int domid; =20 - /* Amount by which this domain's nbentry field has changed. */ - int nbentry; + /* Accounting data. */ + int acc[ACC_TR_N]; }; =20 static struct hashtable *domhash; @@ -550,7 +550,7 @@ int acc_fix_domains(struct list_head *head, bool chk_qu= ota, bool update) int cnt; =20 list_for_each_entry(cd, head, list) { - cnt =3D domain_nbentry_fix(cd->domid, cd->nbentry, update); + cnt =3D domain_nbentry_fix(cd->domid, cd->acc[ACC_NODES], update); if (!update) { if (chk_quota && cnt >=3D quota_nb_entry_per_domain) return ENOSPC; @@ -595,19 +595,21 @@ static struct changed_domain *acc_get_changed_domain(= const void *ctx, return cd; } =20 -static int acc_add_dom_nbentry(const void *ctx, struct list_head *head, in= t val, - unsigned int domid) +static int acc_add_changed_dom(const void *ctx, struct list_head *head, + enum accitem what, int val, unsigned int domid) { struct changed_domain *cd; =20 + assert(what < ARRAY_SIZE(cd->acc)); + cd =3D acc_get_changed_domain(ctx, head, domid); if (!cd) return 0; =20 errno =3D 0; - cd->nbentry +=3D val; + cd->acc[what] +=3D val; =20 - return cd->nbentry; + return cd->acc[what]; } =20 static void domain_conn_reset(struct domain *domain) @@ -1071,7 +1073,8 @@ static int domain_nbentry_add(struct connection *conn= , unsigned int domid, =20 if (conn && conn->transaction) { head =3D transaction_get_changed_domains(conn->transaction); - ret =3D acc_add_dom_nbentry(conn->transaction, head, add, domid); + ret =3D acc_add_changed_dom(conn->transaction, head, ACC_NODES, + add, domid); if (errno) { fail_transaction(conn->transaction); return -1; diff --git a/tools/xenstore/xenstored_domain.h b/tools/xenstore/xenstored_d= omain.h index 279cccb3ad..40803574f6 100644 --- a/tools/xenstore/xenstored_domain.h +++ b/tools/xenstore/xenstored_domain.h @@ -19,6 +19,16 @@ #ifndef _XENSTORED_DOMAIN_H #define _XENSTORED_DOMAIN_H =20 +/* + * All accounting data is stored in a per-domain array. + * Depending on the account item there might be other scopes as well, like= e.g. + * a per transaction array. + */ +enum accitem { + ACC_NODES, + ACC_TR_N, /* Number of elements per transaction. */ +}; + void handle_event(void); =20 void check_domains(void); --=20 2.35.3