* [PATCH] Make lock profiling usable again
@ 2011-11-04 12:52 Juergen Gross
2011-11-05 4:10 ` Hao, Xudong
0 siblings, 1 reply; 4+ messages in thread
From: Juergen Gross @ 2011-11-04 12:52 UTC (permalink / raw)
To: xen-devel; +Cc: xudong.hao
[-- Attachment #1: Type: text/plain, Size: 498 bytes --]
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@ts.fujitsu.com
2 files changed, 44 insertions(+), 24 deletions(-)
xen/common/spinlock.c | 34 +++++++++++++++++++++-------------
xen/include/xen/spinlock.h | 34 +++++++++++++++++++++++-----------
[-- Attachment #2: xen-staging.hg.patch --]
[-- Type: text/x-patch, Size: 7550 bytes --]
# HG changeset patch
# User Juergen Gross <juergen.gross@ts.fujitsu.com>
# Date 1320411131 -3600
# Node ID df918a251d01d3ac6267bee9d4a7351d41167688
# Parent 801ca6c0fbfa07e12c10c3079fc60cfb47dd0e3b
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@ts.fujitsu.com
diff -r 801ca6c0fbfa -r df918a251d01 xen/common/spinlock.c
--- a/xen/common/spinlock.c Thu Nov 03 17:28:41 2011 +0100
+++ b/xen/common/spinlock.c Fri Nov 04 13:52:11 2011 +0100
@@ -86,17 +86,23 @@ void spin_debug_disable(void)
#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 @@ int _spin_trylock(spinlock_t *lock)
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 @@ void _spin_barrier(spinlock_t *lock)
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 @@ static int __init lock_prof_init(void)
{
(*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 801ca6c0fbfa -r df918a251d01 xen/include/xen/spinlock.h
--- a/xen/include/xen/spinlock.h Thu Nov 03 17:28:41 2011 +0100
+++ b/xen/include/xen/spinlock.h Fri Nov 04 13:52:11 2011 +0100
@@ -20,6 +20,9 @@ struct lock_debug { };
#endif
#ifdef LOCK_PROFILE
+
+#include <public/sysctl.h>
+
/*
lock profiling on:
@@ -54,9 +57,12 @@ struct lock_debug { };
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 @@ struct lock_profile_qhead {
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 { };
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 @@ struct lock_profile_qhead { };
#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;
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
^ permalink raw reply [flat|nested] 4+ messages in thread* RE: [PATCH] Make lock profiling usable again
2011-11-04 12:52 [PATCH] Make lock profiling usable again Juergen Gross
@ 2011-11-05 4:10 ` Hao, Xudong
2011-11-07 5:52 ` Juergen Gross
0 siblings, 1 reply; 4+ messages in thread
From: Hao, Xudong @ 2011-11-05 4:10 UTC (permalink / raw)
To: Juergen Gross, xen-devel@lists.xensource.com
Initialize profile to NULL when lock profiling is not enabled.
diff -r 068d3d55ce6e xen/include/xen/spinlock.h
--- a/xen/include/xen/spinlock.h Tue Nov 01 19:03:38 2011 +0000
+++ b/xen/include/xen/spinlock.h Sat Nov 05 11:57:38 2011 +0800
@@ -108,7 +108,7 @@ struct lock_profile_qhead { };
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))
Thanks,
-Xudong
> -----Original Message-----
> From: Juergen Gross [mailto:juergen.gross@ts.fujitsu.com]
> Sent: Friday, November 04, 2011 8:53 PM
> To: xen-devel@lists.xensource.com
> Cc: Hao, Xudong
> Subject: [PATCH] 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@ts.fujitsu.com
>
>
> 2 files changed, 44 insertions(+), 24 deletions(-)
> xen/common/spinlock.c | 34 +++++++++++++++++++++-------------
> xen/include/xen/spinlock.h | 34 +++++++++++++++++++++++-----------
>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: RE: [PATCH] Make lock profiling usable again
2011-11-05 4:10 ` Hao, Xudong
@ 2011-11-07 5:52 ` Juergen Gross
2011-11-07 6:00 ` Hao, Xudong
0 siblings, 1 reply; 4+ messages in thread
From: Juergen Gross @ 2011-11-07 5:52 UTC (permalink / raw)
To: Hao, Xudong; +Cc: xen-devel@lists.xensource.com
Xudong,
I found that bug after sending you the patch and included the correction
already in the version sent to xen-devel.
Juergen
On 11/05/2011 05:10 AM, Hao, Xudong wrote:
> Initialize profile to NULL when lock profiling is not enabled.
>
> diff -r 068d3d55ce6e xen/include/xen/spinlock.h
> --- a/xen/include/xen/spinlock.h Tue Nov 01 19:03:38 2011 +0000
> +++ b/xen/include/xen/spinlock.h Sat Nov 05 11:57:38 2011 +0800
> @@ -108,7 +108,7 @@ struct lock_profile_qhead { };
> 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))
>
>
> Thanks,
> -Xudong
>
>
>> -----Original Message-----
>> From: Juergen Gross [mailto:juergen.gross@ts.fujitsu.com]
>> Sent: Friday, November 04, 2011 8:53 PM
>> To: xen-devel@lists.xensource.com
>> Cc: Hao, Xudong
>> Subject: [PATCH] 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@ts.fujitsu.com
>>
>>
>> 2 files changed, 44 insertions(+), 24 deletions(-)
>> xen/common/spinlock.c | 34 +++++++++++++++++++++-------------
>> xen/include/xen/spinlock.h | 34 +++++++++++++++++++++++-----------
>>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xensource.com
> http://lists.xensource.com/xen-devel
>
>
--
Juergen Gross Principal Developer Operating Systems
PDG ES&S SWE OS6 Telephone: +49 (0) 89 3222 2967
Fujitsu Technology Solutions e-mail: juergen.gross@ts.fujitsu.com
Domagkstr. 28 Internet: ts.fujitsu.com
D-80807 Muenchen Company details: ts.fujitsu.com/imprint.html
^ permalink raw reply [flat|nested] 4+ messages in thread* RE: RE: [PATCH] Make lock profiling usable again
2011-11-07 5:52 ` Juergen Gross
@ 2011-11-07 6:00 ` Hao, Xudong
0 siblings, 0 replies; 4+ messages in thread
From: Hao, Xudong @ 2011-11-07 6:00 UTC (permalink / raw)
To: Juergen Gross; +Cc: xen-devel@lists.xensource.com
> -----Original Message-----
> From: Juergen Gross [mailto:juergen.gross@ts.fujitsu.com]
> Sent: Monday, November 07, 2011 1:52 PM
> To: Hao, Xudong
> Cc: xen-devel@lists.xensource.com
> Subject: Re: [Xen-devel] RE: [PATCH] Make lock profiling usable again
>
> Xudong,
>
> I found that bug after sending you the patch and included the correction
> already in the version sent to xen-devel.
>
OK, thanks.
>
> Juergen
>
> On 11/05/2011 05:10 AM, Hao, Xudong wrote:
> > Initialize profile to NULL when lock profiling is not enabled.
> >
> > diff -r 068d3d55ce6e xen/include/xen/spinlock.h
> > --- a/xen/include/xen/spinlock.h Tue Nov 01 19:03:38 2011 +0000
> > +++ b/xen/include/xen/spinlock.h Sat Nov 05 11:57:38 2011 +0800
> > @@ -108,7 +108,7 @@ struct lock_profile_qhead { };
> > 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))
> >
> >
> > Thanks,
> > -Xudong
> >
> >
> >> -----Original Message-----
> >> From: Juergen Gross [mailto:juergen.gross@ts.fujitsu.com]
> >> Sent: Friday, November 04, 2011 8:53 PM
> >> To: xen-devel@lists.xensource.com
> >> Cc: Hao, Xudong
> >> Subject: [PATCH] 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@ts.fujitsu.com
> >>
> >>
> >> 2 files changed, 44 insertions(+), 24 deletions(-)
> >> xen/common/spinlock.c | 34 +++++++++++++++++++++-------------
> >> xen/include/xen/spinlock.h | 34 +++++++++++++++++++++++-----------
> >>
> >
> > _______________________________________________
> > Xen-devel mailing list
> > Xen-devel@lists.xensource.com
> > http://lists.xensource.com/xen-devel
> >
> >
>
>
> --
> Juergen Gross Principal Developer Operating Systems
> PDG ES&S SWE OS6 Telephone: +49 (0) 89 3222
> 2967
> Fujitsu Technology Solutions e-mail:
> juergen.gross@ts.fujitsu.com
> Domagkstr. 28 Internet: ts.fujitsu.com
> D-80807 Muenchen Company details:
> ts.fujitsu.com/imprint.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-11-07 6:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-04 12:52 [PATCH] Make lock profiling usable again Juergen Gross
2011-11-05 4:10 ` Hao, Xudong
2011-11-07 5:52 ` Juergen Gross
2011-11-07 6:00 ` Hao, Xudong
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.