* [PATCH v1 0/3] regmap: Cleanup and microoptimization
@ 2024-11-21 10:57 Andy Shevchenko
2024-11-21 10:57 ` [PATCH v1 1/3] regmap: cache: Use BITS_TO_BYTES() Andy Shevchenko
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Andy Shevchenko @ 2024-11-21 10:57 UTC (permalink / raw)
To: Mark Brown, Guenter Roeck, linux-kernel, llvm
Cc: Greg Kroah-Hartman, Rafael J. Wysocki, Nathan Chancellor,
Nick Desaulniers, Bill Wendling, Justin Stitt, Andy Shevchenko
Two patches move the code to use BITS_TO_BYTES(), while the last
one otpimizes the code generation on x86 (32- and 64-bit on different
compilers).
Andy Shevchenko (3):
regmap: cache: Use BITS_TO_BYTES()
regmap: Use BITS_TO_BYTES()
regmap: place foo / 8 and foo % 8 closer to each other
drivers/base/regmap/regcache.c | 2 +-
drivers/base/regmap/regmap.c | 9 ++++-----
2 files changed, 5 insertions(+), 6 deletions(-)
--
2.43.0.rc1.1336.g36b5255a03ac
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v1 1/3] regmap: cache: Use BITS_TO_BYTES()
2024-11-21 10:57 [PATCH v1 0/3] regmap: Cleanup and microoptimization Andy Shevchenko
@ 2024-11-21 10:57 ` Andy Shevchenko
2024-11-21 10:57 ` [PATCH v1 2/3] regmap: " Andy Shevchenko
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2024-11-21 10:57 UTC (permalink / raw)
To: Mark Brown, Guenter Roeck, linux-kernel, llvm
Cc: Greg Kroah-Hartman, Rafael J. Wysocki, Nathan Chancellor,
Nick Desaulniers, Bill Wendling, Justin Stitt, Andy Shevchenko
BITS_TO_BYTES() is the existing macro which takes care about full
bytes that may fully hold the given amount of bits. Use it.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/base/regmap/regcache.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c
index d3659ba3cc11..b1f8508c3966 100644
--- a/drivers/base/regmap/regcache.c
+++ b/drivers/base/regmap/regcache.c
@@ -154,7 +154,7 @@ int regcache_init(struct regmap *map, const struct regmap_config *config)
map->num_reg_defaults = config->num_reg_defaults;
map->num_reg_defaults_raw = config->num_reg_defaults_raw;
map->reg_defaults_raw = config->reg_defaults_raw;
- map->cache_word_size = DIV_ROUND_UP(config->val_bits, 8);
+ map->cache_word_size = BITS_TO_BYTES(config->val_bits);
map->cache_size_raw = map->cache_word_size * config->num_reg_defaults_raw;
map->cache = NULL;
--
2.43.0.rc1.1336.g36b5255a03ac
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v1 2/3] regmap: Use BITS_TO_BYTES()
2024-11-21 10:57 [PATCH v1 0/3] regmap: Cleanup and microoptimization Andy Shevchenko
2024-11-21 10:57 ` [PATCH v1 1/3] regmap: cache: Use BITS_TO_BYTES() Andy Shevchenko
@ 2024-11-21 10:57 ` Andy Shevchenko
2024-11-21 10:57 ` [PATCH v1 3/3] regmap: place foo / 8 and foo % 8 closer to each other Andy Shevchenko
2024-12-02 17:36 ` [PATCH v1 0/3] regmap: Cleanup and microoptimization Mark Brown
3 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2024-11-21 10:57 UTC (permalink / raw)
To: Mark Brown, Guenter Roeck, linux-kernel, llvm
Cc: Greg Kroah-Hartman, Rafael J. Wysocki, Nathan Chancellor,
Nick Desaulniers, Bill Wendling, Justin Stitt, Andy Shevchenko
BITS_TO_BYTES() is the existing macro which takes care about full
bytes that may fully hold the given amount of bits. Use it.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/base/regmap/regmap.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 53131a7ede0a..d2944271022c 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -759,12 +759,11 @@ struct regmap *__regmap_init(struct device *dev,
map->reg_base = config->reg_base;
- map->format.reg_bytes = DIV_ROUND_UP(config->reg_bits, 8);
+ map->format.reg_bytes = BITS_TO_BYTES(config->reg_bits);
map->format.pad_bytes = config->pad_bits / 8;
map->format.reg_shift = config->reg_shift;
- map->format.val_bytes = DIV_ROUND_UP(config->val_bits, 8);
- map->format.buf_size = DIV_ROUND_UP(config->reg_bits +
- config->val_bits + config->pad_bits, 8);
+ map->format.val_bytes = BITS_TO_BYTES(config->val_bits);
+ map->format.buf_size = BITS_TO_BYTES(config->reg_bits + config->val_bits + config->pad_bits);
map->reg_shift = config->pad_bits % 8;
if (config->reg_stride)
map->reg_stride = config->reg_stride;
--
2.43.0.rc1.1336.g36b5255a03ac
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v1 3/3] regmap: place foo / 8 and foo % 8 closer to each other
2024-11-21 10:57 [PATCH v1 0/3] regmap: Cleanup and microoptimization Andy Shevchenko
2024-11-21 10:57 ` [PATCH v1 1/3] regmap: cache: Use BITS_TO_BYTES() Andy Shevchenko
2024-11-21 10:57 ` [PATCH v1 2/3] regmap: " Andy Shevchenko
@ 2024-11-21 10:57 ` Andy Shevchenko
2024-12-02 17:36 ` [PATCH v1 0/3] regmap: Cleanup and microoptimization Mark Brown
3 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2024-11-21 10:57 UTC (permalink / raw)
To: Mark Brown, Guenter Roeck, linux-kernel, llvm
Cc: Greg Kroah-Hartman, Rafael J. Wysocki, Nathan Chancellor,
Nick Desaulniers, Bill Wendling, Justin Stitt, Andy Shevchenko
On x86 the compiler (gcc (Debian 14.2.0-8) 14.2.0) may generate
a better code if it sees division and modulo goes together.
Function old new delta
__regmap_init 3740 3732 -8
Total: Before=31159, After=31151, chg -0.03%
clang (Debian clang version 18.1.8) on x86_64 still shows better code
Function old new delta
__regmap_init 3582 3579 -3
Total: Before=39854, After=39851, chg -0.01%
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/base/regmap/regmap.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index d2944271022c..4f8ec8528e34 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -758,13 +758,13 @@ struct regmap *__regmap_init(struct device *dev,
map->alloc_flags = GFP_KERNEL;
map->reg_base = config->reg_base;
+ map->reg_shift = config->pad_bits % 8;
- map->format.reg_bytes = BITS_TO_BYTES(config->reg_bits);
map->format.pad_bytes = config->pad_bits / 8;
map->format.reg_shift = config->reg_shift;
+ map->format.reg_bytes = BITS_TO_BYTES(config->reg_bits);
map->format.val_bytes = BITS_TO_BYTES(config->val_bits);
map->format.buf_size = BITS_TO_BYTES(config->reg_bits + config->val_bits + config->pad_bits);
- map->reg_shift = config->pad_bits % 8;
if (config->reg_stride)
map->reg_stride = config->reg_stride;
else
--
2.43.0.rc1.1336.g36b5255a03ac
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1 0/3] regmap: Cleanup and microoptimization
2024-11-21 10:57 [PATCH v1 0/3] regmap: Cleanup and microoptimization Andy Shevchenko
` (2 preceding siblings ...)
2024-11-21 10:57 ` [PATCH v1 3/3] regmap: place foo / 8 and foo % 8 closer to each other Andy Shevchenko
@ 2024-12-02 17:36 ` Mark Brown
3 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2024-12-02 17:36 UTC (permalink / raw)
To: Guenter Roeck, linux-kernel, llvm, Andy Shevchenko
Cc: Greg Kroah-Hartman, Rafael J. Wysocki, Nathan Chancellor,
Nick Desaulniers, Bill Wendling, Justin Stitt
On Thu, 21 Nov 2024 12:57:20 +0200, Andy Shevchenko wrote:
> Two patches move the code to use BITS_TO_BYTES(), while the last
> one otpimizes the code generation on x86 (32- and 64-bit on different
> compilers).
>
> Andy Shevchenko (3):
> regmap: cache: Use BITS_TO_BYTES()
> regmap: Use BITS_TO_BYTES()
> regmap: place foo / 8 and foo % 8 closer to each other
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git for-next
Thanks!
[1/3] regmap: cache: Use BITS_TO_BYTES()
commit: 4a3aafe01f6c628932a402c21e58101173c8dab3
[2/3] regmap: Use BITS_TO_BYTES()
commit: a4a7d86bc1a59839ad0dffbefa473135b342dd0b
[3/3] regmap: place foo / 8 and foo % 8 closer to each other
commit: 9b3cd5c7099fe7710356dd76ecf9910dc8c32548
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-12-02 17:36 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-21 10:57 [PATCH v1 0/3] regmap: Cleanup and microoptimization Andy Shevchenko
2024-11-21 10:57 ` [PATCH v1 1/3] regmap: cache: Use BITS_TO_BYTES() Andy Shevchenko
2024-11-21 10:57 ` [PATCH v1 2/3] regmap: " Andy Shevchenko
2024-11-21 10:57 ` [PATCH v1 3/3] regmap: place foo / 8 and foo % 8 closer to each other Andy Shevchenko
2024-12-02 17:36 ` [PATCH v1 0/3] regmap: Cleanup and microoptimization Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®