Implement per-cpu reader-writer locks
PATCH v6 3/3 p2m: convert p2m rwlock to percpu rwlock
In reply to Malcolm CrossleyThe per domain p2m read lock suffers from significant contention when performance multi-queue block or network IO due to the parallel grant map/unmaps/copies occuring on the DomU's p2m.
On multi-socket systems, the contention results in the locked compare swap operation failing frequently which results in a tight loop of retries of the compare swap operation. As the coherency fabric can only support a specific rate of compare swap operations for a particular data location then taking the read lock itself becomes a bottleneck for p2m operations.
Percpu rwlock p2m performance with the same configuration is approximately 64 gbit/s vs the 48 gbit/s with grant table percpu rwlocks only.
Oprofile was used to determine the initial overhead of the read-write locks and to confirm the overhead was dramatically reduced by the percpu rwlocks.
Note: altp2m users will not achieve a gain if they take an altp2m read lock simultaneously with the main p2m lock.
--
Changes since v5:
- None
Changes since v4:
- None
Changes since v3:
- None
Changes since v2
- Updated local percpu rwlock initialisation
--- xen/arch/x86/mm/mm-locks.h | 12 +++++++----- xen/arch/x86/mm/p2m.c | 1 + xen/include/asm-x86/mm.h | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-)
xen/arch/x86/mm/mm-locks.h +7 -5
@@ -31,6 +31,8 @@DECLARE_PER_CPU (int, mm_lock_level);#define __get_lock_level () (this_cpu(mm_lock_level)) +DECLARE_PERCPU_RWLOCK_GLOBAL (p2m_percpu_rwlock); +static inline void mm_lock_init (mm_lock_t *l) {spin_lock_init (&l->lock);
@@ -99,7 +101,7 @@ static inline void _mm_enforce_order_lock_post(int level, int *unlock_level,static inline void mm_rwlock_init (mm_rwlock_t *l) { -rwlock_init (&l->lock); +percpu_rwlock_resource_init (&l->lock, p2m_percpu_rwlock); l->locker =-1 ; l->locker_function ="nobody" ; l->unlock_level =0 ;
@@ -115,7 +117,7 @@ static inline void _mm_write_lock(mm_rwlock_t *l, const char *func, int level)if ( !mm_write_locked_by_me (l) ) {__check_lock_level (level); -write_lock (&l->lock); +percpu_write_lock (p2m_percpu_rwlock, &l->lock); l->locker =get_processor_id (); l->locker_function = func; l->unlock_level =__get_lock_level ();
@@ -131,20 +133,20 @@ static inline void mm_write_unlock(mm_rwlock_t *l) l->locker =-1 ; l->locker_function ="nobody" ;__set_lock_level (l->unlock_level); -write_unlock (&l->lock); +percpu_write_unlock (p2m_percpu_rwlock, &l->lock); }static inline void _mm_read_lock (mm_rwlock_t *l,int level) {__check_lock_level (level); -read_lock (&l->lock); +percpu_read_lock (p2m_percpu_rwlock, &l->lock);/* There's nowhere to store the per-CPU unlock level so we can't * set the lock level. */ }static inline void mm_read_unlock (mm_rwlock_t *l) { -read_unlock (&l->lock); +percpu_read_unlock (p2m_percpu_rwlock, &l->lock); }/* This wrapper uses the line number to express the locking order below */
xen/arch/x86/mm/p2m.c +1 -0
@@ -54,6 +54,7 @@ boolean_param("hap_2mb", opt_hap_2mb);#undef page_to_mfn#define page_to_mfn (_pg) _mfn(__page_to_mfn(_pg)) +DEFINE_PERCPU_RWLOCK_GLOBAL (p2m_percpu_rwlock);/* Init the datastructures for later use by the p2m code */ static int p2m_initialise (struct domain *d,struct p2m_domain *p2m)
xen/include/asm-x86/mm.h +1 -1
@@ -584,7 +584,7 @@ typedef struct mm_lock { } mm_lock_t; typedef struct mm_rwlock { - rwlock_t lock; + percpu_rwlock_t lock; int unlock_level; int recurse_count; int locker; /* CPU that holds the write lock */
Signature · 1 line
1.7.12.4
PATCH v6 1/3 rwlock: Add per-cpu reader-writer lock infrastructure
In reply to Malcolm CrossleyPer-cpu read-write locks allow for the fast path read case to have low overhead by only setting/clearing a per-cpu variable for using the read lock. The per-cpu read fast path also avoids locked compare swap operations which can be particularly slow on coherent multi-socket systems, particularly if there is heavy usage of the read lock itself.
The per-cpu reader-writer lock uses a local variable to control the read lock fast path. This allows a writer to disable the fast path and ensures the readers switch to using the underlying read-write lock implementation instead of the per-cpu variable.
Once the writer has taken the write lock and disabled the fast path, it must poll the per-cpu variable for all CPU's which have entered the critical section for the specific read-write lock the writer is attempting to take. This design allows for a single per-cpu variable to be used for read/write locks belonging to seperate data structures. If a two or more different per-cpu read lock(s) are taken simultaneously then the per-cpu data structure is not used and the implementation takes the read lock of the underlying read-write lock, this behaviour is equivalent to the slow path in terms of performance. The per-cpu rwlock is not recursion safe for taking the per-cpu read lock because there is no recursion count variable, this is functionally equivalent to standard spin locks.
Slow path readers which are unblocked, set the per-cpu variable and drop the read lock. This simplifies the implementation and allows for fairness in the underlying read-write lock to be taken advantage of.
There is more overhead on the per-cpu write lock path due to checking each CPUs fast path per-cpu variable but this overhead is likely be hidden by the required delay of waiting for readers to exit the critical section. The loop is optimised to only iterate over the per-cpu data of active readers of the rwlock. The cpumask_t for tracking the active readers is stored in a single per-cpu data location and thus the write lock is not pre-emption safe. Therefore the per-cpu write lock can only be used with interrupts disabled.
--
Changes since v5:
- Fix compilation on ARM
Changes since v4:
- Use static inlines for the percpu_owner check
Changes since v3:
- Fix the ASSERTS for the percpu_owner check
Changes since v2:
- Remove stray hard tabs
- Added owner field to percpu_rwlock_t for debug builds. This allows for ASSERTs to be added which verify the correct global percpu structure is used for the local initialised percpu_rwlock lock
Changes since v1:
- Removed restriction on taking two or more different percpu rw locks simultaneously
- Moved fast-path/slow-path barrier to be per lock instead of global
- Created seperate percpu_rwlock_t type and added macros to initialise new type
- Added helper macros for using the percpu rwlock itself
- Moved active_readers cpumask off the stack and into a percpu variable
--- xen/common/spinlock.c | 45 +++++++++++++++++ xen/include/asm-arm/percpu.h | 5 ++ xen/include/asm-x86/percpu.h | 6 +++ xen/include/xen/percpu.h | 4 ++ xen/include/xen/spinlock.h | 116 +++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 176 insertions(+)
xen/common/spinlock.c +45 -0
@@ -10,6 +10,8 @@#include <asm/processor.h> #include <asm/atomic.h> +static DEFINE_PER_CPU(cpumask_t, percpu_rwlock_readers); +#ifndef NDEBUG static atomic_t spin_debug__read_mostly =ATOMIC_INIT (0 );
@@ -492,6 +494,49 @@ int _rw_is_write_locked(rwlock_t *lock)return (lock->lock ==RW_WRITE_FLAG );/* writer in critical section? */ } +void _percpu_write_lock (percpu_rwlock_t **per_cpudata, +percpu_rwlock_t *percpu_rwlock) +{ +unsigned int cpu; +cpumask_t *rwlock_readers = &this_cpu (percpu_rwlock_readers); + +/* Validate the correct per_cpudata variable has been provided. */ +_percpu_rwlock_owner_check (per_cpudata, percpu_rwlock); + +/* +* First take the write lock to protect against other writers or slow +* path readers. +*/ +write_lock (&percpu_rwlock->rwlock); + +/* Now set the global variable so that readers start using read_lock. */ + percpu_rwlock->writer_activating =1 ; +smp_mb (); + +/* Using a per cpu cpumask is only safe if there is no nesting. */ +ASSERT (!in_irq ()); +cpumask_copy (rwlock_readers, &cpu_online_map); + +/* Check if there are any percpu readers in progress on this rwlock. */ +for ( ; ; ) + { +for_each_cpu (cpu, rwlock_readers) + { +/* +* Remove any percpu readers not contending on this rwlock +* from our check mask. +*/ +if (per_cpu_ptr (per_cpudata, cpu) != percpu_rwlock ) +__cpumask_clear_cpu (cpu, rwlock_readers); + } +/* Check if we've cleared all percpu readers from check mask. */ +if (cpumask_empty (rwlock_readers) ) +break ; +/* Give the coherency fabric a break. */ +cpu_relax (); + }; +} +#ifdef LOCK_PROFILE struct lock_profile_anc {
xen/include/asm-arm/percpu.h +5 -0
@@ -27,6 +27,11 @@ void percpu_init_areas(void);#define __get_cpu_var (var) \ (*RELOC_HIDE(&per_cpu__##var, READ_SYSREG(TPIDR_EL2))) +#define per_cpu_ptr (var, cpu) \ + (*RELOC_HIDE(var, __per_cpu_offset[cpu])) +#define __get_cpu_ptr (var) \ + (*RELOC_HIDE(var, READ_SYSREG(TPIDR_EL2))) +#define DECLARE_PER_CPU (type, name) extern __typeof__(type) per_cpu__##name DECLARE_PER_CPU(unsigned int, cpu_id);
xen/include/asm-x86/percpu.h +6 -0
@@ -20,4 +20,10 @@ void percpu_init_areas(void);#define DECLARE_PER_CPU (type, name) extern __typeof__(type) per_cpu__##name +#define __get_cpu_ptr (var) \ + (*RELOC_HIDE(var, get_cpu_info()->per_cpu_offset)) + +#define per_cpu_ptr (var, cpu) \ + (*RELOC_HIDE(var, __per_cpu_offset[cpu])) +#endif /* __X86_PERCPU_H__ */
xen/include/xen/percpu.h +4 -0
@@ -16,6 +16,10 @@/* Preferred on Xen. Also see arch-defined per_cpu(). */ #define this_cpu (var) __get_cpu_var(var) +#define this_cpu_ptr (ptr) __get_cpu_ptr(ptr) + +#define get_per_cpu_var (var) (per_cpu__##var) +/* Linux compatibility. */ #define get_cpu_var (var) this_cpu(var)#define put_cpu_var (var)
xen/include/xen/spinlock.h +116 -0
126 lines not on this page · raw message
Signature · 1 line
1.7.12.4
PATCH v6 2/3 grant_table: convert grant table rwlock to percpu rwlock
In reply to Malcolm CrossleyThe per domain grant table read lock suffers from significant contention when performance multi-queue block or network IO due to the parallel grant map/unmaps/copies occurring on the DomU's grant table.
On multi-socket systems, the contention results in the locked compare swap operation failing frequently which results in a tight loop of retries of the compare swap operation. As the coherency fabric can only support a specific rate of compare swap operations for a particular data location then taking the read lock itself becomes a bottleneck for grant operations.
Standard rwlock performance of a single VIF VM-VM transfer with 16 queues configured was limited to approximately 15 gbit/s on a 2 socket Haswell-EP host.
Percpu rwlock performance with the same configuration is approximately 48 gbit/s.
Oprofile was used to determine the initial overhead of the read-write locks and to confirm the overhead was dramatically reduced by the percpu rwlocks.
--
Changes since v5:
- None
Changes since v4:
- Rename grant table rwlock wrappers and use grant table pointer as argument
Changes since v3:
- None
Changes since v2:
- Switched to using wrappers for taking percpu rwlock
- Added percpu structure pointer to percpu rwlock initialisation
- Added comment on removal of ASSERTS for grant table rw_is_locked()
Changes since v1:
- Used new macros provided in updated percpu rwlock v2 patch
- Converted grant table rwlock_t to percpu_rwlock_t
- Patched a missed grant table rwlock_t usage site
--- xen/arch/arm/mm.c | 4 +- xen/arch/x86/mm.c | 4 +- xen/common/grant_table.c | 124 +++++++++++++++++++++++------------------- xen/include/xen/grant_table.h | 24 +++++++- 4 files changed, 96 insertions(+), 60 deletions(-)
xen/arch/arm/mm.c +2 -2
@@ -1055,7 +1055,7 @@ int xenmem_add_to_physmap_one(switch ( space ) {case XENMAPSPACE_grant_table: -write_lock (&d->grant_table->lock); +grant_write_lock (d->grant_table);if ( d->grant_table->gt_version ==0 ) d->grant_table->gt_version =1 ;
@@ -1085,7 +1085,7 @@ int xenmem_add_to_physmap_one( t = p2m_ram_rw; -write_unlock (&d->grant_table->lock); +grant_write_unlock (d->grant_table);break ;case XENMAPSPACE_shared_info:if ( idx !=0 )
xen/arch/x86/mm.c +2 -2
@@ -4671,7 +4671,7 @@ int xenmem_add_to_physmap_one( mfn =virt_to_mfn (d->shared_info);break ;case XENMAPSPACE_grant_table: -write_lock (&d->grant_table->lock); +grant_write_lock (d->grant_table);if ( d->grant_table->gt_version ==0 ) d->grant_table->gt_version =1 ;
@@ -4693,7 +4693,7 @@ int xenmem_add_to_physmap_one( mfn =virt_to_mfn (d->grant_table->shared_raw[idx]); } -write_unlock (&d->grant_table->lock); +grant_write_unlock (d->grant_table);break ;case XENMAPSPACE_gmfn_range:case XENMAPSPACE_gmfn:
xen/common/grant_table.c +69 -55
429 lines not on this page · raw message
xen/include/xen/grant_table.h +23 -1
@@ -51,13 +51,15 @@/* The maximum size of a grant table. */ extern unsigned int max_grant_frames; +DECLARE_PERCPU_RWLOCK_GLOBAL (grant_rwlock); +/* Per-domain grant information. */ struct grant_table {/* * Lock protecting updates to grant table state (version, active * entry list, etc.) */ -rwlock_t lock; +percpu_rwlock_t lock;/* Table size. Number of frames shared with guest */ unsigned int nr_grant_frames;/* Shared grant table (see include/public/grant_table.h). */
@@ -82,6 +84,26 @@ struct grant_table {unsigned gt_version; }; +static inline void grant_read_lock (struct grant_table *gt) +{ +percpu_read_lock (grant_rwlock, >->lock); +} + +static inline void grant_read_unlock (struct grant_table *gt) +{ +percpu_read_unlock (grant_rwlock, >->lock); +} + +static inline void grant_write_lock (struct grant_table *gt) +{ +percpu_write_lock (grant_rwlock, >->lock); +} + +static inline void grant_write_unlock (struct grant_table *gt) +{ +percpu_write_unlock (grant_rwlock, >->lock); +} +/* Create/destroy per-domain grant table context. */ int grant_table_create (struct domain *d);
Signature · 1 line
1.7.12.4
v6 cover Implement per-cpu reader-writer locks
This patch series adds per-cpu reader-writer locks as a generic lock implementation and then converts the grant table and p2m rwlocks to use the percpu rwlocks, in order to improve multi-socket host performance.
CPU profiling has revealed the rwlocks themselves suffer from severe cache line bouncing due to the cmpxchg operation used even when taking a read lock. Multiqueue paravirtualised I/O results in heavy contention of the grant table and p2m read locks of a specific domain and so I/O throughput is bottlenecked by the overhead of the cache line bouncing itself.
Per-cpu read locks avoid lock cache line bouncing by using a per-cpu data area to record a CPU has taken the read lock. Correctness is enforced for the write lock by using a per lock barrier which forces the per-cpu read lock to revert to using a standard read lock. The write lock then polls all the percpu data area until active readers for the lock have exited.
Removing the cache line bouncing on a multi-socket Haswell-EP system dramatically improves performance, with 16 vCPU network IO performance going from 15 gb/s to 64 gb/s! The host under test was fully utilising all 40 logical CPU's at 64 gb/s, so a bigger logical CPU host may see an even better IO improvement.
Note: Benchmarking of the these performance improvements should be done with the non debug version of the hypervisor otherwise the map_domain_page spinlock is the main bottleneck.
Changes in V6:
- Fix compilation on ARM
Changes in V5:
- Move percpu_owner ASSERTS to be inline function
- Rename grant table rwlock wrappers
Changes in V4:
- Fix the ASSERTS for the percpu_owner check
Changes in V3:
- Add percpu rwlock owner for debug Xen builds
- Validate percpu rwlock owner at runtime for debug Xen builds
- Fix hard tab issues
- Use percpu rwlock wrappers for grant table rwlock users
- Add comments why rw_is_locked ASSERTS have been removed in grant table code
Changes in V2:
- Add Cover letter
- Convert p2m rwlock to percpu rwlock
- Improve percpu rwlock to safely handle simultaneously holding 2 or more locks
- Move percpu rwlock barrier from global to per lock
- Move write lock cpumask variable to a percpu variable
- Add macros to help initialise and use percpu rwlocks
- Updated IO benchmark results to cover revised locking implementation
Malcolm Crossley (3):
rwlock: Add per-cpu reader-writer lock infrastructure
grant_table: convert grant table rwlock to percpu rwlock
p2m: convert p2m rwlock to percpu rwlock
xen/arch/arm/mm.c | 4 +- xen/arch/x86/mm.c | 4 +- xen/arch/x86/mm/mm-locks.h | 12 ++-- xen/arch/x86/mm/p2m.c | 1 + xen/common/grant_table.c | 124 +++++++++++++++++++++++------------------- xen/common/spinlock.c | 45 +++++++++++++++ xen/include/asm-arm/percpu.h | 5 ++ xen/include/asm-x86/mm.h | 2 +- xen/include/asm-x86/percpu.h | 6 ++ xen/include/xen/grant_table.h | 24 +++++++- xen/include/xen/percpu.h | 4 ++ xen/include/xen/spinlock.h | 116 +++++++++++++++++++++++++++++++++++++++ 12 files changed, 281 insertions(+), 66 deletions(-)
Signature · 1 line
1.7.12.4
Re: [PATCHv6 1/3] rwlock: Add per-cpu reader-writer lock infrastructure
In reply to Malcolm CrossleyQuoted 3 lines · Malcolm Crossley
Changes since v5:
- Fix compilation on ARM
This was the removal of some spurious "&", I think?
Thanks for catching this!
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCHv6 1/3] rwlock: Add per-cpu reader-writer lock infrastructure
Quoted 6 lines · Ian Campbell
Quoted 3 lines · Malcolm Crossley
Changes since v5:
- Fix compilation on ARMThis was the removal of some spurious "&", I think?
Yeah, I forgot to keep the macro's in sync. ARM also needed the xen/percpu.h header file to be explictly included into spinlock.h.
Quoted 4 lines
Acked-by Ian Campbell <[email protected]>Thanks for catching this!
Sorry for not build testing before on ARM. Building the hypervisor itself using a prebuilt linaro toolchain is actually very easy (no chroot required).
Do you think it's worth documenting this? So that at least hypervisor build failures are caught.
Malcolm
Re: [PATCHv6 1/3] rwlock: Add per-cpu reader-writer lock infrastructure
Quoted 13 lines · Malcolm Crossley
Quoted 6 lines · Ian Campbell
Quoted 3 lines · Malcolm Crossley
Changes since v5:
- Fix compilation on ARMThis was the removal of some spurious "&", I think?
Yeah, I forgot to keep the macro's in sync. ARM also needed the
xen/percpu.hheader file to be
explictly included intospinlock.h.Quoted 1 line
Quoted 5 lines
Quoted 3 lines
Acked-by Ian Campbell <[email protected]>Thanks for catching this!
Sorry for not build testing before on ARM.
No problem, some people never remember at all, so v5 isn't too bad ;-)
Quoted 2 lines
Building the hypervisor itself using a prebuilt linaro
toolchain is actually very easy (no chroot required).
Indeed.
Quoted 2 lines
Do you think it's worth documenting this? So that at least hypervisor build failures are caught.
I think it's covered by
http://wiki.xen.org/wiki/Xen_ARM_with_Virtualization_Extensions#Cross_Compiling
or do you mean something more?
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCHv6 1/3] rwlock: Add per-cpu reader-writer lock infrastructure
In reply to Malcolm CrossleyQuoted 12 lines · Malcolm Crossley
Quoted 6 lines · Ian Campbell
Quoted 3 lines · Malcolm Crossley
Changes since v5:
- Fix compilation on ARMThis was the removal of some spurious "&", I think?
Yeah, I forgot to keep the macro's in sync. ARM also needed the
xen/percpu.hheader file to be explictly included intospinlock.h.Quoted 1 line
Quoted 9 lines
Quoted 3 lines
Acked-by Ian Campbell <[email protected]>Thanks for catching this!
Sorry for not build testing before on ARM. Building the hypervisor itself using a prebuilt linaro toolchain is actually very easy (no chroot required).
Do you think it's worth documenting this? So that at least hypervisor build failures are caught.
This is already documented (briefly) here:
http://wiki.xen.org/wiki/Xen_ARM_with_Virtualization_Extensions#Cross_Compiling
Signature · 1 line
Ross Lagerwall
Re: [PATCHv6 1/3] rwlock: Add per-cpu reader-writer lock infrastructure
In reply to Ian CampbellQuoted 25 lines · Ian Campbell
Quoted 13 lines · Malcolm Crossley
Quoted 6 lines · Ian Campbell
Quoted 3 lines · Malcolm Crossley
Changes since v5:
- Fix compilation on ARMThis was the removal of some spurious "&", I think?
Yeah, I forgot to keep the macro's in sync. ARM also needed the
xen/percpu.hheader file to be
explictly included intospinlock.h.Quoted 1 line
Quoted 5 lines
Quoted 3 lines
Acked-by Ian Campbell <[email protected]>Thanks for catching this!
Sorry for not build testing before on ARM.
No problem, some people never remember at all, so v5 isn't too bad ;-)
Quoted 2 lines
Building the hypervisor itself using a prebuilt linaro
toolchain is actually very easy (no chroot required).
Quoted 7 lines
Indeed.
Quoted 2 lines
Do you think it's worth documenting this? So that at least hypervisor build failures are caught.
I think it's covered by
http://wiki.xen.org/wiki/Xen_ARM_with_Virtualization_Extensions#Cross_Compiling
Yeah that section covers it. I came across the toolstack page first and didn't check the third link down in google :)
https://www.google.co.uk/search?q=xen+cross+compilation
Maybe there should be comment in the toolstack page linking back to the simpler hypervisor only steps :)
Quoted 5 lines
or do you mean something more?
Ian.
Re: [PATCHv6 1/3] rwlock: Add per-cpu reader-writer lock infrastructure
Quoted 35 lines · Malcolm Crossley
Quoted 25 lines · Ian Campbell
Quoted 13 lines · Malcolm Crossley
Quoted 6 lines · Ian Campbell
Quoted 3 lines · Malcolm Crossley
Changes since v5:
- Fix compilation on ARMThis was the removal of some spurious "&", I think?
Yeah, I forgot to keep the macro's in sync. ARM also needed the
xen/percpu.hheader file to be
explictly included intospinlock.h.Quoted 1 line
Quoted 5 lines
Quoted 3 lines
Acked-by Ian Campbell <[email protected]>Thanks for catching this!
Sorry for not build testing before on ARM.
No problem, some people never remember at all, so v5 isn't too bad ;-)
Quoted 2 lines
Building the hypervisor itself using a prebuilt linaro toolchain is actually very easy (no chroot required).
Quoted 8 lines
Indeed.
Quoted 2 lines
Do you think it's worth documenting this? So that at least hypervisor build failures are caught.
I think it's covered by
http://wiki.xen.org/wiki/Xen_ARM_with_Virtualization_Extensions#Cross_C
ompiling
Quoted 8 lines
Yeah that section covers it. I came across the toolstack page first and didn't check the third link
down in google :)https://www.google.co.uk/search?q=xen+cross+compilation
Maybe there should be comment in the toolstack page linking back to the simpler hypervisor only steps :)
Good idea, done.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCHv6 2/3] grant_table: convert grant table rwlock to percpu rwlock
In reply to Malcolm CrossleyQuoted 14 lines
Quoted 1 line
Quoted 1 line · On 22.01.16 at 14:41, <[email protected]> wrote:
xen/common/grant_table.c +2
-0@@ -178,6 +178,8 @@ struct active_grant_entry {#define _active_entry (t, e) \ ((t)->active[(e)/ACGNT_PER_PAGE][(e)%ACGNT_PER_PAGE]) +DEFINE_PERCPU_RWLOCK_GLOBAL (grant_rwlock); +static inline void gnttab_flush_tlb (const struct domain *d) {if ( !paging_mode_external (d) )@@ -208,7 +210,13 @@ active_entry_acquire(struct grant_table *t, grant_ref_t e) {
xen/common/grant_table.c active_entry_acquire(struct grant_table *t, grant_ref_t e) · line 219
Quoted 10 lines
xen/common/grant_table.c +7
-1struct active_grant_entry *act; -ASSERT (rw_is_locked (&t->lock)); +/* +* The grant table for the active entry should be locked but the +* percpu rwlock cannot be checked for read lock without race conditions +* or high overhead so we cannot use an ASSERT +* +* ASSERT(rw_is_locked(&t->lock)); +*/
There are a number of trailing blanks being added here (and further down), which I'm fixing up as I'm in the process of applying this. The reason I noticed though is that this hunk ...
Quoted 5 lines
xen/common/grant_table.c +0
-1@@ -660,7 +668,13 @@ static int grant_map_exists(const struct domain *ld, {unsigned int ref, max_iter; -ASSERT (rw_is_locked (&rgt->lock));
xen/common/grant_table.c static int grant_map_exists(const struct domain *ld, · line 680
Quoted 10 lines
xen/common/grant_table.c +7
-0+/* +* The remote grant table should be locked but the percpu rwlock +* cannot be checked for read lock without race conditions or high +* overhead so we cannot use an ASSERT +* +* ASSERT(rw_is_locked(&rgt->lock)); +*/ max_iter =min (*ref_count + (1 <<GNTTABOP_CONTINUATION_ARG_SHIFT ),nr_grant_entries (rgt));
... doesn't apply at all due to being white space damaged (the line immediately preceding the ASSERT() which gets removed actually has four blanks on it in the source tree (which is wrong, but should nevertheless be reflected in your patch). Due to the other trailing whitespace found above I can also exclude the mail system to have eaten that white space on the way here, so I really wonder which tree this patch got created against.
Considering the hassle with the first commit attempt yesterday, may I please ask that you apply a little more care?
Thanks, Jan
Re: [PATCHv6 2/3] grant_table: convert grant table rwlock to percpu rwlock
Quoted 3 lines · Jan Beulich
There are a number of trailing blanks being added here (and further down), which I'm fixing up as I'm in the process of applying this.
Aside: Do you know about "git am --whitespace=fix" ? It automates the removal of trailing whitespace...
Ian.
Re: [PATCHv6 2/3] grant_table: convert grant table rwlock to percpu rwlock
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 22.01.16 at 16:22, <[email protected]> wrote:
Quoted 3 lines · Jan Beulich
There are a number of trailing blanks being added here (and further down), which I'm fixing up as I'm in the process of applying this.
Aside: Do you know about "git am --whitespace=fix" ? It automates the removal of trailing whitespace...
No, I didn't, but it'd be maximally useful only if I could store this as the default into ~/.gitconfig (and maybe that's possible, just that my git foo is too lame). Besides that I'm also not always using "git am", not the least because what my mail frontend saves is not always compatible with that command (leading to lost metadata).
Jan
Re: [PATCHv6 2/3] grant_table: convert grant table rwlock to percpu rwlock
Quoted 7 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 22.01.16 at 16:22, <[email protected]> wrote:
Quoted 2 lines · Jan Beulich
There are a number of trailing blanks being added here (and
further
Quoted 2 lines
Quoted 1 line
down), which I'm fixing up as I'm in the process of applying this.
Quoted 8 lines
Quoted 1 line
Aside: Do you know about "git am --whitespace=fix" ? It automates
the
Quoted 1 line
removal of trailing whitespace...
No, I didn't, but it'd be maximally useful only if I could store this as
the default into ~/.gitconfig (and maybe that's possible, just that my git foo is too lame).
It ends up being a git apply option, so it looks like
apply.whitespace = "fix"
is the answer.
I don't do that and tend to just rerun if git am complains about whitespace (which is the default) and it looks like it is worth fixing. Or is correct to fix since checked in patches have deliberate trailing whitepace on the context lines which you don't want to squash.
IME trailing whitespace in patches is actually astonishingly rare in practice.
Quoted 3 lines
Besides that I'm also not always using "git
am", not the least because what my mail frontend saves is not always compatible with that command (leading to lost metadata).
I use a sneaky trick, which is that the bug tracker will serve up raw, unadulterated messages sent to xen-devel by message-id:
curl --silent http://bugs.xenproject.org/xen/mid/<msg@id>/raw
Doesn't help if the patch didn't go to xen-devel, but most of the ones I'm interested in do.
I actually use the skanky script below which has a little bit of smarts to do series at a time if they were sent with git send-email...
git-msgid -g '1 10' '<[email protected]>' | git am
Ian.
8<------
#!/bin/bash
help()
{
echo "help!" 1>&2
}GIT=
while getopts g: OPT ; do
case $OPT in
g) GIT="$OPTARG" ;;
h) help ; exit 1 ;;
\?) exit 1 ;;
esacdone
shift $(expr $OPTIND - 1)
fetch_messages()
{
for i in $@ ; do
echo "Fetching Message ID $i" 1>&2
if [ -n "$X" ] ; then
ssh celaeno cat /srv/mldrop/xen-devel/"\"$i\""
else
#wget -O - -q http://bugs.xenproject.org/xen/mid/"$i"/raw
i=${i/\+/%2B}
curl --silent http://bugs.xenproject.org/xen/mid/"$i"/raw
fi
done
}if [ -z "$GIT" ] ; then
fetch_messages $@
else
#<[email protected]> for i in $@ ; do PATTERN=$(echo "$i" | sed -e 's/^\(<[0-9]*-[0-9]*-\)[0-9]*\(-.*>\)/\1@@NR@@\2/g') echo "GIT pattern $PATTERN" 1>&2 for n in $(seq $GIT) ; do MSG=$(echo "$PATTERN" | sed -e "s/@@NR@@/$n/") fetch_messages $MSG done done
fi