From: ira.weiny@intel.com
To: dledford@redhat.com, linux-rdma@vger.kernel.org
Cc: devel@driverdev.osuosl.org, gregkh@linuxfoundation.org,
Mitko Haralanov <mitko.haralanov@intel.com>
Subject: [RESUBMIT PATCH v2 09/14] staging/rdma/hfi1: Convert lock to mutex
Date: Mon, 11 Jan 2016 12:56:45 -0500 [thread overview]
Message-ID: <1452535010-14087-10-git-send-email-ira.weiny@intel.com> (raw)
In-Reply-To: <1452535010-14087-1-git-send-email-ira.weiny@intel.com>
From: Mitko Haralanov <mitko.haralanov@intel.com>
The exp_lock lock does not need to be a spinlock as
all its uses are in process context and allowing the
process to sleep when the mutex is contended might
be benefitial.
Signed-off-by: Mitko Haralanov <mitko.haralanov@intel.com>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
---
drivers/staging/rdma/hfi1/file_ops.c | 12 ++++++------
drivers/staging/rdma/hfi1/hfi.h | 2 +-
drivers/staging/rdma/hfi1/init.c | 2 +-
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/staging/rdma/hfi1/file_ops.c b/drivers/staging/rdma/hfi1/file_ops.c
index 76fe60315bb4..b0348263b901 100644
--- a/drivers/staging/rdma/hfi1/file_ops.c
+++ b/drivers/staging/rdma/hfi1/file_ops.c
@@ -1611,14 +1611,14 @@ static int exp_tid_setup(struct file *fp, struct hfi1_tid_info *tinfo)
* reserved, we don't need the lock anymore since we
* are guaranteed the groups.
*/
- spin_lock(&uctxt->exp_lock);
+ mutex_lock(&uctxt->exp_lock);
if (uctxt->tidusemap[useidx] == -1ULL ||
bitidx >= BITS_PER_LONG) {
/* no free groups in the set, use the next */
useidx = (useidx + 1) % uctxt->tidmapcnt;
idx++;
bitidx = 0;
- spin_unlock(&uctxt->exp_lock);
+ mutex_unlock(&uctxt->exp_lock);
continue;
}
ngroups = ((npages - mapped) / dd->rcv_entries.group_size) +
@@ -1635,13 +1635,13 @@ static int exp_tid_setup(struct file *fp, struct hfi1_tid_info *tinfo)
* as 0 because we don't check the entire bitmap but
* we start from bitidx.
*/
- spin_unlock(&uctxt->exp_lock);
+ mutex_unlock(&uctxt->exp_lock);
continue;
}
bits_used = min(free, ngroups);
tidmap[useidx] |= ((1ULL << bits_used) - 1) << bitidx;
uctxt->tidusemap[useidx] |= tidmap[useidx];
- spin_unlock(&uctxt->exp_lock);
+ mutex_unlock(&uctxt->exp_lock);
/*
* At this point, we know where in the map we have free bits.
@@ -1677,10 +1677,10 @@ static int exp_tid_setup(struct file *fp, struct hfi1_tid_info *tinfo)
* Let go of the bits that we reserved since we are not
* going to use them.
*/
- spin_lock(&uctxt->exp_lock);
+ mutex_lock(&uctxt->exp_lock);
uctxt->tidusemap[useidx] &=
~(((1ULL << bits_used) - 1) << bitidx);
- spin_unlock(&uctxt->exp_lock);
+ mutex_unlock(&uctxt->exp_lock);
goto done;
}
/*
diff --git a/drivers/staging/rdma/hfi1/hfi.h b/drivers/staging/rdma/hfi1/hfi.h
index 905bb40febb3..9052331ff6c5 100644
--- a/drivers/staging/rdma/hfi1/hfi.h
+++ b/drivers/staging/rdma/hfi1/hfi.h
@@ -258,7 +258,7 @@ struct hfi1_ctxtdata {
struct exp_tid_set tid_full_list;
/* lock protecting all Expected TID data */
- spinlock_t exp_lock;
+ struct mutex exp_lock;
/* number of pio bufs for this ctxt (all procs, if shared) */
u32 piocnt;
/* first pio buffer for this ctxt */
diff --git a/drivers/staging/rdma/hfi1/init.c b/drivers/staging/rdma/hfi1/init.c
index db80544deb66..ee63fe977ad4 100644
--- a/drivers/staging/rdma/hfi1/init.c
+++ b/drivers/staging/rdma/hfi1/init.c
@@ -227,7 +227,7 @@ struct hfi1_ctxtdata *hfi1_create_ctxtdata(struct hfi1_pportdata *ppd, u32 ctxt)
rcd->numa_id = numa_node_id();
rcd->rcv_array_groups = dd->rcv_entries.ngroups;
- spin_lock_init(&rcd->exp_lock);
+ mutex_init(&rcd->exp_lock);
/*
* Calculate the context's RcvArray entry starting point.
--
1.8.2
next prev parent reply other threads:[~2016-01-11 17:56 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-11 17:56 From: Ira Weiny <ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> ira.weiny-ral2JQCrhuEAvxtiuMwx3w
2016-01-11 17:56 ` [RESUBMIT PATCH v2 01/14] staging/rdma/hfi1: Add function stubs for TID caching ira.weiny
2016-01-11 17:56 ` [RESUBMIT PATCH v2 02/14] uapi/rdma/hfi/hfi1_user.h: Correct comment for capability bit ira.weiny
2016-01-11 17:56 ` [RESUBMIT PATCH v2 03/14] uapi/rdma/hfi/hfi1_user.h: Convert definitions to use BIT() macro ira.weiny
2016-01-11 17:56 ` [RESUBMIT PATCH v2 04/14] uapi/rdma/hfi/hfi1_user.h: Add command and event for TID caching ira.weiny
2016-01-11 17:56 ` [RESUBMIT PATCH v2 07/14] staging/rdma/hfi1: Add definitions and support functions for TID groups ira.weiny
2016-01-11 17:56 ` ira.weiny [this message]
2016-01-11 17:56 ` [RESUBMIT PATCH v2 10/14] staging/rdma/hfi1: Add Expected receive init and free functions ira.weiny
2016-01-11 17:56 ` [RESUBMIT PATCH v2 11/14] staging/rdma/hfi1: Add MMU notifier callback function ira.weiny
[not found] ` <1452535010-14087-1-git-send-email-ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2016-01-11 17:56 ` [RESUBMIT PATCH v2 05/14] staging/rdma/hfi1: Add definitions needed for TID caching support ira.weiny-ral2JQCrhuEAvxtiuMwx3w
2016-01-11 17:56 ` [RESUBMIT PATCH v2 06/14] staging/rdma/hfi1: Remove un-needed variable ira.weiny-ral2JQCrhuEAvxtiuMwx3w
2016-01-11 17:56 ` [RESUBMIT PATCH v2 08/14] staging/rdma/hfi1: Start adding building blocks for TID caching ira.weiny-ral2JQCrhuEAvxtiuMwx3w
2016-01-11 17:56 ` [RESUBMIT PATCH v2 12/14] staging/rdma/hfi1: Add TID free/clear function bodies ira.weiny-ral2JQCrhuEAvxtiuMwx3w
2016-01-11 17:56 ` [RESUBMIT PATCH v2 13/14] staging/rdma/hfi1: Add TID entry program function body ira.weiny-ral2JQCrhuEAvxtiuMwx3w
2016-01-11 17:56 ` [RESUBMIT PATCH v2 14/14] staging/rdma/hfi1: Enable TID caching feature ira.weiny-ral2JQCrhuEAvxtiuMwx3w
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1452535010-14087-10-git-send-email-ira.weiny@intel.com \
--to=ira.weiny@intel.com \
--cc=devel@driverdev.osuosl.org \
--cc=dledford@redhat.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-rdma@vger.kernel.org \
--cc=mitko.haralanov@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).