The commit is pushed to "branch-rh7-3.10.0-1160.36.2.vz7.182.x-ovz" and will 
appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1160.36.2.vz7.182.1
------>
commit 54b4ddbd65f89be6a31c08e2add004d27c79ceed
Author: Kirill Tkhai <[email protected]>
Date:   Tue Aug 24 14:39:48 2021 +0300

    ploop: Check disable_merge only if there is a delta with such method
    
    There is high spinlock contention on NVME in this place.
    But really, we should try this optimization only if it's
    there is a delta, which provides such method. Kaio does
    not provide it, so here is just spinlock taking wasting.
    
    Signed-off-by: Kirill Tkhai <[email protected]>
---
 drivers/block/ploop/dev.c | 31 ++++++++++++++++++++-----------
 1 file changed, 20 insertions(+), 11 deletions(-)

diff --git a/drivers/block/ploop/dev.c b/drivers/block/ploop/dev.c
index c4cb944..9abce6a 100644
--- a/drivers/block/ploop/dev.c
+++ b/drivers/block/ploop/dev.c
@@ -1248,18 +1248,27 @@ ploop_merge_bvec(struct request_queue *q, struct 
bvec_merge_data *bm_data,
                return 0;
        }
 
-       /* We can return ret right now, the further action is an optimization
-        * to prevent splitting overhead and to enable fast path.
-        */
-       spin_lock_irqsave(&plo->lock, flags);
-       delta = ploop_fast_lookup(plo, sec, 0, &isector);
-       if (delta &&
-           delta->io.ops->disable_merge &&
-           delta->io.ops->disable_merge(&delta->io, isector, len)) {
-               plo->st.merge_neg_disable++;
-               ret = 0;
+       if (plo->has_disable_merge) {
+               /*
+                * We can return ret right now, the further action
+                * is an optimization to prevent splitting overhead
+                * and to enable fast path.
+                * We do that only in case of there is a delta
+                * with disable_merge method: otherwise this just
+                * brings spinlock taking overhead (seen on NVME).
+                * Since below is only optimization, we check
+                * plo->has_disable_merge without any synchronization.
+                */
+               spin_lock_irqsave(&plo->lock, flags);
+               delta = ploop_fast_lookup(plo, sec, 0, &isector);
+               if (delta &&
+                   delta->io.ops->disable_merge &&
+                   delta->io.ops->disable_merge(&delta->io, isector, len)) {
+                       plo->st.merge_neg_disable++;
+                       ret = 0;
+               }
+               spin_unlock_irqrestore(&plo->lock, flags);
        }
-       spin_unlock_irqrestore(&plo->lock, flags);
 
        /* If no mapping is available, merge up to cluster boundary */
        return ret;
_______________________________________________
Devel mailing list
[email protected]
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to