]> xenbits.xensource.com Git - people/jgross/xen.git/commitdiff
lockprof: don't leave locks uninitialized upon allocation failure
authorJan Beulich <jbeulich@suse.com>
Fri, 24 Jul 2020 08:18:30 +0000 (10:18 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 24 Jul 2020 08:18:30 +0000 (10:18 +0200)
Even if a specific struct lock_profile instance can't be allocated, the
lock itself should still be functional. As this isn't a production use
feature, also log a message in the event that the profiling struct can't
be allocated.

Fixes: d98feda5c756 ("Make lock profiling usable again")
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/include/xen/spinlock.h

index 468b9ac9ef639cf66d807d97939c6c61c71ddc64..c0e7690a6c4bb2b301694069a8c557a646d40329 100644 (file)
@@ -103,10 +103,16 @@ struct lock_profile_qhead {
     do {                                                                      \
         struct lock_profile *prof;                                            \
         prof = xzalloc(struct lock_profile);                                  \
-        if (!prof) break;                                                     \
+        (s)->l = (spinlock_t)_SPIN_LOCK_UNLOCKED(prof);                       \
+        if ( !prof )                                                          \
+        {                                                                     \
+            printk(XENLOG_WARNING                                             \
+                   "lock profiling unavailable for %p(%d)'s %s\n",            \
+                   s, (s)->profile_head.idx, #l);                             \
+            break;                                                            \
+        }                                                                     \
         prof->name = #l;                                                      \
         prof->lock = &(s)->l;                                                 \
-        (s)->l = (spinlock_t)_SPIN_LOCK_UNLOCKED(prof);                       \
         prof->next = (s)->profile_head.elem_q;                                \
         (s)->profile_head.elem_q = prof;                                      \
     } while(0)