From: Bart Van Assche <Bart.VanAssche-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
To: "jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org"
<jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
Cc: "linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org"
<sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Subject: Re: [PATCH rdma-core 4/6] rdmacm: Use C11 stdatomic for all atomics
Date: Thu, 16 Mar 2017 01:04:49 +0000 [thread overview]
Message-ID: <1489626275.3542.1.camel@sandisk.com> (raw)
In-Reply-To: <20170315231837.GA23082-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 2098 bytes --]
On Wed, 2017-03-15 at 17:18 -0600, Jason Gunthorpe wrote:
> Indeed, you are right, I will sqush in this patch, thanks
>
> diff --git a/librdmacm/cma.h b/librdmacm/cma.h
> index 645d1e43576279..2f5f86cf498918 100644
> --- a/librdmacm/cma.h
> +++ b/librdmacm/cma.h
> @@ -69,12 +69,12 @@ static inline void fastlock_destroy(fastlock_t *lock)
> }
> static inline void fastlock_acquire(fastlock_t *lock)
> {
> - if (atomic_fetch_add(&lock->cnt, 1) > 1)
> + if (atomic_fetch_add(&lock->cnt, 1) > 0)
> sem_wait(&lock->sem);
> }
> static inline void fastlock_release(fastlock_t *lock)
> {
> - if (atomic_fetch_sub(&lock->cnt, 1) > 0)
> + if (atomic_fetch_sub(&lock->cnt, 1) > 1)
> sem_post(&lock->sem);
> }
>
> diff --git a/librdmacm/preload.c b/librdmacm/preload.c
> index bd1bcb1d701015..82cb0c03850b05 100644
> --- a/librdmacm/preload.c
> +++ b/librdmacm/preload.c
> @@ -1012,7 +1012,7 @@ int close(int socket)
> return ret;
> }
>
> - if (atomic_fetch_sub(&fdi->refcnt, 1))
> + if (atomic_fetch_sub(&fdi->refcnt, 1) != 1)
> return 0;
>
> idm_clear(&idm, socket);
> diff --git a/librdmacm/rsocket.c b/librdmacm/rsocket.c
> index 4fbe7aaa938610..9a71035fbeed8b 100644
> --- a/librdmacm/rsocket.c
> +++ b/librdmacm/rsocket.c
> @@ -898,7 +898,7 @@ static int rs_create_ep(struct rsocket *rs)
>
> static void rs_release_iomap_mr(struct rs_iomap_mr *iomr)
> {
> - if (atomic_fetch_sub(&iomr->refcnt, 1))
> + if (atomic_fetch_sub(&iomr->refcnt, 1) != 1)
> return;
>
> dlist_remove(&iomr->entry);
Hello Jason,
Have you considered to introduce something like the function below? I think
that would make the changes smaller and hence easier to review.
static inline int atomic_add_fetch(_Atomic(int) *a, int arg)
{
return atomic_fetch_add(a, arg) + arg;
}
static inline int atomic_sub_fetch(_Atomic(int) *a, int arg)
{
return atomic_fetch_sub(a, arg) - arg;
}
Bart.
N§²æìr¸yúèØb²X¬¶Ç§vØ^)Þº{.nÇ+·¥{±Ù{ayº\x1dÊÚë,j\a¢f£¢·h»öì\x17/oSc¾Ú³9uÀ¦æåÈ&jw¨®\x03(éÝ¢j"ú\x1a¶^[m§ÿïêäz¹Þàþf£¢·h§~m
next prev parent reply other threads:[~2017-03-16 1:04 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-15 22:12 [PATCH rdma-core 0/6] Sparse code changes Jason Gunthorpe
[not found] ` <1489615927-12117-1-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-03-15 22:12 ` [PATCH rdma-core 1/6] Use NULL instead of 0 to silence sparse Jason Gunthorpe
2017-03-15 22:12 ` [PATCH rdma-core 2/6] INADDR_* needs to be byteswapped before being used Jason Gunthorpe
2017-03-15 22:12 ` [PATCH rdma-core 3/6] rstream: Use waitpid instead of wait Jason Gunthorpe
2017-03-15 22:12 ` [PATCH rdma-core 4/6] rdmacm: Use C11 stdatomic for all atomics Jason Gunthorpe
[not found] ` <1489615927-12117-5-git-send-email-jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-03-15 22:55 ` Bart Van Assche
[not found] ` <1489618538.2660.14.camel-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2017-03-15 23:18 ` Jason Gunthorpe
[not found] ` <20170315231837.GA23082-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-03-16 1:04 ` Bart Van Assche [this message]
[not found] ` <1489626275.3542.1.camel-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2017-03-16 16:16 ` Jason Gunthorpe
2017-03-15 22:12 ` [PATCH rdma-core 5/6] rsocket: Fix byte swapping when constructing path records Jason Gunthorpe
2017-03-15 22:12 ` [PATCH rdma-core 6/6] verbs: Consistently apply __attribute_const Jason Gunthorpe
2017-03-21 17:24 ` [PATCH rdma-core 0/6] Sparse code changes Doug Ledford
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=1489626275.3542.1.camel@sandisk.com \
--to=bart.vanassche-xdaiopvojttbdgjk7y7tuq@public.gmane.org \
--cc=jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@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