diff options
author | SeongJae Park <sjpark@amazon.de> | 2020-12-14 10:02:45 +0100 |
---|---|---|
committer | Juergen Gross <jgross@suse.com> | 2020-12-14 10:02:45 +0100 |
commit | fed1755b118147721f2c87b37b9d66e62c39b668 (patch) | |
tree | c85a0c3f96dbe2aee72474fb994f24d7660156a6 /include/xen/xenbus.h | |
parent | Linux 5.10 (diff) | |
download | linux-fed1755b118147721f2c87b37b9d66e62c39b668.tar.xz linux-fed1755b118147721f2c87b37b9d66e62c39b668.zip |
xen/xenbus: Allow watches discard events before queueing
If handling logics of watch events are slower than the events enqueue
logic and the events can be created from the guests, the guests could
trigger memory pressure by intensively inducing the events, because it
will create a huge number of pending events that exhausting the memory.
Fortunately, some watch events could be ignored, depending on its
handler callback. For example, if the callback has interest in only one
single path, the watch wouldn't want multiple pending events. Or, some
watches could ignore events to same path.
To let such watches to volutarily help avoiding the memory pressure
situation, this commit introduces new watch callback, 'will_handle'. If
it is not NULL, it will be called for each new event just before
enqueuing it. Then, if the callback returns false, the event will be
discarded. No watch is using the callback for now, though.
This is part of XSA-349
Cc: stable@vger.kernel.org
Signed-off-by: SeongJae Park <sjpark@amazon.de>
Reported-by: Michael Kurth <mku@amazon.de>
Reported-by: Pawel Wieczorkiewicz <wipawel@amazon.de>
Reviewed-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
Diffstat (limited to 'include/xen/xenbus.h')
-rw-r--r-- | include/xen/xenbus.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/include/xen/xenbus.h b/include/xen/xenbus.h index 5a8315e6d8a6..baa88bf0b9bc 100644 --- a/include/xen/xenbus.h +++ b/include/xen/xenbus.h @@ -61,6 +61,13 @@ struct xenbus_watch /* Path being watched. */ const char *node; + /* + * Called just before enqueing new event while a spinlock is held. + * The event will be discarded if this callback returns false. + */ + bool (*will_handle)(struct xenbus_watch *, + const char *path, const char *token); + /* Callback (executed in a process context with no locks held). */ void (*callback)(struct xenbus_watch *, const char *path, const char *token); |