WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] Make lock profiling usable again

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] Make lock profiling usable again
From: Xen patchbot-unstable <patchbot@xxxxxxx>
Date: Fri, 11 Nov 2011 04:33:22 +0000
Delivery-date: Thu, 10 Nov 2011 20:36:23 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Juergen Gross <juergen.gross@xxxxxxxxxxxxxx>
# Date 1320676604 0
# Node ID 10ddd98dcc62b0fb4238794144b180c604f1696b
# Parent  c0702424afc5f7b972c26c6110f6489305844635
Make lock profiling usable again

Using lock profiling (option lock_profile in xen/Rules.mk) resulted in
build errors.
Changes:
- Include public/sysctl.h in spinlock.h when using lock profiling.
- Allocate profile data in an own structure to avoid struct domain
  becoming larger then one page

Signed-off-by: Juergen Gross <juergen.gross@xxxxxxxxxxxxxx>
Acked-by: Keir Fraser <keir@xxxxxxx>
---


diff -r c0702424afc5 -r 10ddd98dcc62 xen/common/spinlock.c
--- a/xen/common/spinlock.c     Mon Nov 07 10:29:14 2011 +0100
+++ b/xen/common/spinlock.c     Mon Nov 07 14:36:44 2011 +0000
@@ -86,17 +86,23 @@
 
 #ifdef LOCK_PROFILE
 
-#define LOCK_PROFILE_REL                                               \
-    lock->profile.time_hold += NOW() - lock->profile.time_locked;      \
-    lock->profile.lock_cnt++;
+#define LOCK_PROFILE_REL                                                     \
+    if (lock->profile)                                                       \
+    {                                                                        \
+        lock->profile->time_hold += NOW() - lock->profile->time_locked;      \
+        lock->profile->lock_cnt++;                                           \
+    }
 #define LOCK_PROFILE_VAR    s_time_t block = 0
 #define LOCK_PROFILE_BLOCK  block = block ? : NOW();
