All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Metzmacher <metze@samba.org>
To: "Håkon Bugge" <haakon.bugge@oracle.com>,
	"Doug Ledford" <dledford@redhat.com>,
	"Jason Gunthorpe" <jgg@nvidia.com>,
	"Leon Romanovsky" <leon@kernel.org>
Cc: linux-rdma@vger.kernel.org
Subject: Re: [PATCH for-next] RDMA/cma: Replace RMW with atomic bit-ops
Date: Wed, 16 Jun 2021 17:02:57 +0200	[thread overview]
Message-ID: <70403927-7cd3-a9e2-6e97-d1bb35571db6@samba.org> (raw)
In-Reply-To: <1623854153-19147-1-git-send-email-haakon.bugge@oracle.com>

Hi Håkon,

> +#define BIT_ACCESS_FUNCTIONS(b)							\
> +	static inline void set_##b(unsigned long flags)				\
> +	{									\
> +		/* set_bit() does not imply a memory barrier */			\
> +		smp_mb__before_atomic();					\
> +		set_bit(b, &flags);						\
> +		/* set_bit() does not imply a memory barrier */			\
> +		smp_mb__after_atomic();						\
> +	}									\

Don't you need to pass flags by reference to the inline function?
As far as I can see set_bit() operates on a temporary variable.

In order to check if inline functions are special I wrote this little check:

$ cat inline_arg.c
#include <stdio.h>

static inline void func(unsigned s, unsigned *p)
{
        printf("&s=%p p=%p\n", &s, p);
}

int main(void)
{
        unsigned flags = 0;

        func(flags, &flags);
        return 0;
}

$ gcc -O0 -o inline_arg inline_arg.c
$ ./inline_arg
&s=0x7ffd3a71616c p=0x7ffd3a716184

$ gcc -O6 -o inline_arg inline_arg.c
$ ./inline_arg
&s=0x7ffd87781064 p=0x7ffd87781060

It means s doesn't magically become 'flags' of the caller...

I'm I missing something?

metze

  reply	other threads:[~2021-06-16 15:03 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-16 14:35 [PATCH for-next] RDMA/cma: Replace RMW with atomic bit-ops Håkon Bugge
2021-06-16 15:02 ` Stefan Metzmacher [this message]
2021-06-16 16:03   ` Haakon Bugge
2021-06-17  6:51 ` Leon Romanovsky
2021-06-17  6:56   ` Haakon Bugge
2021-06-17  7:38     ` Leon Romanovsky
2021-06-17  9:19       ` Haakon Bugge
2021-06-17 12:49         ` Leon Romanovsky
2021-06-18 13:57           ` Haakon Bugge
2021-06-21 14:35 ` Jason Gunthorpe
2021-06-21 15:30   ` Haakon Bugge
2021-06-21 15:32     ` Jason Gunthorpe
2021-06-21 15:37       ` Haakon Bugge
2021-06-21 23:29         ` Jason Gunthorpe
2021-06-22  7:34           ` Haakon Bugge
2021-06-22  7:44             ` Haakon Bugge

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=70403927-7cd3-a9e2-6e97-d1bb35571db6@samba.org \
    --to=metze@samba.org \
    --cc=dledford@redhat.com \
    --cc=haakon.bugge@oracle.com \
    --cc=jgg@nvidia.com \
    --cc=leon@kernel.org \
    --cc=linux-rdma@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.