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

[PATCH RFC] rangeset: mark a few functions pure


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 28 Sep 2022 14:12:30 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • 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=gyAqsiSzPa5o+G/D+k0KBts/58aQQznsv6CR5kobuHY=; b=ZrTKrzbq0SmLM27SKLLiZodjQvZ1tXsWxRtz2Kp16G4gaovgS5yZ5Wy0fjuaIMUwSnUWRDvEaZBi4f9gslBHVfBTS2ydX5JXODObKagppByofyvoGO5B3znpd52LFAl14NQ4hGW6UsV1Z+GN63ApyuzSwOYY8meDk9WaBuOUYLKueo1YYPQHwK5fUZ804aSHhCQYPXp8e8kLiKvANTUM3AdNCc1Uez/GWYc9uI6/9u+wEhGyii3JMVCDKT5O8CbAq2Okiy0WEp1b4Js4ZeHNc0JQNZf8dqF4Bo3BGNtZTo4oDVfvBH4d8RiP29lEJ5dJoj6p1Ps/uVeMLciI2D52yQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F4DpHQJbFxNLQxE/1YccGtzWNZhk/bUmgAmvf5BDcM5lFOZrVyW/0iGkPaGTuBzu1LNNLU5Kap8FG6R0fN34MAFexkw4Z9bdQO3hfalllbl6bDkycx4BtJBpwIVFgdH6eTjJbLubA14sadXObaSN+e6SFNzwKhpAipabDVcRY2fcefFlRM3KGLWjlGQKs2erCIaYSwLoWiPH8qT4+wYd6j6S4wR09m3HjXcPAW7CkkBB+qogJM0XouEwxcbHP+GEnOPqavFZLL8iO+SErQZn7JV2t3NGJfyFibIQAZ0Ys0CGSW+gW3UMn1aIcUpxhB2ZZLpbRbxfM5bIv7F9yiReMg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Wed, 28 Sep 2022 12:12:41 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

While for some of the functions there's locking involved, the acquiring
and releasing of a lock doesn't alter program state when comparing
"before" and "after" the function invocations. Furthermore without
(further) locking by callers, return values are stale anyway by the time
they can be evaluated. Hence both CSE and DCE are okay to occur for
invocations of these functions.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---
RFC for the (imo) ambiguous wording in documentation.

I further wonder whether functions trivially wrapping others without
de-referencing the rangeset pointer, like
rangeset_{add,remove,contains}_singleton(), wouldn't better be inline
ones. This would (afaict) eliminate the need for marking pure the one of
those altered here.

--- a/xen/include/xen/rangeset.h
+++ b/xen/include/xen/rangeset.h
@@ -52,7 +52,7 @@ void rangeset_limit(
 #define _RANGESETF_prettyprint_hex 0
 #define RANGESETF_prettyprint_hex  (1U << _RANGESETF_prettyprint_hex)
 
-bool_t __must_check rangeset_is_empty(
+bool __must_check __attribute_pure__ rangeset_is_empty(
     const struct rangeset *r);
 
 /* Add/claim/remove/query a numeric range. */
@@ -62,9 +62,9 @@ int __must_check rangeset_claim_range(st
                                       unsigned long *s);
 int __must_check rangeset_remove_range(
     struct rangeset *r, unsigned long s, unsigned long e);
-bool_t __must_check rangeset_contains_range(
+bool __must_check __attribute_pure__ rangeset_contains_range(
     struct rangeset *r, unsigned long s, unsigned long e);
-bool_t __must_check rangeset_overlaps_range(
+bool __must_check __attribute_pure__ rangeset_overlaps_range(
     struct rangeset *r, unsigned long s, unsigned long e);
 int rangeset_report_ranges(
     struct rangeset *r, unsigned long s, unsigned long e,
@@ -88,7 +88,7 @@ int __must_check rangeset_add_singleton(
     struct rangeset *r, unsigned long s);
 int __must_check rangeset_remove_singleton(
     struct rangeset *r, unsigned long s);
-bool_t __must_check rangeset_contains_singleton(
+bool __must_check __attribute_pure__ rangeset_contains_singleton(
     struct rangeset *r, unsigned long s);
 
 /* swap contents */



 


Rackspace

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