Cleanup: no need to hold RCU read-side lock when reading current nsproxy
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 27 Aug 2012 13:46:48 +0000 (09:46 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 27 Aug 2012 13:46:48 +0000 (09:46 -0400)
As documented in include/linux/nsproxy.h.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
lttng-context-hostname.c
lttng-events.c

index e38340b72ec7bf53f8272ddacac5cf7434212498..6dc14f9c1cfef5930059172d21ed0ed0fa6f61e0 100644 (file)
@@ -49,8 +49,11 @@ void hostname_record(struct lttng_ctx_field *field,
        struct uts_namespace *ns;
        char *hostname;
 
-       rcu_read_lock();
-       nsproxy = task_nsproxy(current);
+       /*
+        * No need to take the RCU read-side lock to read current
+        * nsproxy. (documented in nsproxy.h)
+        */
+       nsproxy = current->nsproxy;
        if (nsproxy) {
                ns = nsproxy->uts_ns;
                hostname = ns->name.nodename;
@@ -60,7 +63,6 @@ void hostname_record(struct lttng_ctx_field *field,
                chan->ops->event_memset(ctx, 0,
                                LTTNG_HOSTNAME_CTX_LEN);
        }
-       rcu_read_unlock();
 }
 
 int lttng_add_hostname_to_ctx(struct lttng_ctx **ctx)
index 7a1be7295a7ef33d1e61f692d9a2926c0ed03d77..220178f71c96e565d64122e12fa856344e542b17 100644 (file)
@@ -903,7 +903,6 @@ int _lttng_session_metadata_statedump(struct lttng_session *session)
        unsigned char uuid_s[37], clock_uuid_s[BOOT_ID_LEN];
        struct lttng_channel *chan;
        struct lttng_event *event;
-       char hostname[__NEW_UTS_LEN + 1];
        int ret = 0;
 
        if (!ACCESS_ONCE(session->active))
@@ -960,11 +959,6 @@ int _lttng_session_metadata_statedump(struct lttng_session *session)
        if (ret)
                goto end;
 
-       rcu_read_lock();
-       memcpy(hostname, task_nsproxy(current)->uts_ns->name.nodename,
-               sizeof(hostname));
-       rcu_read_unlock();
-
        ret = lttng_metadata_printf(session,
                "env {\n"
                "       hostname = \"%s\";\n"
@@ -977,7 +971,7 @@ int _lttng_session_metadata_statedump(struct lttng_session *session)
                "       tracer_minor = %d;\n"
                "       tracer_patchlevel = %d;\n"
                "};\n\n",
-               hostname,
+               current->nsproxy->uts_ns->name.nodename,
                utsname()->sysname,
                utsname()->release,
                utsname()->version,
This page took 0.026906 seconds and 4 git commands to generate.