From patchwork Fri Apr 19 18:05:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hefty, Sean" X-Patchwork-Id: 10909607 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3D31C1515 for ; Fri, 19 Apr 2019 19:10:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 31D9E28DFA for ; Fri, 19 Apr 2019 19:10:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 261BC28DFC; Fri, 19 Apr 2019 19:10:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C482528DFA for ; Fri, 19 Apr 2019 19:10:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726683AbfDSTK5 convert rfc822-to-8bit (ORCPT ); Fri, 19 Apr 2019 15:10:57 -0400 Received: from mga01.intel.com ([192.55.52.88]:16195 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729340AbfDSTKq (ORCPT ); Fri, 19 Apr 2019 15:10:46 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Apr 2019 11:05:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,370,1549958400"; d="scan'208";a="225001286" Received: from orsmsx102.amr.corp.intel.com ([10.22.225.129]) by orsmga001.jf.intel.com with ESMTP; 19 Apr 2019 11:05:44 -0700 Received: from orsmsx109.amr.corp.intel.com ([169.254.11.52]) by ORSMSX102.amr.corp.intel.com ([169.254.3.144]) with mapi id 14.03.0415.000; Fri, 19 Apr 2019 11:05:44 -0700 From: "Hefty, Sean" To: "linux-rdma (linux-rdma@vger.kernel.org)" Subject: [PATCH rdma-core 3/5] rsockets: Add locks around CM state processing Thread-Topic: [PATCH rdma-core 3/5] rsockets: Add locks around CM state processing Thread-Index: AdT22fCt3R0dJLoEQCm6sIIvNw3U4w== Date: Fri, 19 Apr 2019 18:05:44 +0000 Message-ID: <1828884A29C6694DAF28B7E6B8A82373B3E1F90E@ORSMSX109.amr.corp.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiODljMTFjOWItNzI5Ni00ZjYwLWE2YTUtZjVjNzk1MTExNWVjIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiWDNpM2M1NHBnS0IyYWMzcU5HY0JiWDdaTGptdjlkdjVIaWNXZUNhc0FoZXZPdllBa3JnNVFZNGhsSU5TTnVIcyJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.600.7 dlp-reaction: no-action x-originating-ip: [10.22.254.139] MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In rs_do_connect(), we drive the connection state of an rsocket. Because applications may call rpoll() from multiple thread, it's possible for multiple threads to try driving the rsocket connection state. Use the rsocket slock to serialize their access. Signed-off-by: Sean Hefty --- librdmacm/rsocket.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/librdmacm/rsocket.c b/librdmacm/rsocket.c index cee3bd01..9ac881bc 100644 --- a/librdmacm/rsocket.c +++ b/librdmacm/rsocket.c @@ -1327,6 +1327,7 @@ static int rs_do_connect(struct rsocket *rs) struct rs_conn_data *creq, *cresp; int to, ret; + fastlock_acquire(&rs->slock); switch (rs->state) { case rs_init: case rs_bound: @@ -1437,6 +1438,7 @@ connected: rs->err = errno; } } + fastlock_release(&rs->slock); return ret; }