this_cpu_ptr() should be used under local_lock() (or task migration
should be disabled instead), so switch the order.

Fixes: 0e60020d2a ("proc connector: take number of listeners and per-cpu
conters from VE")

Signed-off-by: Konstantin Khorenko <[email protected]>

--
v2:
 * instead of prohibiting migration of the task to another cpu let's
   just put this_cpu_ptr() after local_lock().
 * fix double this_cpu_ptr() (local_lock() contains the second one)
---
 drivers/connector/cn_proc.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/connector/cn_proc.c b/drivers/connector/cn_proc.c
index 9b63792f0dff..c2d021f9b19b 100644
--- a/drivers/connector/cn_proc.c
+++ b/drivers/connector/cn_proc.c
@@ -63,9 +63,15 @@ static inline void send_msg_ve(struct ve_struct *ve, struct 
cn_msg *msg)
 {
        struct local_event *le_ptr;
 
-       le_ptr = this_cpu_ptr(ve->cn->local_event);
-       local_lock(&le_ptr->lock);
+       /*
+        * The following hack with local_event->lock address works only
+        * till the "lock" is the first field in the local_event struct,
+        * so be of the safe side.
+        */
+       BUILD_BUG_ON(offsetof(struct local_event, lock) != 0);
+       local_lock(&ve->cn->local_event->lock);
 
+       le_ptr = this_cpu_ptr(ve->cn->local_event);
        msg->seq = le_ptr->count++;
        ((struct proc_event *)msg->data)->cpu = smp_processor_id();
 
-- 
2.28.0

_______________________________________________
Devel mailing list
[email protected]
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to