From: Yury Norov <yury.norov@gmail.com>
To: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: linux-kernel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Arnd Bergmann <arnd@arndb.de>,
linux-arch@vger.kernel.org
Subject: Re: [PATCH V2 1/2] uapi: Define GENMASK_U128
Date: Tue, 30 Jul 2024 11:15:57 -0700 [thread overview]
Message-ID: <Zqkt3byHNZQvCZiB@yury-ThinkPad> (raw)
In-Reply-To: <20240725054808.286708-2-anshuman.khandual@arm.com>
On Thu, Jul 25, 2024 at 11:18:07AM +0530, Anshuman Khandual wrote:
> This adds GENMASK_U128() and __GENMASK_U128() macros using __BITS_PER_U128
> and __int128 data types. These macros will be used in providing support for
> generating 128 bit masks.
>
> Cc: Yury Norov <yury.norov@gmail.com>
> Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
> Cc: Arnd Bergmann <arnd@arndb.de>>
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-arch@vger.kernel.org
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
> ---
> include/linux/bits.h | 2 ++
> include/uapi/asm-generic/bitsperlong.h | 2 ++
> include/uapi/linux/bits.h | 3 +++
> include/uapi/linux/const.h | 1 +
> 4 files changed, 8 insertions(+)
>
> diff --git a/include/linux/bits.h b/include/linux/bits.h
> index 0eb24d21aac2..0a174cce09d2 100644
> --- a/include/linux/bits.h
> +++ b/include/linux/bits.h
> @@ -35,5 +35,7 @@
> (GENMASK_INPUT_CHECK(h, l) + __GENMASK(h, l))
> #define GENMASK_ULL(h, l) \
> (GENMASK_INPUT_CHECK(h, l) + __GENMASK_ULL(h, l))
> +#define GENMASK_U128(h, l) \
> + (GENMASK_INPUT_CHECK(h, l) + __GENMASK_U128(h, l))
>
> #endif /* __LINUX_BITS_H */
> diff --git a/include/uapi/asm-generic/bitsperlong.h b/include/uapi/asm-generic/bitsperlong.h
> index fadb3f857f28..6275367b17bb 100644
> --- a/include/uapi/asm-generic/bitsperlong.h
> +++ b/include/uapi/asm-generic/bitsperlong.h
> @@ -28,4 +28,6 @@
> #define __BITS_PER_LONG_LONG 64
> #endif
>
> +#define __BITS_PER_U128 128
Do we need such a macro for a fixed-width type? Even if we do, I'm not
sure that a header named bitsperlong.h is a good place to host it.
> +
> #endif /* _UAPI__ASM_GENERIC_BITS_PER_LONG */
> diff --git a/include/uapi/linux/bits.h b/include/uapi/linux/bits.h
> index 3c2a101986a3..4d4b7b08003c 100644
> --- a/include/uapi/linux/bits.h
> +++ b/include/uapi/linux/bits.h
> @@ -12,4 +12,7 @@
> (((~_ULL(0)) - (_ULL(1) << (l)) + 1) & \
> (~_ULL(0) >> (__BITS_PER_LONG_LONG - 1 - (h))))
>
> +#define __GENMASK_U128(h, l) \
> + ((_BIT128((h) + 1)) - (_BIT128(l)))
> +
> #endif /* _UAPI_LINUX_BITS_H */
> diff --git a/include/uapi/linux/const.h b/include/uapi/linux/const.h
> index a429381e7ca5..a0211136dfd8 100644
> --- a/include/uapi/linux/const.h
> +++ b/include/uapi/linux/const.h
> @@ -27,6 +27,7 @@
>
> #define _BITUL(x) (_UL(1) << (x))
> #define _BITULL(x) (_ULL(1) << (x))
> +#define _BIT128(x) ((unsigned __int128)(1) << (x))
GENMASK() macros may be used in assembly code. This is not the case
for GENMASK_128 at this time, of course, but I think we'd introduce
assembly glue at this point to simplify things in future. Can you
check the include/uapi/linux/const.h and add something like _U128()
in there?
>
> #define __ALIGN_KERNEL(x, a) __ALIGN_KERNEL_MASK(x, (__typeof__(x))(a) - 1)
> #define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask))
> --
> 2.30.2
next prev parent reply other threads:[~2024-07-30 18:16 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-25 5:48 [PATCH V2 0/2] uapi: Add support for GENMASK_U128() Anshuman Khandual
2024-07-25 5:48 ` [PATCH V2 1/2] uapi: Define GENMASK_U128 Anshuman Khandual
2024-07-30 18:15 ` Yury Norov [this message]
2024-07-31 3:44 ` Anshuman Khandual
2024-07-31 16:38 ` Yury Norov
2024-07-31 17:16 ` Arnd Bergmann
2024-07-25 5:48 ` [PATCH V2 2/2] lib/test_bits.c: Add tests for GENMASK_U128() Anshuman Khandual
2024-07-30 18:20 ` Yury Norov
2024-07-31 4:11 ` Anshuman Khandual
2024-07-25 21:05 ` [PATCH V2 0/2] uapi: Add support " Andrew Morton
2024-07-26 3:34 ` Anshuman Khandual
2024-07-30 4:29 ` Anshuman Khandual
2024-07-30 12:29 ` Arnd Bergmann
2024-07-31 2:39 ` Anshuman Khandual
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=Zqkt3byHNZQvCZiB@yury-ThinkPad \
--to=yury.norov@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=anshuman.khandual@arm.com \
--cc=arnd@arndb.de \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
/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