xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Juergen Gross <jgross@suse.com>
To: Julien Grall <julien@xen.org>, xen-devel@lists.xenproject.org
Cc: Wei Liu <wl@xen.org>, Anthony PERARD <anthony.perard@citrix.com>
Subject: Re: [PATCH v2 04/13] tools/xenstore: add framework to commit accounting data on success only
Date: Wed, 22 Feb 2023 09:52:04 +0100	[thread overview]
Message-ID: <292847c2-02b8-b190-8439-75ddb9ff4cb0@suse.com> (raw)
In-Reply-To: <6b9b0afc-da89-6f6f-859f-c8f7ae0be972@xen.org>


[-- Attachment #1.1.1: Type: text/plain, Size: 4892 bytes --]

On 21.02.23 23:42, Julien Grall wrote:
> Hi Juergen,
> 
> On 21/02/2023 08:37, Juergen Gross wrote:
>> On 20.02.23 23:50, Julien Grall wrote:
>>>> +        list_del(&cd->list);
>>>> +        talloc_free(cd);
>>>> +    }
>>>> +}
>>>> +
>>>> +void acc_commit(struct connection *conn)
>>>> +{
>>>> +    struct changed_domain *cd;
>>>> +    struct buffered_data *in = conn->in;
>>>> +    enum accitem what;
>>>> +
>>>> +    conn->in = NULL; /* Avoid recursion. */
>>>
>>> I am not sure I understand this comment. Can you provide more details where 
>>> the recursion would happen?
>>
>> domain_acc_add() might do temporary accounting if conn->in isn't NULL.
> 
> I am confused. To me recursion means the function (or the caller) will call 
> itself. But here you seem to say you just want to avoid temporary accounting.

It is basically data recursion. Trying to apply temporary accounting data
leading to that temporary accounting data being modified again might result
in endless loops.

> What did I miss?
> 
>>
>>>
>>>> +    while ((cd = list_top(&conn->acc_list, struct changed_domain, list))) {
>>>
>>> NIT: You could use list_for_each_safe();
>>
>> Like above.
>>
>>>
>>>> +        list_del(&cd->list);
>>>> +        for (what = 0; what < ACC_REQ_N; what++)
>>>
>>> There is a chance that some compiler will complain about this line because 
>>> ACC_REQ_N = 0. So this would always be true. Therefore...
>>
>> Huh? It would always be false.
> 
> Yes false sorry. This doesn't change about the potential (temporary) warning.

Shouldn't that rather result in dead code elimination instead?

> 
>>
>>>
>>>> +            if (cd->acc[what])
>>>> +                domain_acc_add(conn, cd->domid, what,
>>>> +                           cd->acc[what], true);
>>>> +
>>>> +        talloc_free(cd);
>>>> +    }
>>>> +
>>>> +    conn->in = in;
>>>> +}
>>>> +
>>>>   int domain_nbentry_inc(struct connection *conn, unsigned int domid)
>>>>   {
>>>>       return (domain_acc_add(conn, domid, ACC_NODES, 1, false) < 0)
>>>> diff --git a/tools/xenstore/xenstored_domain.h 
>>>> b/tools/xenstore/xenstored_domain.h
>>>> index 8259c114b0..cd85bd0cad 100644
>>>> --- a/tools/xenstore/xenstored_domain.h
>>>> +++ b/tools/xenstore/xenstored_domain.h
>>>> @@ -20,7 +20,8 @@
>>>>   #define _XENSTORED_DOMAIN_H
>>>>   enum accitem {
>>>> -    ACC_NODES,
>>>> +    ACC_REQ_N,       /* Number of elements per request and domain. */
>>>> +    ACC_NODES = ACC_REQ_N,
>>>
>>> I would bring forward the change in patch #5. I mean:
>>>
>>> ACC_NODES,
>>> ACC_REQ_N
>>
>> I'm not sure this is a good idea. This would activate the temporary
>> accounting for nodes, but keeping the error handling active. I'd rather
>> activate temporary accounting for nodes together with removing the
>> accounting correction in the error handling.
> 
> I am not sure I fully understand what you would rather do. Can you clarify?

Having ACC_REQ_N > 0 will result in temporary accounting being active for
ACC_NODES (which is 0), due to "what < ACC_REQ_N".

At the same time there are still all the places where in error cases the
node accounting is corrected again (the mentioned error handling). So we
would have both error handling mechanisms (explicit and temp accounting)
active at the same time for nodes.

> 
>>
>>>
>>>>       ACC_TR_N,        /* Number of elements per transaction and domain. */
>>>>       ACC_N = ACC_TR_N /* Number of elements per domain. */
>>>>   };
>>>
>>> This enum is getting extremely confusing. There are many "number of elements 
>>> per ... domain". Can you clarify?
>>
>> I will add some more comments to the header. Would you like it better to have
>> the limits indented more? something like:
> 
> I am afraid it doesn't help understanding the comment. For instance,
> 
>>
>> enum accitem {
>>          ACC_NODES,
>>          /* Number of elements per request and domain. */
> 
> you wrote "per request and domain" here. But...
> 
>>          ACC_REQ_N,
>>          /* Number of elements per transaction and domain. */
> 
> ... here this is "per transaction and domain". Should not nbe "elements per 
> transaction"? And if not, then why don't we had "per request, transaction and 
> domain" above?

This is due to the nesting: the outermost nesting level is "all accounting
items", which covers everything, and is tracked on a per domain basis.

The next level is "per transaction" (I can drop the "and per domain", as
everything is per domain).

The innermost level is "per request". A request can be either part of a
transaction, or not. This doesn't matter.


Juergen

[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3149 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]

  reply	other threads:[~2023-02-22  8:52 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-20 10:00 [PATCH v2 00/13] tools/xenstore: rework internal accounting Juergen Gross
2023-01-20 10:00 ` [PATCH v2 01/13] tools/xenstore: don't allow creating too many nodes in a transaction Juergen Gross
2023-02-20  9:46   ` Julien Grall
2023-02-20 11:04     ` Juergen Gross
2023-02-20 12:07       ` Julien Grall
2023-02-20 13:49         ` Juergen Gross
2023-02-20 14:06           ` Juergen Gross
2023-02-20 14:15           ` Julien Grall
2023-02-20 14:21             ` Juergen Gross
2023-02-20 18:01               ` Julien Grall
2023-02-21  8:10                 ` Juergen Gross
2023-02-21 22:36                   ` Julien Grall
2023-02-22  8:36                     ` Juergen Gross
2023-02-22  8:52                       ` Julien Grall
2023-02-22  9:37                         ` Juergen Gross
2023-01-20 10:00 ` [PATCH v2 02/13] tools/xenstore: manage per-transaction domain accounting data in an array Juergen Gross
2023-02-17 18:49   ` Julien Grall
2023-01-20 10:00 ` [PATCH v2 03/13] tools/xenstore: introduce accounting data array for per-domain values Juergen Gross
2023-02-17 19:29   ` Julien Grall
2023-02-20 11:20     ` Juergen Gross
2023-02-20 12:13       ` Julien Grall
2023-01-20 10:00 ` [PATCH v2 04/13] tools/xenstore: add framework to commit accounting data on success only Juergen Gross
2023-02-20 22:50   ` Julien Grall
2023-02-21  8:37     ` Juergen Gross
2023-02-21 22:42       ` Julien Grall
2023-02-22  8:52         ` Juergen Gross [this message]
2023-01-20 10:00 ` [PATCH v2 05/13] tools/xenstore: use accounting buffering for node accounting Juergen Gross
2023-01-20 10:00 ` [PATCH v2 06/13] tools/xenstore: add current connection to domain_memory_add() parameters Juergen Gross
2023-01-20 10:00 ` [PATCH v2 07/13] tools/xenstore: use accounting data array for per-domain values Juergen Gross
2023-01-20 10:00 ` [PATCH v2 08/13] tools/xenstore: add accounting trace support Juergen Gross
2023-02-20 22:57   ` Julien Grall
2023-02-21  8:40     ` Juergen Gross
2023-02-21 22:45       ` Julien Grall
2023-01-20 10:00 ` [PATCH v2 09/13] tools/xenstore: add TDB access " Juergen Gross
2023-02-20 22:59   ` Julien Grall
2023-02-21  8:41     ` Juergen Gross
2023-01-20 10:00 ` [PATCH v2 10/13] tools/xenstore: switch transaction accounting to generic accounting Juergen Gross
2023-01-20 10:00 ` [PATCH v2 11/13] tools/xenstore: remember global and per domain max accounting values Juergen Gross
2023-01-20 10:00 ` [PATCH v2 12/13] tools/xenstore: use generic accounting for remaining quotas Juergen Gross
2023-01-20 10:00 ` [PATCH v2 13/13] tools/xenstore: switch quota management to be table based Juergen Gross

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=292847c2-02b8-b190-8439-75ddb9ff4cb0@suse.com \
    --to=jgross@suse.com \
    --cc=anthony.perard@citrix.com \
    --cc=julien@xen.org \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).