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

[PATCH] spinlock: alter inlining of _spin_lock_cb()


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 14 Jun 2023 16:17:19 +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=cunu0xp7pvxz5mEERk0+Akla7p/Ed2j8w9biXRMSufk=; b=TSSOswSe1KlAL7iO20MePSXXJaoJnn8u3o4U1BnxZ+JdP81c0Hh7vlqNRTT2Yvuxk5x1oMTZatHDT5zO8q6SSHDGV3QQiYr/zr+G9JFr5Yb/Dt738dshYfl7k7Rch+I86kv73/v6klctDXFC5gHtAaClDdgHrYzNkNOByVP6lZlP2DB5p+iO/5+Bfwqb4S+EkzfmZIxi2ZedKJfjpRWmah9X/dGz5CZutDi7WL5S1eHLUKrjcg60r2BthIDHkrp+lotheFl7OkKgIRT2nJIgrO16YycZoiHXvrt+2Bco9XnNp3nVI3Lmjko7uDNVXkQ4E65NjPgLgLL68B7O3itofQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AWGUC04IMIeomgJxUZd0DhVwXdHfwYESptrcyXe+tn416jpFA8F1yL0foQNsFBDp2jTwFf+Ekyewqba+GOugKvp4Y0T6TDu2tA9GUBztETjjvBnBcovuWGGzuG96u8O+qJXy5woMgnanOpVOweYyM4vh1BUTNQcApt7c8UETFQqcawrkjjIjnLxUPKMeiUdLt6QTc8fAwgNWj8b8jc/LsQOD7tri2chKrjVpLX8aOiFusuhpTFdxdGHheqw/X1XlBGlifmc23ef560/Gsw2pqVA4+a+uuGFwLIxquaI7BnUzl9g02NczBhcDpUga638BbfkYaoNn9apR53ar8Lq2UQ==
  • 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>, Federico Serafini <federico.serafini@xxxxxxxxxxx>
  • Delivery-date: Wed, 14 Jun 2023 14:17:42 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

To comply with Misra rule 8.10 ("An inline function shall be declared
with the static storage class"), convert what is presently
_spin_lock_cb() to an always-inline (and static) helper, while making
the function itself a thin wrapper, just like _spin_lock() is.

While there drop the unlikely() from the callback check, and correct
indentation in _spin_lock().

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>

--- a/xen/common/spinlock.c
+++ b/xen/common/spinlock.c
@@ -304,7 +304,8 @@ static always_inline u16 observe_head(sp
     return read_atomic(&t->head);
 }
 
-void inline _spin_lock_cb(spinlock_t *lock, void (*cb)(void *), void *data)
+static void always_inline spin_lock_common(spinlock_t *lock,
+                                           void (*cb)(void *), void *data)
 {
     spinlock_tickets_t tickets = SPINLOCK_TICKET_INC;
     LOCK_PROFILE_VAR;
@@ -316,7 +317,7 @@ void inline _spin_lock_cb(spinlock_t *lo
     while ( tickets.tail != observe_head(&lock->tickets) )
     {
         LOCK_PROFILE_BLOCK;
-        if ( unlikely(cb) )
+        if ( cb )
             cb(data);
         arch_lock_relax();
     }
@@ -327,7 +328,12 @@ void inline _spin_lock_cb(spinlock_t *lo
 
 void _spin_lock(spinlock_t *lock)
 {
-     _spin_lock_cb(lock, NULL, NULL);
+    spin_lock_common(lock, NULL, NULL);
+}
+
+void _spin_lock_cb(spinlock_t *lock, void (*cb)(void *), void *data)
+{
+    spin_lock_common(lock, cb, data);
 }
 
 void _spin_lock_irq(spinlock_t *lock)



 


Rackspace

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