[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v13 07/14] rangeset: add rangeset_purge() function


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
  • Date: Fri, 2 Feb 2024 16:33:11 -0500
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Qi56JEzWMgKoMsc50mwUebNiiljtIu6vzi5g/b8KIBY=; b=kEb6n/l4euu0BG8KsUgcZjMIxggmkdndvzmYPDqCQZ5dMuqXtMko0tbwAMm9CEgc3XxjM27iBxVSlpTC9803CtGNcPyXYe+JCPPpWTbqb1QsA+eG2ldPEIR6Lpg1OG4GCfkYqJB1rBBqcSzmBrVhEOv4hhUxxf2uLRMHqWQb9/XZejlIRe+2Jn/hCI76rQV6Uv7Z0R3CFT7525Lzgx5AP2XWXi1L8rltAkemmVdj7iFsu2pXQiNXiG5vZoLD/SXsinPnNYzId0c7lTL0NGAjjmGOt/KPMwxVE6zLqKLiKcYOWN1D+ktuXApxWm8VjAaNNCntqxMyBNgxyhPFUOJ6dQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JfeohXYcssNx4LGdnMYO1l6efKA2Cu4pWzgNugzpbp0WI3n+F98n0GqUP0JLNg7pcfDIR9w4+wIDzaJawO8YRqDlMsEqd1C75+U+Y5zKeUlAoQNywrn4zZkXVaQ2O1DPy9sgOuYrSQnKqxDAu+RnKt+qFC5mnHCikAeH0r/FfPuXFf3YFquVam/ixdfbkRpC3cpSfSONj7sCnnEX4aow0gonPk7gYWmSkLDnYRDPBF/6YFyhFFRoSU8wVFOYWA2lQJWwLVN48eyJ68sar9B9WIZUmpNm3U3ig3c+9VZIvocvWifww/Bbd/zdz5bqfqzS7VJ8sKSJ0B7blP7xanF7NQ==
  • Cc: Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, "Jan Beulich" <jbeulich@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, "Stefano Stabellini" <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Volodymyr Babchuk <volodymyr_babchuk@xxxxxxxx>, Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
  • Delivery-date: Fri, 02 Feb 2024 21:37:23 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

From: Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>

This function can be used when user wants to remove all rangeset
entries but do not want to destroy rangeset itself.

Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@xxxxxxxx>
Signed-off-by: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
Acked-by: Jan Beulich <jbeulich@xxxxxxxx>
---
Changes in v13:
 - Added Jan's A-b
Changes in v12:
 - s/rangeset_empty/rangeset_purge/
Changes in v11:
 - Now the function only empties rangeset, without removing it from
   domain's list

Changes in v10:
 - New in v10. The function is used in "vpci/header: handle p2m range sets per 
BAR"
---
 xen/common/rangeset.c      | 16 ++++++++++++----
 xen/include/xen/rangeset.h |  3 ++-
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/xen/common/rangeset.c b/xen/common/rangeset.c
index 0ccd53caac52..b75590f90744 100644
--- a/xen/common/rangeset.c
+++ b/xen/common/rangeset.c
@@ -448,11 +448,20 @@ struct rangeset *rangeset_new(
     return r;
 }
 
-void rangeset_destroy(
-    struct rangeset *r)
+void rangeset_purge(struct rangeset *r)
 {
     struct range *x;
 
+    if ( r == NULL )
+        return;
+
+    while ( (x = first_range(r)) != NULL )
+        destroy_range(r, x);
+}
+
+void rangeset_destroy(
+    struct rangeset *r)
+{
     if ( r == NULL )
         return;
 
@@ -463,8 +472,7 @@ void rangeset_destroy(
         spin_unlock(&r->domain->rangesets_lock);
     }
 
-    while ( (x = first_range(r)) != NULL )
-        destroy_range(r, x);
+    rangeset_purge(r);
 
     xfree(r);
 }
diff --git a/xen/include/xen/rangeset.h b/xen/include/xen/rangeset.h
index 87bd956962b5..96c918082501 100644
--- a/xen/include/xen/rangeset.h
+++ b/xen/include/xen/rangeset.h
@@ -56,7 +56,7 @@ void rangeset_limit(
 bool __must_check rangeset_is_empty(
     const struct rangeset *r);
 
-/* Add/claim/remove/query a numeric range. */
+/* Add/claim/remove/query/purge a numeric range. */
 int __must_check rangeset_add_range(
     struct rangeset *r, unsigned long s, unsigned long e);
 int __must_check rangeset_claim_range(struct rangeset *r, unsigned long size,
@@ -70,6 +70,7 @@ bool __must_check rangeset_overlaps_range(
 int rangeset_report_ranges(
     struct rangeset *r, unsigned long s, unsigned long e,
     int (*cb)(unsigned long s, unsigned long e, void *data), void *ctxt);
+void rangeset_purge(struct rangeset *r);
 
 /*
  * Note that the consume function can return an error value apart from
-- 
2.43.0




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.