All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julien Grall <julien@xen.org>
To: Roger Pau Monne <roger.pau@citrix.com>, xen-devel@lists.xenproject.org
Cc: Stefano Stabellini <sstabellini@kernel.org>, Wei Liu <wl@xen.org>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	George Dunlap <George.Dunlap@eu.citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>,
	Jan Beulich <jbeulich@suse.com>,
	Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
Subject: Re: [Xen-devel] [PATCH v5 2/4] arm: rename BIT_WORD to BITOP_WORD
Date: Mon, 17 Feb 2020 21:46:24 +0000	[thread overview]
Message-ID: <cebafac4-b109-1726-1fa0-cb9fe7554e4d@xen.org> (raw)
In-Reply-To: <20200217114545.71112-3-roger.pau@citrix.com>

Hi Roger,

Thank you for the renaming.

On 17/02/2020 11:45, Roger Pau Monne wrote:
> So BIT_WORD can be imported from Linux. The difference between current
> Linux implementation of BIT_WORD is that the size of the word unit is
> a long integer, while the Xen one is hardcoded to 32 bits.
> 
> Current users of BITOP_WORD on Arm (which considers a word a long
> integer) are switched to use the generic BIT_WORD which also operates
> on long integers.
> 
> No functional change intended.
> 
> Suggested-by: Julien Grall <julien@xen.org>
> Suggested-by: Jan Beulich <jbeulich@suse.com>
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> ---
> Changes since v4:
>   - New in this version.
> ---
>   xen/arch/arm/arm32/lib/bitops.c        |  4 ++--
>   xen/arch/arm/arm64/lib/bitops.c        |  4 ++--
>   xen/arch/arm/arm64/lib/find_next_bit.c | 10 ++++------
>   xen/include/asm-arm/bitops.h           | 10 +++++-----
>   xen/include/xen/bitops.h               |  2 ++
>   5 files changed, 15 insertions(+), 15 deletions(-)
> 
> diff --git a/xen/arch/arm/arm32/lib/bitops.c b/xen/arch/arm/arm32/lib/bitops.c
> index 3dca769bf0..82d935ce33 100644
> --- a/xen/arch/arm/arm32/lib/bitops.c
> +++ b/xen/arch/arm/arm32/lib/bitops.c
> @@ -33,7 +33,7 @@
>   static always_inline bool int_##name(int nr, volatile void *p, bool timeout,\
>                                        unsigned int max_try)                  \
>   {                                                                           \
> -    volatile uint32_t *ptr = (uint32_t *)p + BIT_WORD((unsigned int)nr);    \
> +    volatile uint32_t *ptr = (uint32_t *)p + BITOP_WORD((unsigned int)nr);  \
>       const uint32_t mask = BIT_MASK((unsigned int)nr);                       \
>       unsigned long res, tmp;                                                 \
>                                                                               \
> @@ -71,7 +71,7 @@ bool name##_timeout(int nr, volatile void *p, unsigned int max_try)         \
>   static always_inline bool int_##name(int nr, volatile void *p, int *oldbit, \
>                                        bool timeout, unsigned int max_try)    \
>   {                                                                           \
> -    volatile uint32_t *ptr = (uint32_t *)p + BIT_WORD((unsigned int)nr);    \
> +    volatile uint32_t *ptr = (uint32_t *)p + BITOP_WORD((unsigned int)nr);  \
>       unsigned int bit = (unsigned int)nr % BITS_PER_WORD;                    \
>       const uint32_t mask = BIT_MASK(bit);                                    \
>       unsigned long res, tmp;                                                 \
> diff --git a/xen/arch/arm/arm64/lib/bitops.c b/xen/arch/arm/arm64/lib/bitops.c
> index 27688e5418..f5128c58f5 100644
> --- a/xen/arch/arm/arm64/lib/bitops.c
> +++ b/xen/arch/arm/arm64/lib/bitops.c
> @@ -32,7 +32,7 @@
>   static always_inline bool int_##name(int nr, volatile void *p, bool timeout,\
>                                        unsigned int max_try)                  \
>   {                                                                           \
> -    volatile uint32_t *ptr = (uint32_t *)p + BIT_WORD((unsigned int)nr);    \
> +    volatile uint32_t *ptr = (uint32_t *)p + BITOP_WORD((unsigned int)nr);  \
>       const uint32_t mask = BIT_MASK((unsigned int)nr);                       \
>       unsigned long res, tmp;                                                 \
>                                                                               \
> @@ -67,7 +67,7 @@ bool name##_timeout(int nr, volatile void *p, unsigned int max_try)         \
>   static always_inline bool int_##name(int nr, volatile void *p, int *oldbit, \
>                                        bool timeout, unsigned int max_try)    \
>   {                                                                           \
> -    volatile uint32_t *ptr = (uint32_t *)p + BIT_WORD((unsigned int)nr);    \
> +    volatile uint32_t *ptr = (uint32_t *)p + BITOP_WORD((unsigned int)nr);  \
>       unsigned int bit = (unsigned int)nr % BITS_PER_WORD;                    \
>       const uint32_t mask = BIT_MASK(bit);                                    \
>       unsigned long res, tmp;                                                 \
> diff --git a/xen/arch/arm/arm64/lib/find_next_bit.c b/xen/arch/arm/arm64/lib/find_next_bit.c
> index 17cb176266..8ebf8bfe97 100644
> --- a/xen/arch/arm/arm64/lib/find_next_bit.c
> +++ b/xen/arch/arm/arm64/lib/find_next_bit.c
> @@ -12,8 +12,6 @@
>   #include <asm/types.h>
>   #include <asm/byteorder.h>
>   
> -#define BITOP_WORD(nr)		((nr) / BITS_PER_LONG)
> -
>   #ifndef find_next_bit
>   /*
>    * Find the next set bit in a memory region.
> @@ -21,7 +19,7 @@
>   unsigned long find_next_bit(const unsigned long *addr, unsigned long size,
>   			    unsigned long offset)
>   {
> -	const unsigned long *p = addr + BITOP_WORD(offset);
> +	const unsigned long *p = addr + BIT_WORD(offset);
>   	unsigned long result = offset & ~(BITS_PER_LONG-1);
>   	unsigned long tmp;
>   
> @@ -67,7 +65,7 @@ EXPORT_SYMBOL(find_next_bit);
>   unsigned long find_next_zero_bit(const unsigned long *addr, unsigned long size,
>   				 unsigned long offset)
>   {
> -	const unsigned long *p = addr + BITOP_WORD(offset);
> +	const unsigned long *p = addr + BIT_WORD(offset);
>   	unsigned long result = offset & ~(BITS_PER_LONG-1);
>   	unsigned long tmp;
>   
> @@ -197,7 +195,7 @@ unsigned long find_next_zero_bit_le(const void *addr, unsigned
>   
>   	if (offset >= size)
>   		return size;
> -	p += BITOP_WORD(offset);
> +	p += BIT_WORD(offset);
>   	size -= result;
>   	offset &= (BITS_PER_LONG - 1UL);
>   	if (offset) {
> @@ -243,7 +241,7 @@ unsigned long find_next_bit_le(const void *addr, unsigned
>   
>   	if (offset >= size)
>   		return size;
> -	p += BITOP_WORD(offset);
> +	p += BIT_WORD(offset);
>   	size -= result;
>   	offset &= (BITS_PER_LONG - 1UL);
>   	if (offset) {
> diff --git a/xen/include/asm-arm/bitops.h b/xen/include/asm-arm/bitops.h
> index fbb4b82413..fabf218e23 100644
> --- a/xen/include/asm-arm/bitops.h
> +++ b/xen/include/asm-arm/bitops.h
> @@ -22,7 +22,7 @@
>   
>   #define BITS_PER_WORD           32
>   #define BIT_MASK(nr)            (1UL << ((nr) % BITS_PER_WORD))

The naming for the 2 macros above seem a bit off now. Can this be 
renamed to maybe BITOP_BITS_PER_WORD and BITOP_MASK?

> -#define BIT_WORD(nr)            ((nr) / BITS_PER_WORD)
> +#define BITOP_WORD(nr)          ((nr) / BITS_PER_WORD)
>   #define BITS_PER_BYTE           8
>   
>   #define ADDR (*(volatile int *) addr)
> @@ -87,7 +87,7 @@ static inline int __test_and_set_bit(int nr, volatile void *addr)
>   {
>           unsigned int mask = BIT_MASK(nr);
>           volatile unsigned int *p =
> -                ((volatile unsigned int *)addr) + BIT_WORD(nr);
> +                ((volatile unsigned int *)addr) + BITOP_WORD(nr);
>           unsigned int old = *p;
>   
>           *p = old | mask;
> @@ -107,7 +107,7 @@ static inline int __test_and_clear_bit(int nr, volatile void *addr)
>   {
>           unsigned int mask = BIT_MASK(nr);
>           volatile unsigned int *p =
> -                ((volatile unsigned int *)addr) + BIT_WORD(nr);
> +                ((volatile unsigned int *)addr) + BITOP_WORD(nr);
>           unsigned int old = *p;
>   
>           *p = old & ~mask;
> @@ -120,7 +120,7 @@ static inline int __test_and_change_bit(int nr,
>   {
>           unsigned int mask = BIT_MASK(nr);
>           volatile unsigned int *p =
> -                ((volatile unsigned int *)addr) + BIT_WORD(nr);
> +                ((volatile unsigned int *)addr) + BITOP_WORD(nr);
>           unsigned int old = *p;
>   
>           *p = old ^ mask;
> @@ -135,7 +135,7 @@ static inline int __test_and_change_bit(int nr,
>   static inline int test_bit(int nr, const volatile void *addr)
>   {
>           const volatile unsigned int *p = (const volatile unsigned int *)addr;
> -        return 1UL & (p[BIT_WORD(nr)] >> (nr & (BITS_PER_WORD-1)));
> +        return 1UL & (p[BITOP_WORD(nr)] >> (nr & (BITS_PER_WORD-1)));
>   }
>   
>   /*
> diff --git a/xen/include/xen/bitops.h b/xen/include/xen/bitops.h
> index dfb70417c2..a64595f68e 100644
> --- a/xen/include/xen/bitops.h
> +++ b/xen/include/xen/bitops.h
> @@ -245,4 +245,6 @@ static inline __u32 ror32(__u32 word, unsigned int shift)
>             (bit) < (size);                               \
>             (bit) = find_next_bit(addr, size, (bit) + 1) )
>   
> +#define BIT_WORD(nr) ((nr) / BITS_PER_LONG)
> +
>   #endif
> 

Cheers,

-- 
Julien Grall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2020-02-17 21:47 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-17 11:45 [Xen-devel] [PATCH v5 0/4] nvmx: implement support for MSR bitmaps Roger Pau Monne
2020-02-17 11:45 ` [Xen-devel] [PATCH v5 1/4] " Roger Pau Monne
2020-02-18  8:17   ` Tian, Kevin
2020-02-17 11:45 ` [Xen-devel] [PATCH v5 2/4] arm: rename BIT_WORD to BITOP_WORD Roger Pau Monne
2020-02-17 21:46   ` Julien Grall [this message]
2020-02-17 11:45 ` [Xen-devel] [PATCH v5 3/4] bitmap: import bitmap_{set/clear} from Linux 5.5 Roger Pau Monne
2020-02-18 15:30   ` Jan Beulich
2020-02-17 11:45 ` [Xen-devel] [PATCH v5 4/4] nvmx: always trap accesses to x2APIC MSRs Roger Pau Monne

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=cebafac4-b109-1726-1fa0-cb9fe7554e4d@xen.org \
    --to=julien@xen.org \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jbeulich@suse.com \
    --cc=konrad.wilk@oracle.com \
    --cc=roger.pau@citrix.com \
    --cc=sstabellini@kernel.org \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.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.