From: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>
To: Binoy Jayan <binoy.jayan-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Cc: Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
Hal Rosenstock
<hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH v2 6/8] IB/hns: Replace counting semaphore event_sem with wait_event
Date: Tue, 25 Oct 2016 14:28:57 +0200 [thread overview]
Message-ID: <5375848.bxLv0aDzDv@wuerfel> (raw)
In-Reply-To: <1477396919-27669-7-git-send-email-binoy.jayan-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
On Tuesday, October 25, 2016 5:31:57 PM CEST Binoy Jayan wrote:
> static int __hns_roce_cmd_mbox_wait(struct hns_roce_dev *hr_dev, u64 in_param,
> u64 out_param, unsigned long in_modifier,
> @@ -198,11 +218,12 @@ static int __hns_roce_cmd_mbox_wait(struct hns_roce_dev *hr_dev, u64 in_param,
> struct hns_roce_cmdq *cmd = &hr_dev->cmd;
> struct device *dev = &hr_dev->pdev->dev;
> struct hns_roce_cmd_context *context;
> - int ret = 0;
> + int orig_free_head, ret = 0;
> +
> + wait_event(cmd->wq, (orig_free_head = atomic_free_node(cmd, -1)) != -1);
>
> spin_lock(&cmd->context_lock);
> - WARN_ON(cmd->free_head < 0);
> - context = &cmd->context[cmd->free_head];
> + context = &cmd->context[orig_free_head];
> context->token += cmd->token_mask + 1;
> cmd->free_head = context->next;
> spin_unlock(&cmd->context_lock);
>
You get the lock in atomic_free_node() and then again right after that.
Why not combine the two and only take the lock inside of that
function that returns a context?
Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2016-10-25 12:28 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-25 12:01 [PATCH v2 0/8] infiniband: Remove semaphores Binoy Jayan
2016-10-25 12:01 ` [PATCH v2 3/8] IB/hns: Replace semaphore poll_sem with mutex Binoy Jayan
2016-10-25 12:01 ` [PATCH v2 4/8] IB/mthca: " Binoy Jayan
2016-10-25 12:01 ` [PATCH v2 5/8] IB/isert: Replace semaphore sem with completion Binoy Jayan
2016-10-25 12:01 ` [PATCH v2 6/8] IB/hns: Replace counting semaphore event_sem with wait_event Binoy Jayan
[not found] ` <1477396919-27669-7-git-send-email-binoy.jayan-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2016-10-25 12:28 ` Arnd Bergmann [this message]
2016-10-25 12:59 ` Binoy Jayan
2016-10-25 13:21 ` Arnd Bergmann
2016-10-25 13:35 ` Binoy Jayan
[not found] ` <1477396919-27669-1-git-send-email-binoy.jayan-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2016-10-25 12:01 ` [PATCH v2 1/8] IB/core: iwpm_nlmsg_request: Replace semaphore with completion Binoy Jayan
2016-10-25 12:01 ` [PATCH v2 2/8] IB/core: Replace semaphore sm_sem " Binoy Jayan
2016-10-25 12:43 ` Jack Wang
2016-10-25 15:08 ` Binoy Jayan
[not found] ` <CAHv-k_86z3MTYePPQcs5fWSqFeoGxt7UYG_b-SyZGQ7zVW-hSw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-10-25 15:48 ` Jack Wang
2016-10-25 15:48 ` Jason Gunthorpe
[not found] ` <20161025154822.GA27240-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2016-10-25 20:15 ` Arnd Bergmann
2016-10-25 12:01 ` [PATCH v2 7/8] IB/mthca: Replace counting semaphore event_sem with wait_event Binoy Jayan
2016-10-25 12:01 ` [PATCH v2 8/8] IB/mlx5: Add helper mlx5_ib_post_send_wait Binoy Jayan
2016-10-25 12:23 ` Arnd Bergmann
2016-10-25 12:46 ` Binoy Jayan
2016-10-25 12:26 ` Leon Romanovsky
2016-10-25 13:16 ` Binoy Jayan
2016-10-27 6:05 ` Leon Romanovsky
2016-10-27 6:23 ` Binoy Jayan
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=5375848.bxLv0aDzDv@wuerfel \
--to=arnd-r2ngtmty4d4@public.gmane.org \
--cc=binoy.jayan-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
/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