From: "Jürgen Groß" <jgross@suse.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
George Dunlap <george.dunlap@citrix.com>,
Ian Jackson <iwj@xenproject.org>, Julien Grall <julien@xen.org>,
Stefano Stabellini <sstabellini@kernel.org>, Wei Liu <wl@xen.org>,
xen-devel@lists.xenproject.org
Subject: Re: [PATCH v3 3/8] xen/hypfs: add new enter() and exit() per node callbacks
Date: Wed, 16 Dec 2020 17:24:06 +0100 [thread overview]
Message-ID: <aad9131f-ca42-94b4-1ce2-18c6db0ac381@suse.com> (raw)
In-Reply-To: <36469295-8c77-0e58-654a-35fd992c11a1@suse.com>
[-- Attachment #1.1.1: Type: text/plain, Size: 4446 bytes --]
On 16.12.20 17:16, Jan Beulich wrote:
> On 09.12.2020 17:09, Juergen Gross wrote:
>> In order to better support resource allocation and locking for dynamic
>> hypfs nodes add enter() and exit() callbacks to struct hypfs_funcs.
>>
>> The enter() callback is called when entering a node during hypfs user
>> actions (traversing, reading or writing it), while the exit() callback
>> is called when leaving a node (accessing another node at the same or a
>> higher directory level, or when returning to the user).
>>
>> For avoiding recursion this requires a parent pointer in each node.
>> Let the enter() callback return the entry address which is stored as
>> the last accessed node in order to be able to use a template entry for
>> that purpose in case of dynamic entries.
>>
>> Signed-off-by: Juergen Gross <jgross@suse.com>
>> ---
>> V2:
>> - new patch
>>
>> V3:
>> - add ASSERT(entry); (Jan Beulich)
>>
>> Signed-off-by: Juergen Gross <jgross@suse.com>
>> ---
>> xen/common/hypfs.c | 80 +++++++++++++++++++++++++++++++++++++++++
>> xen/include/xen/hypfs.h | 5 +++
>> 2 files changed, 85 insertions(+)
>>
>> diff --git a/xen/common/hypfs.c b/xen/common/hypfs.c
>> index 6f822ae097..f04934db10 100644
>> --- a/xen/common/hypfs.c
>> +++ b/xen/common/hypfs.c
>> @@ -25,30 +25,40 @@ CHECK_hypfs_dirlistentry;
>> ROUNDUP((name_len) + 1, alignof(struct xen_hypfs_direntry)))
>>
>> const struct hypfs_funcs hypfs_dir_funcs = {
>> + .enter = hypfs_node_enter,
>> + .exit = hypfs_node_exit,
>> .read = hypfs_read_dir,
>> .write = hypfs_write_deny,
>> .getsize = hypfs_getsize,
>> .findentry = hypfs_dir_findentry,
>> };
>> const struct hypfs_funcs hypfs_leaf_ro_funcs = {
>> + .enter = hypfs_node_enter,
>> + .exit = hypfs_node_exit,
>> .read = hypfs_read_leaf,
>> .write = hypfs_write_deny,
>> .getsize = hypfs_getsize,
>> .findentry = hypfs_leaf_findentry,
>> };
>> const struct hypfs_funcs hypfs_leaf_wr_funcs = {
>> + .enter = hypfs_node_enter,
>> + .exit = hypfs_node_exit,
>> .read = hypfs_read_leaf,
>> .write = hypfs_write_leaf,
>> .getsize = hypfs_getsize,
>> .findentry = hypfs_leaf_findentry,
>> };
>> const struct hypfs_funcs hypfs_bool_wr_funcs = {
>> + .enter = hypfs_node_enter,
>> + .exit = hypfs_node_exit,
>> .read = hypfs_read_leaf,
>> .write = hypfs_write_bool,
>> .getsize = hypfs_getsize,
>> .findentry = hypfs_leaf_findentry,
>> };
>> const struct hypfs_funcs hypfs_custom_wr_funcs = {
>> + .enter = hypfs_node_enter,
>> + .exit = hypfs_node_exit,
>> .read = hypfs_read_leaf,
>> .write = hypfs_write_custom,
>> .getsize = hypfs_getsize,
>> @@ -63,6 +73,8 @@ enum hypfs_lock_state {
>> };
>> static DEFINE_PER_CPU(enum hypfs_lock_state, hypfs_locked);
>>
>> +static DEFINE_PER_CPU(const struct hypfs_entry *, hypfs_last_node_entered);
>> +
>> HYPFS_DIR_INIT(hypfs_root, "");
>>
>> static void hypfs_read_lock(void)
>> @@ -100,11 +112,59 @@ static void hypfs_unlock(void)
>> }
>> }
>>
>> +const struct hypfs_entry *hypfs_node_enter(const struct hypfs_entry *entry)
>> +{
>> + return entry;
>> +}
>> +
>> +void hypfs_node_exit(const struct hypfs_entry *entry)
>> +{
>> +}
>> +
>> +static int node_enter(const struct hypfs_entry *entry)
>> +{
>> + const struct hypfs_entry **last = &this_cpu(hypfs_last_node_entered);
>> +
>> + entry = entry->funcs->enter(entry);
>> + if ( IS_ERR(entry) )
>> + return PTR_ERR(entry);
>> +
>> + ASSERT(entry);
>> + ASSERT(!*last || *last == entry->parent);
>> +
>> + *last = entry;
>> +
>> + return 0;
>> +}
>> +
>> +static void node_exit(const struct hypfs_entry *entry)
>> +{
>> + const struct hypfs_entry **last = &this_cpu(hypfs_last_node_entered);
>> +
>> + if ( !*last )
>> + return;
>
> To my question regarding this in v2 you replied
>
> "I rechecked and have found that this was a remnant from an earlier
> variant. *last won't ever be NULL, so the if can be dropped (a NULL
> will be catched by the following ASSERT())."
>
> Now this if() is still there. Why?
I really thought I did remove the if(). Seems as if I did that on
my test machine only and not in my git tree. Sorry for that.
Juergen
[-- Attachment #1.1.2: OpenPGP_0xB0DE9DD628BF132F.asc --]
[-- Type: application/pgp-keys, Size: 3135 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]
next prev parent reply other threads:[~2020-12-16 16:24 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-09 16:09 [PATCH v3 0/8] xen: support per-cpupool scheduling granularity Juergen Gross
2020-12-09 16:09 ` [PATCH v3 1/8] xen/cpupool: support moving domain between cpupools with different granularity Juergen Gross
2020-12-16 17:52 ` Dario Faggioli
2020-12-17 7:49 ` Jan Beulich
2020-12-17 7:54 ` Jürgen Groß
2020-12-09 16:09 ` [PATCH v3 2/8] xen/hypfs: switch write function handles to const Juergen Gross
2020-12-16 16:08 ` Jan Beulich
2020-12-16 16:17 ` Jürgen Groß
2020-12-16 16:35 ` Jan Beulich
2020-12-09 16:09 ` [PATCH v3 3/8] xen/hypfs: add new enter() and exit() per node callbacks Juergen Gross
2020-12-16 16:16 ` Jan Beulich
2020-12-16 16:24 ` Jürgen Groß [this message]
2020-12-16 16:36 ` Jan Beulich
2020-12-16 17:12 ` Jürgen Groß
2020-12-09 16:09 ` [PATCH v3 4/8] xen/hypfs: support dynamic hypfs nodes Juergen Gross
2020-12-17 11:01 ` Jan Beulich
2020-12-17 11:24 ` Jürgen Groß
2020-12-09 16:09 ` [PATCH v3 5/8] xen/hypfs: add support for id-based dynamic directories Juergen Gross
2020-12-17 11:28 ` Jan Beulich
2020-12-17 11:32 ` Jürgen Groß
2020-12-17 12:14 ` Jan Beulich
2020-12-18 8:57 ` Jürgen Groß
2020-12-18 9:09 ` Jan Beulich
2020-12-18 12:41 ` Jürgen Groß
2020-12-21 8:26 ` Jan Beulich
2021-01-18 7:25 ` Jürgen Groß
2021-01-18 7:59 ` Jan Beulich
2020-12-09 16:09 ` [PATCH v3 6/8] xen/cpupool: add cpupool directories Juergen Gross
2020-12-17 15:54 ` Jan Beulich
2020-12-17 16:10 ` Dario Faggioli
2020-12-09 16:09 ` [PATCH v3 7/8] xen/cpupool: add scheduling granularity entry to cpupool entries Juergen Gross
2020-12-17 15:57 ` Jan Beulich
2020-12-09 16:09 ` [PATCH v3 8/8] xen/cpupool: make per-cpupool sched-gran hypfs node writable 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=aad9131f-ca42-94b4-1ce2-18c6db0ac381@suse.com \
--to=jgross@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=george.dunlap@citrix.com \
--cc=iwj@xenproject.org \
--cc=jbeulich@suse.com \
--cc=julien@xen.org \
--cc=sstabellini@kernel.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).