-#define LOCK_PROFILE_GOT                                               \
-    lock->profile.time_locked = NOW();                                 \
-    if (block)                                                         \
-    {                                                                  \
-        lock->profile.time_block += lock->profile.time_locked - block; \
-        lock->profile.block_cnt++;                                     \
+#define LOCK_PROFILE_GOT                                                     \
+    if (lock->profile)                                                       \
+    {                                                                        \
+        lock->profile->time_locked = NOW();                                  \
+        if (block)                                                           \
+        {                                                                    \
+            lock->profile->time_block += lock->profile->time_locked - block; \
+            lock->profile->block_cnt++;                                      \
+        }                                                                    \
     }
 
 #else
@@ -197,7 +203,8 @@
     if ( !_raw_spin_trylock(&lock->raw) )
         return 0;
 #ifdef LOCK_PROFILE
-    lock->profile.time_locked = NOW();
+    if (lock->profile)
+        lock->profile->time_locked = NOW();
 #endif
     preempt_disable();
     return 1;
@@ -211,10 +218,10 @@
 
     check_barrier(&lock->debug);
     do { mb(); loop++;} while ( _raw_spin_is_locked(&lock->raw) );
-    if (loop > 1)
+    if ((loop > 1) && lock->profile)
     {
-        lock->profile.time_block += NOW() - block;
-        lock->profile.block_cnt++;
+        lock->profile->time_block += NOW() - block;
+        lock->profile->block_cnt++;
     }
 #else
     check_barrier(&lock->debug);
@@ -586,6 +593,7 @@
     {
         (*q)->next = lock_profile_glb_q.elem_q;
         lock_profile_glb_q.elem_q = *q;
+        (*q)->lock->profile = *q;
     }
 
     _lock_profile_register_struct(
diff -r c0702424afc5 -r 10ddd98dcc62 xen/include/xen/spinlock.h
--- a/xen/include/xen/spinlock.h        Mon Nov 07 10:29:14 2011 +0100
+++ b/xen/include/xen/spinlock.h        Mon Nov 07 14:36:44 2011 +0000
@@ -20,6 +20,9 @@
 #endif
 
 #ifdef LOCK_PROFILE
+
+#include <public/sysctl.h>
+
 /*
     lock profiling on:
 
@@ -54,9 +57,12 @@
       lock_profile_deregister_struct(type, ptr);
 */
 
+struct spinlock;
+
 struct lock_profile {
     struct lock_profile *next;       /* forward link */
     char                *name;       /* lock name */
+    struct spinlock     *lock;       /* the lock itself */
     u64                 lock_cnt;    /* # of complete locking ops */
     u64                 block_cnt;   /* # of complete wait for lock */
     s64                 time_hold;   /* cumulated lock time */
@@ -70,23 +76,29 @@
     int32_t                   idx;     /* index for printout */
 };
 
-#define _LOCK_PROFILE(name) { 0, name, 0, 0, 0, 0, 0 }
-#define _LOCK_NO_PROFILE _LOCK_PROFILE(NULL)
+#define _LOCK_PROFILE(name) { 0, #name, &name, 0, 0, 0, 0, 0 }
 #define _LOCK_PROFILE_PTR(name)                                               \
     static struct lock_profile *__lock_profile_##name __attribute_used__      \
-    __attribute__ ((__section__(".lockprofile.data"))) = &name.profile
+    __attribute__ ((__section__(".lockprofile.data"))) =                      \
+    &__lock_profile_data_##name
 #define _SPIN_LOCK_UNLOCKED(x) { _RAW_SPIN_LOCK_UNLOCKED, 0xfffu, 0,          \
                                  _LOCK_DEBUG, x }
-#define SPIN_LOCK_UNLOCKED _SPIN_LOCK_UNLOCKED(_LOCK_NO_PROFILE)
+#define SPIN_LOCK_UNLOCKED _SPIN_LOCK_UNLOCKED(NULL)
 #define DEFINE_SPINLOCK(l)                                                    \
-    spinlock_t l = _SPIN_LOCK_UNLOCKED(_LOCK_PROFILE(#l));                    \
+    spinlock_t l = _SPIN_LOCK_UNLOCKED(NULL);                                 \
+    static struct lock_profile __lock_profile_data_##l = _LOCK_PROFILE(l);    \
     _LOCK_PROFILE_PTR(l)
 
 #define spin_lock_init_prof(s, l)                                             \
     do {                                                                      \
-        (s)->l = (spinlock_t)_SPIN_LOCK_UNLOCKED(_LOCK_PROFILE(#l));          \
-        (s)->l.profile.next = (s)->profile_head.elem_q;                       \
-        (s)->profile_head.elem_q = &((s)->l.profile);                         \
+        struct lock_profile *prof;                                            \
+        prof = xzalloc(struct lock_profile);                                  \
+        if (!prof) 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)
 
 void _lock_profile_register_struct(
@@ -108,7 +120,7 @@
 struct lock_profile_qhead { };
 
 #define SPIN_LOCK_UNLOCKED                                                    \
-    { _RAW_SPIN_LOCK_UNLOCKED, 0xfffu, 0, _LOCK_DEBUG, { } }
+    { _RAW_SPIN_LOCK_UNLOCKED, 0xfffu, 0, _LOCK_DEBUG, NULL }
 #define DEFINE_SPINLOCK(l) spinlock_t l = SPIN_LOCK_UNLOCKED
 
 #define spin_lock_init_prof(s, l) spin_lock_init(&((s)->l))
@@ -117,12 +129,12 @@
 
 #endif
 
-typedef struct {
+typedef struct spinlock {
     raw_spinlock_t raw;
     u16 recurse_cpu:12;
     u16 recurse_cnt:4;
     struct lock_debug debug;
-    struct lock_profile profile;
+    struct lock_profile *profile;
 } spinlock_t;
 
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] Make lock profiling usable again, Xen patchbot-unstable <=