All of lore.kernel.org
 help / color / mirror / Atom feed
From: Juergen Gross <jgross@suse.com>
To: Oleksii Moisieiev <Oleksii_Moisieiev@epam.com>,
	"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Subject: Re: [RFC v2 1/8] xen/hypfs: support fo nested dynamic hypfs nodes
Date: Thu, 10 Feb 2022 08:34:08 +0100	[thread overview]
Message-ID: <74e4635d-10ad-86c4-71b1-6e46bc76a89a@suse.com> (raw)
In-Reply-To: <8ab7e9ffd5f041c2631f754c7c596874cf6a99c1.1644341635.git.oleksii_moisieiev@epam.com>


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

On 08.02.22 19:00, Oleksii Moisieiev wrote:

Nit: in the patch title s/fo/for/

> Add new api:
> - hypfs_read_dyndir_entry
> - hypfs_gen_dyndir_entry
> which are the extension of the dynamic hypfs nodes support, presented in
> 0b3b53be8cf226d947a79c2535a9efbb2dd7bc38.
> This allows nested dynamic nodes to be added. Also input parameter is
> hypfs_entry, so properties can also be generated dynamically.
> 
> Generating mixed list of dirs and properties is also supported.
> Same as to the dynamic hypfs nodes, this is anchored in percpu pointer,
> which can be retriewed on any level of the dynamic entries.
> This handle should be allocated on enter() callback and released on
> exit() callback. When using nested dynamic dirs and properties handle
> should be allocated on the first enter() call and released on the last
> exit() call.
> 
> Signed-off-by: Oleksii Moisieiev <oleksii_moisieiev@epam.com>
> ---
>   xen/common/hypfs.c      | 83 +++++++++++++++++++++++++++++++++--------
>   xen/include/xen/hypfs.h | 14 ++++++-
>   2 files changed, 79 insertions(+), 18 deletions(-)
> 
> diff --git a/xen/common/hypfs.c b/xen/common/hypfs.c
> index e71f7df479..6901f5e311 100644
> --- a/xen/common/hypfs.c
> +++ b/xen/common/hypfs.c
> @@ -367,28 +367,27 @@ unsigned int hypfs_getsize(const struct hypfs_entry *entry)
>   
>   /*
>    * Fill the direntry for a dynamically generated entry. Especially the
> - * generated name needs to be kept in sync with hypfs_gen_dyndir_id_entry().
> + * generated name needs to be kept in sync with hypfs_gen_dyndir_entry().
>    */
> -int hypfs_read_dyndir_id_entry(const struct hypfs_entry_dir *template,
> -                               unsigned int id, bool is_last,
> +int hypfs_read_dyndir_entry(const struct hypfs_entry *template,
> +                               const char *name, unsigned int namelen,
> +                               bool is_last,
>                                  XEN_GUEST_HANDLE_PARAM(void) *uaddr)

Please fix the indentation of the parameters.

>   {
>       struct xen_hypfs_dirlistentry direntry;
> -    char name[HYPFS_DYNDIR_ID_NAMELEN];
> -    unsigned int e_namelen, e_len;
> +    unsigned int e_len;
>   
> -    e_namelen = snprintf(name, sizeof(name), template->e.name, id);
> -    e_len = DIRENTRY_SIZE(e_namelen);
> +    e_len = DIRENTRY_SIZE(namelen);
>       direntry.e.pad = 0;
> -    direntry.e.type = template->e.type;
> -    direntry.e.encoding = template->e.encoding;
> -    direntry.e.content_len = template->e.funcs->getsize(&template->e);
> -    direntry.e.max_write_len = template->e.max_size;
> +    direntry.e.type = template->type;
> +    direntry.e.encoding = template->encoding;
> +    direntry.e.content_len = template->funcs->getsize(template);
> +    direntry.e.max_write_len = template->max_size;
>       direntry.off_next = is_last ? 0 : e_len;
>       if ( copy_to_guest(*uaddr, &direntry, 1) )
>           return -EFAULT;
>       if ( copy_to_guest_offset(*uaddr, DIRENTRY_NAME_OFF, name,
> -                              e_namelen + 1) )
> +                              namelen + 1) )
>           return -EFAULT;
>   
>       guest_handle_add_offset(*uaddr, e_len);
> @@ -396,6 +395,22 @@ int hypfs_read_dyndir_id_entry(const struct hypfs_entry_dir *template,
>       return 0;
>   }
>   
> +/*
> + * Fill the direntry for a dynamically generated entry. Especially the
> + * generated name needs to be kept in sync with hypfs_gen_dyndir_id_entry().
> + */
> +int hypfs_read_dyndir_id_entry(const struct hypfs_entry_dir *template,
> +                               unsigned int id, bool is_last,
> +                               XEN_GUEST_HANDLE_PARAM(void) *uaddr)
> +{
> +    char name[HYPFS_DYNDIR_ID_NAMELEN];
> +    unsigned int e_namelen;
> +
> +    e_namelen = snprintf(name, sizeof(name), template->e.name, id);
> +    return hypfs_read_dyndir_entry(&template->e, name, e_namelen, is_last, uaddr);
> +}
> +
> +
>   static const struct hypfs_entry *hypfs_dyndir_enter(
>       const struct hypfs_entry *entry)
>   {
> @@ -404,7 +419,7 @@ static const struct hypfs_entry *hypfs_dyndir_enter(
>       data = hypfs_get_dyndata();
>   
>       /* Use template with original enter function. */
> -    return data->template->e.funcs->enter(&data->template->e);
> +    return data->template->funcs->enter(data->template);
>   }
>   
>   static struct hypfs_entry *hypfs_dyndir_findentry(
> @@ -415,7 +430,7 @@ static struct hypfs_entry *hypfs_dyndir_findentry(
>       data = hypfs_get_dyndata();
>   
>       /* Use template with original findentry function. */
> -    return data->template->e.funcs->findentry(data->template, name, name_len);
> +    return data->template->funcs->findentry(&data->dir, name, name_len);
>   }
>   
>   static int hypfs_read_dyndir(const struct hypfs_entry *entry,
> @@ -426,7 +441,36 @@ static int hypfs_read_dyndir(const struct hypfs_entry *entry,
>       data = hypfs_get_dyndata();
>   
>       /* Use template with original read function. */
> -    return data->template->e.funcs->read(&data->template->e, uaddr);
> +    return data->template->funcs->read(data->template, uaddr);
> +}
> +
> +/*
> + * Fill dyndata with a dynamically generated entry based on a template
> + * and a name.
> + * Needs to be kept in sync with hypfs_read_dyndir_entry() regarding the
> + * name generated.
> + */
> +struct hypfs_entry *hypfs_gen_dyndir_entry(
> +    const struct hypfs_entry *template, const char *name,
> +    void *data)
> +{
> +    struct hypfs_dyndir_id *dyndata;
> +
> +    dyndata = hypfs_get_dyndata();
> +
> +    dyndata->template = template;
> +    dyndata->data = data;
> +    memcpy(dyndata->name, name, strlen(name));
> +    dyndata->dir.e = *template;
> +    dyndata->dir.e.name = dyndata->name;
> +
> +    dyndata->dir.e.funcs = &dyndata->funcs;
> +    dyndata->funcs = *template->funcs;
> +    dyndata->funcs.enter = hypfs_dyndir_enter;
> +    dyndata->funcs.findentry = hypfs_dyndir_findentry;
> +    dyndata->funcs.read = hypfs_read_dyndir;
> +
> +    return &dyndata->dir.e;
>   }
>   
>   /*
> @@ -442,12 +486,13 @@ struct hypfs_entry *hypfs_gen_dyndir_id_entry(
>   
>       dyndata = hypfs_get_dyndata();
>   
> -    dyndata->template = template;
> +    dyndata->template = &template->e;
>       dyndata->id = id;
>       dyndata->data = data;
>       snprintf(dyndata->name, sizeof(dyndata->name), template->e.name, id);
>       dyndata->dir = *template;
>       dyndata->dir.e.name = dyndata->name;
> +

Unrelated change?

>       dyndata->dir.e.funcs = &dyndata->funcs;
>       dyndata->funcs = *template->e.funcs;
>       dyndata->funcs.enter = hypfs_dyndir_enter;
> @@ -457,6 +502,12 @@ struct hypfs_entry *hypfs_gen_dyndir_id_entry(
>       return &dyndata->dir.e;
>   }
>   
> +unsigned int hypfs_dyndir_entry_size(const struct hypfs_entry *template,
> +                                    const char *name)

Please fix indentation.

> +{
> +    return DIRENTRY_SIZE(strlen(name));
> +}
> +
>   unsigned int hypfs_dynid_entry_size(const struct hypfs_entry *template,
>                                       unsigned int id)
>   {
> diff --git a/xen/include/xen/hypfs.h b/xen/include/xen/hypfs.h
> index e9d4c2555b..5d2728b963 100644
> --- a/xen/include/xen/hypfs.h
> +++ b/xen/include/xen/hypfs.h
> @@ -79,8 +79,8 @@ struct hypfs_entry_dir {
>   struct hypfs_dyndir_id {

Please rename to struct hypfs_dyndir.

>       struct hypfs_entry_dir dir;             /* Modified copy of template. */
>       struct hypfs_funcs funcs;               /* Dynamic functions. */
> -    const struct hypfs_entry_dir *template; /* Template used. */
> -#define HYPFS_DYNDIR_ID_NAMELEN 12
> +    const struct hypfs_entry *template; /* Template used. */
> +#define HYPFS_DYNDIR_ID_NAMELEN 32
>       char name[HYPFS_DYNDIR_ID_NAMELEN];     /* Name of hypfs entry. */
>   
>       unsigned int id;                        /* Numerical id. */

What about the following change instead:

-    const struct hypfs_entry_dir *template; /* Template used. */
-#define HYPFS_DYNDIR_ID_NAMELEN 12
-    char name[HYPFS_DYNDIR_ID_NAMELEN];     /* Name of hypfs entry. */
-
-    unsigned int id;                        /* Numerical id. */
-    void *data;                             /* Data associated with id. */
+    const struct hypfs_entry *template;  /* Template used. */
+    union {
+#define HYPFS_DYNDIR_NAMELEN    32
+        char name[HYPFS_DYNDIR_NAMELEN]; /* Name of hypfs entry. */
+        struct {
+#define HYPFS_DYNDIR_ID_NAMELEN 12
+            char name[HYPFS_DYNDIR_ID_NAMELEN]; /* Name of id entry. */
+            unsigned int id;                    /* Numerical id. */
+        } id;
+    };
+    void *data;                          /* Data associated with entry. */

> @@ -197,13 +197,23 @@ void *hypfs_alloc_dyndata(unsigned long size);
>   #define hypfs_alloc_dyndata(type) ((type *)hypfs_alloc_dyndata(sizeof(type)))
>   void *hypfs_get_dyndata(void);
>   void hypfs_free_dyndata(void);
> +int hypfs_read_dyndir_entry(const struct hypfs_entry *template,
> +                               const char *name, unsigned int namelen,
> +                               bool is_last,
> +                               XEN_GUEST_HANDLE_PARAM(void) *uaddr);

Again: indentation.

>   int hypfs_read_dyndir_id_entry(const struct hypfs_entry_dir *template,
>                                  unsigned int id, bool is_last,
>                                  XEN_GUEST_HANDLE_PARAM(void) *uaddr);
> +struct hypfs_entry *hypfs_gen_dyndir_entry(
> +    const struct hypfs_entry *template, const char *name,
> +    void *data);
>   struct hypfs_entry *hypfs_gen_dyndir_id_entry(
>       const struct hypfs_entry_dir *template, unsigned int id, void *data);
>   unsigned int hypfs_dynid_entry_size(const struct hypfs_entry *template,
>                                       unsigned int id);
> +unsigned int hypfs_dyndir_entry_size(const struct hypfs_entry *template,
> +                                    const char *name);

Indentation.

> +
>   #endif
>   
>   #endif /* __XEN_HYPFS_H__ */


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:[~2022-02-10  7:34 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-08 18:00 [RFC v2 0/8] Introduce SCI-mediator feature Oleksii Moisieiev
2022-02-08 18:00 ` [RFC v2 1/8] xen/hypfs: support fo nested dynamic hypfs nodes Oleksii Moisieiev
2022-02-10  7:34   ` Juergen Gross [this message]
2022-02-11  8:16     ` Oleksii Moisieiev
2022-02-11 13:28       ` Juergen Gross
2022-02-11 13:32         ` Oleksii Moisieiev
2022-02-08 18:00 ` [RFC v2 2/8] libs: libxenhypfs - handle blob properties Oleksii Moisieiev
2022-02-09 13:47   ` Oleksandr Andrushchenko
2022-02-09 14:01     ` Jan Beulich
2022-02-09 14:04       ` Oleksandr Andrushchenko
2022-02-09 14:04   ` Juergen Gross
2022-02-08 18:00 ` [RFC v2 3/8] xen/arm: Export host device-tree to hypfs Oleksii Moisieiev
2022-02-08 18:26   ` Julien Grall
2022-02-09 10:20     ` Oleksii Moisieiev
2022-02-09 12:17       ` Julien Grall
2022-02-09 14:17         ` Oleksii Moisieiev
2022-02-09 18:51         ` Oleksii Moisieiev
2022-02-09 19:34           ` Julien Grall
2022-02-10  9:38             ` Oleksii Moisieiev
2022-02-09 14:03     ` Juergen Gross
2022-02-08 18:00 ` [RFC v2 4/8] xen/arm: add generic SCI mediator framework Oleksii Moisieiev
2022-02-08 18:00 ` [RFC v2 5/8] xen/arm: introduce SCMI-SMC mediator driver Oleksii Moisieiev
2022-02-09 15:02   ` Oleksandr Andrushchenko
2022-02-09 15:23     ` Julien Grall
2022-02-11  8:46   ` Bertrand Marquis
2022-02-11 10:44     ` Oleksii Moisieiev
2022-02-11 11:18       ` Bertrand Marquis
2022-02-11 11:55         ` Oleksii Moisieiev
2022-02-11 23:35           ` Stefano Stabellini
2022-02-12 12:43         ` Julien Grall
2022-02-14 11:13           ` Oleksii Moisieiev
2022-02-14 11:27             ` Bertrand Marquis
2022-02-14 11:51               ` Oleksii Moisieiev
2022-02-14 22:05                 ` Stefano Stabellini
2022-02-16 17:41                   ` Oleksii Moisieiev
2022-02-08 18:00 ` [RFC v2 6/8] tools/arm: Introduce force_assign_without_iommu option to xl.cfg Oleksii Moisieiev
2022-02-17 14:52   ` Anthony PERARD
2022-02-18  8:19     ` Oleksii Moisieiev
2022-02-17 15:20   ` Julien Grall
2022-02-18  9:16     ` Oleksii Moisieiev
2022-02-18 10:17       ` Julien Grall
2022-02-21 18:39         ` Oleksii Moisieiev
2022-06-03 13:43   ` Jan Beulich
2022-02-08 18:00 ` [RFC v2 7/8] tools/arm: add "arm_sci" " Oleksii Moisieiev
2022-02-08 18:00 ` [RFC v2 8/8] xen/arm: add SCI mediator support for DomUs Oleksii Moisieiev

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=74e4635d-10ad-86c4-71b1-6e46bc76a89a@suse.com \
    --to=jgross@suse.com \
    --cc=Oleksii_Moisieiev@epam.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.