Received: by 2002:a4a:311b:0:0:0:0:0 with SMTP id k27-v6csp4870356ooa; Tue, 14 Aug 2018 11:43:31 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzgK+0gD9BV1HvdEFQVGjzPqp7NY6l+UimCFMr+k7glEn68YDXuoNvfWDtFR9LcZtGZR/q3 X-Received: by 2002:a65:62d8:: with SMTP id m24-v6mr22461878pgv.307.1534272211524; Tue, 14 Aug 2018 11:43:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534272211; cv=none; d=google.com; s=arc-20160816; b=rx/2ehLE/BOq70vveFPkhphSjrGy3C7P//gHBSJR2SyQGZJcxw2gaV0TJsohpkXc1q fGXOfkHdtedZ/U+iAwUMPtwiG6hy/CK6YyAeMx72vhyDdGM4ILy/f6+5gPM2kZ303GKS G/bgNEyUYNScLiaXZlGPrLiE/imw8TWxla6UuZhLKj8Ad7LxW9L68Wjb0eY58jnGOlOC bVQRgrNFr1863q5jHzbpDj/D7nxyzf9Kx+Fbe0nH+PT/nWXpWRuJE/l61z2+R1FWuF4W uY0ZQsK1sU7+Se1ov6N5roB3OEJj1wJMOHTeiJwrabnMY7JiAFX7cDF7U9JKrjkjMq46 vjtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=MVYOOQhCYGhADvrRLTuMaT3SEBV+1nDnJZy3VDfId3o=; b=UVeVTQaMHiXmzKyg4D+Zrw3dRYqUbNkwPveolMV6E8YDFS1PLad2MOlqrCH8G7aoGg pTrInDYhRsFuK7PPnzz4F/LDuBu9BFL3nFf0Wiw4Qu6Y3/2y9a9kwxZgpVFsNlZo0j24 cK7b+nWT2RYIJJOsY6cKFwzhKLOvQovvom1oOfT1pUbmSar8OPC7O950syeYQnPsafMr Ulygti7qp5VzVTW7HTkIIfsgKAp3cfmkmCKUz4bzmQgWYxeh+au4Qt0nKw21nhfkTeK+ h0cevZtjhx24kr2cADT4X13kB3dPkXW1F5GSt+sxJSyGOGNpiCjBlb7q4+Fd+wFwqdSJ DteQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=F8PTgheU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g15-v6si17034579plo.284.2018.08.14.11.43.17; Tue, 14 Aug 2018 11:43:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=F8PTgheU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728459AbeHNVaV (ORCPT + 99 others); Tue, 14 Aug 2018 17:30:21 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:40434 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728146AbeHNVaV (ORCPT ); Tue, 14 Aug 2018 17:30:21 -0400 Received: by mail-wm0-f68.google.com with SMTP id y9-v6so13230475wma.5 for ; Tue, 14 Aug 2018 11:41:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id; bh=MVYOOQhCYGhADvrRLTuMaT3SEBV+1nDnJZy3VDfId3o=; b=F8PTgheUuJh466LRAf9XlS8cQjrmuzkKd0zbAqLOAnrDcdsTvOwCKZ3U/44ma3Yvnx 8OQfRCgECIaOxAOJARzvrrv7dOoPxX7IDE4d54YjTxvNnyFjKgAcnRwo0o/FzN/CRuU6 /P8ucAnvXCg+VhnfLsvMIP2MgVaft3u9FI7kw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=MVYOOQhCYGhADvrRLTuMaT3SEBV+1nDnJZy3VDfId3o=; b=tgjUjUT9gMR7b2zEs3hFbehDN3TaXpESWDJ7FPGPGmHfCa5fKY6OuBVn7+L8TNchGX dy5pbQj1EQLDRh/igExcyZnkVLfDBs4HPrKBrzy0ixbm9nqPYzPm/T0dIwd+I8KfO1Qk BxLVtQ0udRb+f5P7sh1piMBC63Vov97hls7DkTG+q6JndQmAo1Znsz/Ud11vU7yTIxzZ X40rixfutQCEt9qeMin0p14DV0nb5Y70KgmpaPxNhNphk+u5zGVLh7DhWXII+kj+nnoy xf8ZK5nbR28GCg3wGl7EKlwgoM5rdYM9Ujn9zOjnGSa1TKYH2dQGvH+5+n0IUwNkwAhF jEFQ== X-Gm-Message-State: AOUpUlF3mvULi/46qqUKP1sixrTIzSxZC6Hq9J50/DiOs1E9zCzAx0WR lAjZEKlojpxtQ3xzdvaZ3Ge8sQ== X-Received: by 2002:a1c:3545:: with SMTP id c66-v6mr11879236wma.120.1534272109898; Tue, 14 Aug 2018 11:41:49 -0700 (PDT) Received: from localhost.localdomain (host47-68-dynamic.36-79-r.retail.telecomitalia.it. [79.36.68.47]) by smtp.gmail.com with ESMTPSA id a9-v6sm26042610wrp.55.2018.08.14.11.41.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 14 Aug 2018 11:41:49 -0700 (PDT) From: Andrea Parri To: Marcel Holtmann , Johan Hedberg , "David S . Miller" Cc: linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jeffy Chen , Brian Norris , AL Yu-Chen Cho , Andrea Parri Subject: [PATCH] bluetooth/{bnep,cmtp,hidp}: Remove unnecessary smp_mb__{before,after}_atomic Date: Tue, 14 Aug 2018 20:41:06 +0200 Message-Id: <1534272066-9366-1-git-send-email-andrea.parri@amarulasolutions.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The barriers are unneeded; wait_woken() and woken_wake_function() already provide us with the required synchronization: remove them and document that we're relying on the (implicit) synchronization provided by wait_woken() and woken_wake_function(). Signed-off-by: Andrea Parri --- net/bluetooth/bnep/core.c | 7 ++++--- net/bluetooth/cmtp/core.c | 14 ++++++++------ net/bluetooth/hidp/core.c | 13 ++++++++----- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/net/bluetooth/bnep/core.c b/net/bluetooth/bnep/core.c index 7b3965861013c..43c284158f63e 100644 --- a/net/bluetooth/bnep/core.c +++ b/net/bluetooth/bnep/core.c @@ -489,9 +489,6 @@ static int bnep_session(void *arg) add_wait_queue(sk_sleep(sk), &wait); while (1) { - /* Ensure session->terminate is updated */ - smp_mb__before_atomic(); - if (atomic_read(&s->terminate)) break; /* RX */ @@ -512,6 +509,10 @@ static int bnep_session(void *arg) break; netif_wake_queue(dev); + /* + * wait_woken() performs the necessary memory barriers + * for us; see the header comment for this primitive. + */ wait_woken(&wait, TASK_INTERRUPTIBLE, MAX_SCHEDULE_TIMEOUT); } remove_wait_queue(sk_sleep(sk), &wait); diff --git a/net/bluetooth/cmtp/core.c b/net/bluetooth/cmtp/core.c index 7f26a5a19ff6d..07cfa3249f83a 100644 --- a/net/bluetooth/cmtp/core.c +++ b/net/bluetooth/cmtp/core.c @@ -288,9 +288,6 @@ static int cmtp_session(void *arg) add_wait_queue(sk_sleep(sk), &wait); while (1) { - /* Ensure session->terminate is updated */ - smp_mb__before_atomic(); - if (atomic_read(&session->terminate)) break; if (sk->sk_state != BT_CONNECTED) @@ -306,6 +303,10 @@ static int cmtp_session(void *arg) cmtp_process_transmit(session); + /* + * wait_woken() performs the necessary memory barriers + * for us; see the header comment for this primitive. + */ wait_woken(&wait, TASK_INTERRUPTIBLE, MAX_SCHEDULE_TIMEOUT); } remove_wait_queue(sk_sleep(sk), &wait); @@ -431,9 +432,10 @@ int cmtp_del_connection(struct cmtp_conndel_req *req) /* Stop session thread */ atomic_inc(&session->terminate); - /* Ensure session->terminate is updated */ - smp_mb__after_atomic(); - + /* + * See the comment preceding the call to wait_woken() + * in cmtp_session(). + */ wake_up_interruptible(sk_sleep(session->sock->sk)); } else err = -ENOENT; diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c index 1036e4fa1ea28..e621551712f59 100644 --- a/net/bluetooth/hidp/core.c +++ b/net/bluetooth/hidp/core.c @@ -1074,6 +1074,10 @@ static int hidp_session_start_sync(struct hidp_session *session) static void hidp_session_terminate(struct hidp_session *session) { atomic_inc(&session->terminate); + /* + * See the comment preceding the call to wait_woken() + * in hidp_session_run(). + */ wake_up_interruptible(&hidp_session_wq); } @@ -1193,8 +1197,6 @@ static void hidp_session_run(struct hidp_session *session) * thread is woken up by ->sk_state_changed(). */ - /* Ensure session->terminate is updated */ - smp_mb__before_atomic(); if (atomic_read(&session->terminate)) break; @@ -1228,14 +1230,15 @@ static void hidp_session_run(struct hidp_session *session) hidp_process_transmit(session, &session->ctrl_transmit, session->ctrl_sock); + /* + * wait_woken() performs the necessary memory barriers + * for us; see the header comment for this primitive. + */ wait_woken(&wait, TASK_INTERRUPTIBLE, MAX_SCHEDULE_TIMEOUT); } remove_wait_queue(&hidp_session_wq, &wait); atomic_inc(&session->terminate); - - /* Ensure session->terminate is updated */ - smp_mb__after_atomic(); } static int hidp_session_wake_function(wait_queue_entry_t *wait, -- 2.7.4