From: Oleksandr Andrushchenko <andr2000@gmail.com>
To: xen-devel@lists.xenproject.org
Cc: julien@xen.org, sstabellini@kernel.org,
oleksandr_tyshchenko@epam.com, volodymyr_babchuk@epam.com,
Artem_Mygaiev@epam.com, roger.pau@citrix.com, jbeulich@suse.com,
andrew.cooper3@citrix.com, george.dunlap@citrix.com,
paul@xen.org, bertrand.marquis@arm.com, rahul.singh@arm.com,
Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
Subject: [PATCH 2/4] rangeset: add rangeset_reset helper function
Date: Tue, 1 Feb 2022 18:25:06 +0200 [thread overview]
Message-ID: <20220201162508.417008-3-andr2000@gmail.com> (raw)
In-Reply-To: <20220201162508.417008-1-andr2000@gmail.com>
From: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
This helper destroys all the ranges of the rangeset given.
Please note, that it uses rangeset_remove_range which returns an error
code on failure. This error code can be ignored as while destroying all
the ranges no memory allocation is expected, so in this case it must not
fail.
To make sure this remains valid use BUG_ON if that changes in the future.
Suggested-by: Roger Pau Monné <roger.pau@citrix.com>
Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
---
xen/common/rangeset.c | 6 ++++++
xen/include/xen/rangeset.h | 3 +++
2 files changed, 9 insertions(+)
diff --git a/xen/common/rangeset.c b/xen/common/rangeset.c
index ea27d651723b..9ca2b06cff22 100644
--- a/xen/common/rangeset.c
+++ b/xen/common/rangeset.c
@@ -525,6 +525,12 @@ void rangeset_swap(struct rangeset *a, struct rangeset *b)
write_unlock(&b->lock);
}
+void rangeset_reset(struct rangeset *r)
+{
+ /* This doesn't allocate anything and must not fail. */
+ BUG_ON(rangeset_remove_range(r, 0, ~0ULL));
+}
+
/*****************************
* Pretty-printing functions
*/
diff --git a/xen/include/xen/rangeset.h b/xen/include/xen/rangeset.h
index f7c69394d66a..e0d70d88bdd7 100644
--- a/xen/include/xen/rangeset.h
+++ b/xen/include/xen/rangeset.h
@@ -95,6 +95,9 @@ bool_t __must_check rangeset_contains_singleton(
/* swap contents */
void rangeset_swap(struct rangeset *a, struct rangeset *b);
+/* Destroy all ranges. */
+void rangeset_reset(struct rangeset *r);
+
/* Rangeset pretty printing. */
void rangeset_domain_printk(
struct domain *d);
--
2.25.1
next prev parent reply other threads:[~2022-02-01 16:25 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-01 16:25 [PATCH 0/4] PCI devices passthrough pre-req patches Oleksandr Andrushchenko
2022-02-01 16:25 ` [PATCH 1/4] rangeset: add RANGESETF_no_print flag Oleksandr Andrushchenko
2022-02-01 16:25 ` Oleksandr Andrushchenko [this message]
2022-02-01 17:05 ` [PATCH 2/4] rangeset: add rangeset_reset helper function Julien Grall
2022-02-01 17:14 ` Oleksandr Andrushchenko
2022-02-01 17:33 ` Julien Grall
2022-02-01 17:39 ` Oleksandr Andrushchenko
2022-02-01 16:25 ` [PATCH 3/4] vpci: shrink critical section in vpci_{read/write} Oleksandr Andrushchenko
2022-02-02 8:44 ` Roger Pau Monné
2022-02-02 9:05 ` Jan Beulich
2022-02-02 9:38 ` Oleksandr Andrushchenko
2022-02-02 9:45 ` Jan Beulich
2022-02-02 9:49 ` Oleksandr Andrushchenko
2022-02-02 9:49 ` Roger Pau Monné
2022-02-01 16:25 ` [PATCH 4/4] vpci: move lock outside of struct vpci Oleksandr Andrushchenko
2022-02-02 9:22 ` Jan Beulich
2022-02-02 11:03 ` Oleksandr Andrushchenko
2022-02-02 11:14 ` Jan Beulich
2022-02-02 11:26 ` Oleksandr Andrushchenko
2022-02-02 9:45 ` Roger Pau Monné
2022-02-02 10:15 ` Oleksandr Andrushchenko
2022-02-02 8:48 ` [PATCH 0/4] PCI devices passthrough pre-req patches Jan Beulich
2022-02-02 9:03 ` Oleksandr Andrushchenko
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=20220201162508.417008-3-andr2000@gmail.com \
--to=andr2000@gmail.com \
--cc=Artem_Mygaiev@epam.com \
--cc=andrew.cooper3@citrix.com \
--cc=bertrand.marquis@arm.com \
--cc=george.dunlap@citrix.com \
--cc=jbeulich@suse.com \
--cc=julien@xen.org \
--cc=oleksandr_andrushchenko@epam.com \
--cc=oleksandr_tyshchenko@epam.com \
--cc=paul@xen.org \
--cc=rahul.singh@arm.com \
--cc=roger.pau@citrix.com \
--cc=sstabellini@kernel.org \
--cc=volodymyr_babchuk@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.