From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755024AbbHFIWF (ORCPT ); Thu, 6 Aug 2015 04:22:05 -0400 Received: from mail-wi0-f172.google.com ([209.85.212.172]:38225 "EHLO mail-wi0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754860AbbHFIV7 (ORCPT ); Thu, 6 Aug 2015 04:21:59 -0400 From: David Herrmann To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , Daniel Mack , Djalal Harouni , David Herrmann Subject: [PATCH 3/9] kdbus: use separate counter for message IDs Date: Thu, 6 Aug 2015 10:21:22 +0200 Message-Id: <1438849288-18112-4-git-send-email-dh.herrmann@gmail.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1438849288-18112-1-git-send-email-dh.herrmann@gmail.com> References: <1438849288-18112-1-git-send-email-dh.herrmann@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For each kdbus domain, we maintain an ID-counter to guarantee unique IDs across all objects. We also used to use it for message IDs. However, this requires touching a shared cacheline on each message transaction, even though we never guaranteed global ordering across buses, anyway. Introduce a separate counter which is used solely for message IDs. Semantics stay the same, but it no longer relates to IDs across buses. Reviewed-by: Daniel Mack Signed-off-by: David Herrmann --- ipc/kdbus/bus.h | 2 ++ ipc/kdbus/message.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ipc/kdbus/bus.h b/ipc/kdbus/bus.h index 238986e..8c2acae 100644 --- a/ipc/kdbus/bus.h +++ b/ipc/kdbus/bus.h @@ -44,6 +44,7 @@ struct kdbus_user; * @domain: Domain of this bus * @creator: Creator of the bus * @creator_meta: Meta information about the bus creator + * @last_message_id: Last used message id * @policy_db: Policy database for this bus * @name_registry: Name registry of this bus * @conn_rwlock: Read/Write lock for all lists of child connections @@ -67,6 +68,7 @@ struct kdbus_bus { struct kdbus_meta_proc *creator_meta; /* protected by own locks */ + atomic64_t last_message_id; struct kdbus_policy_db policy_db; struct kdbus_name_registry *name_registry; diff --git a/ipc/kdbus/message.c b/ipc/kdbus/message.c index 432dba4..ae565cd 100644 --- a/ipc/kdbus/message.c +++ b/ipc/kdbus/message.c @@ -671,7 +671,7 @@ static struct kdbus_staging *kdbus_staging_new(struct kdbus_bus *bus, if (!staging) return ERR_PTR(-ENOMEM); - staging->msg_seqnum = atomic64_inc_return(&bus->domain->last_id); + staging->msg_seqnum = atomic64_inc_return(&bus->last_message_id); staging->n_parts = 0; /* we reserve n_parts, but don't enforce them */ staging->parts = (void *)(staging + 1); -- 2.5.0