Message ID | 7c4f50ce-6212-2f16-c9c5-c9af450b10ba@suse.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | lockprof: eliminate a minor bug and a quirk | expand |
On 23/07/2020 11:51, Jan Beulich wrote: > 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> > > --- a/xen/include/xen/spinlock.h > +++ b/xen/include/xen/spinlock.h > @@ -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 " #l "\n", \ > + s, (s)->profile_head.idx); \ You'll end up with far less .rodata if you use %s and pass #l in as a parameter. Either way, Acked-by: Andrew Cooper <andrew.cooper3@citrix.com> > + 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) >
On 23.07.2020 13:23, Andrew Cooper wrote: > On 23/07/2020 11:51, Jan Beulich wrote: >> 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> >> >> --- a/xen/include/xen/spinlock.h >> +++ b/xen/include/xen/spinlock.h >> @@ -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 " #l "\n", \ >> + s, (s)->profile_head.idx); \ > > You'll end up with far less .rodata if you use %s and pass #l in as a > parameter. Well, "far less" perhaps goes a little far, as we currently have just three use sites, but I see your point and hence will switch. > Either way, Acked-by: Andrew Cooper <andrew.cooper3@citrix.com> Thanks, Jan
--- a/xen/include/xen/spinlock.h +++ b/xen/include/xen/spinlock.h @@ -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 " #l "\n", \ + s, (s)->profile_head.idx); \ + 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)
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>