Move the comment from utrace_task_alloc() to utrace_add_engine()
and try to make it a bit more clear.

Signed-off-by: Oleg Nesterov <o...@redhat.com>
---

 include/linux/utrace.h |    4 ++--
 kernel/utrace.c        |   11 +++++------
 2 files changed, 7 insertions(+), 8 deletions(-)

--- UTRACE-PTRACE/include/linux/utrace.h~4_ADD_ENGINE_DOCUMENT_IMPLICIT_MB      
2009-11-21 15:12:27.000000000 +0100
+++ UTRACE-PTRACE/include/linux/utrace.h        2009-12-12 17:42:16.000000000 
+0100
@@ -164,8 +164,8 @@ static inline struct utrace *task_utrace
         * is ordered before this load of task->utrace.  We use those
         * utrace_flags checks in the hot path to decide to call into
         * the utrace code.  The first attach installs task->utrace before
-        * setting task->utrace_flags nonzero, with a barrier between.
-        * See utrace_task_alloc().
+        * setting task->utrace_flags nonzero with implicit barrier in
+        * between, see utrace_add_engine().
         */
        smp_rmb();
        utrace = task->utrace;
--- UTRACE-PTRACE/kernel/utrace.c~4_ADD_ENGINE_DOCUMENT_IMPLICIT_MB     
2009-12-12 16:49:26.000000000 +0100
+++ UTRACE-PTRACE/kernel/utrace.c       2009-12-12 17:46:55.000000000 +0100
@@ -107,11 +107,7 @@ static bool utrace_task_alloc(struct tas
                task->utrace = utrace;
        }
        task_unlock(task);
-       /*
-        * That unlock after storing task->utrace acts as a memory barrier
-        * ordering any subsequent task->utrace_flags store afterwards.
-        * This pairs with smp_rmb() in task_utrace_struct().
-        */
+
        if (unlikely(task->utrace != utrace))
                kmem_cache_free(utrace_cachep, utrace);
        return true;
@@ -221,7 +217,10 @@ static int utrace_add_engine(struct task
 
        /*
         * In case we had no engines before, make sure that
-        * utrace_flags is not zero.
+        * utrace_flags is not zero. Since we did unlock+lock
+        * at least once after utrace_task_alloc() installed
+        * ->utrace, we have the necessary barrier which pairs
+        * with rmb() in task_utrace_struct().
         */
        ret = -ESRCH;
        if (!target->utrace_flags) {

Reply via email to