From: David Herrmann Date: Mon, 20 Oct 2014 13:41:49 +0000 (+0200) Subject: connection: make attach_flags atomic X-Git-Tag: upstream/0.20141102.012929utc~76 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=812a945ecb8a7a1aaea94cd01a6d78865755b6b1;p=platform%2Fcore%2Fsystem%2Fkdbus-bus.git connection: make attach_flags atomic Instead of requiring connection locks, make conn->attach_flags a 64bit atomic. This isn't particularly fast on archs that don't optimize atomic64, but it simplifies the locking in kdbus. Requiring the connection lock is just annoying. Furthermore, most 'real' archs should provide 64bit atomics, anyway. Signed-off-by: David Herrmann --- diff --git a/connection.c b/connection.c index 8210d1d..6093c13 100644 --- a/connection.c +++ b/connection.c @@ -549,9 +549,7 @@ static int kdbus_kmsg_attach_metadata(struct kdbus_kmsg *kmsg, * conn_src->owner_meta, and we only attach the connection's name and * currently owned names on top of that. */ - mutex_lock(&conn_dst->lock); - attach_flags = conn_dst->attach_flags; - mutex_unlock(&conn_dst->lock); + attach_flags = atomic64_read(&conn_dst->attach_flags); if (conn_src->owner_meta) attach_flags &= KDBUS_ATTACH_NAMES | KDBUS_ATTACH_CONN_NAME; @@ -1372,11 +1370,8 @@ int kdbus_cmd_conn_update(struct kdbus_conn *conn, return ret; } - if (flags_provided) { - mutex_lock(&conn->lock); - conn->attach_flags = attach_flags; - mutex_unlock(&conn->lock); - } + if (flags_provided) + atomic64_set(&conn->attach_flags, attach_flags); return 0; } @@ -1545,7 +1540,7 @@ int kdbus_conn_new(struct kdbus_ep *ep, memcpy(hello->id128, bus->id128, sizeof(hello->id128)); conn->flags = hello->conn_flags; - conn->attach_flags = hello->attach_flags; + atomic64_set(&conn->attach_flags, hello->attach_flags); if (is_activator) { u64 flags = KDBUS_NAME_ACTIVATOR; diff --git a/connection.h b/connection.h index 6a9c557..4fdf334 100644 --- a/connection.h +++ b/connection.h @@ -15,6 +15,7 @@ #ifndef __KDBUS_CONNECTION_H #define __KDBUS_CONNECTION_H +#include #include #include "limits.h" #include "metadata.h" @@ -72,7 +73,7 @@ struct kdbus_conn { #endif u64 id; u64 flags; - u64 attach_flags; + atomic64_t attach_flags; const char *name; struct kdbus_bus *bus; struct kdbus_ep *ep;