* [RFC PATCH v1 31/57] edac: Remove PAGE_SIZE compile-time constant assumption
[not found] ` <20241014105912.3207374-1-ryan.roberts@arm.com>
@ 2024-10-14 10:58 ` Ryan Roberts
2024-10-16 14:46 ` Ryan Roberts
0 siblings, 1 reply; 2+ messages in thread
From: Ryan Roberts @ 2024-10-14 10:58 UTC (permalink / raw)
To: Andrew Morton, Anshuman Khandual, Ard Biesheuvel, Catalin Marinas,
David Hildenbrand, Greg Marsden, Ivan Ivanov, Kalesh Singh,
Marc Zyngier, Mark Rutland, Matthias Brugger, Miroslav Benes,
Will Deacon
Cc: Ryan Roberts, linux-arm-kernel, linux-edac, linux-kernel,
linux-mm
To prepare for supporting boot-time page size selection, refactor code
to remove assumptions about PAGE_SIZE being compile-time constant. Code
intended to be equivalent when compile-time page size is active.
Convert PAGES_TO_MiB() and MiB_TO_PAGES() to use the ternary operator so
that they continue to work with boot-time page size; Boot-time page size
can't be used with CPP because it's value is not known at compile time.
For compile-time page size builds, the compiler will dead code strip for
the same result.
Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>
---
***NOTE***
Any confused maintainers may want to read the cover note here for context:
https://lore.kernel.org/all/20241014105514.3206191-1-ryan.roberts@arm.com/
drivers/edac/edac_mc.h | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/drivers/edac/edac_mc.h b/drivers/edac/edac_mc.h
index 881b00eadf7a5..22132ee86e953 100644
--- a/drivers/edac/edac_mc.h
+++ b/drivers/edac/edac_mc.h
@@ -37,13 +37,12 @@
#include <linux/workqueue.h>
#include <linux/edac.h>
-#if PAGE_SHIFT < 20
-#define PAGES_TO_MiB(pages) ((pages) >> (20 - PAGE_SHIFT))
-#define MiB_TO_PAGES(mb) ((mb) << (20 - PAGE_SHIFT))
-#else /* PAGE_SHIFT > 20 */
-#define PAGES_TO_MiB(pages) ((pages) << (PAGE_SHIFT - 20))
-#define MiB_TO_PAGES(mb) ((mb) >> (PAGE_SHIFT - 20))
-#endif
+#define PAGES_TO_MiB(pages) (PAGE_SHIFT < 20 ? \
+ ((pages) >> (20 - PAGE_SHIFT)) :\
+ ((pages) << (PAGE_SHIFT - 20)))
+#define MiB_TO_PAGES(mb) (PAGE_SHIFT < 20 ? \
+ ((mb) << (20 - PAGE_SHIFT)) : \
+ ((mb) >> (PAGE_SHIFT - 20)))
#define edac_printk(level, prefix, fmt, arg...) \
printk(level "EDAC " prefix ": " fmt, ##arg)
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [RFC PATCH v1 31/57] edac: Remove PAGE_SIZE compile-time constant assumption
2024-10-14 10:58 ` [RFC PATCH v1 31/57] edac: Remove PAGE_SIZE compile-time constant assumption Ryan Roberts
@ 2024-10-16 14:46 ` Ryan Roberts
0 siblings, 0 replies; 2+ messages in thread
From: Ryan Roberts @ 2024-10-16 14:46 UTC (permalink / raw)
To: Andrew Morton, Anshuman Khandual, Ard Biesheuvel, Catalin Marinas,
David Hildenbrand, Greg Marsden, Ivan Ivanov, Kalesh Singh,
Marc Zyngier, Mark Rutland, Matthias Brugger, Miroslav Benes,
Will Deacon
Cc: linux-arm-kernel, linux-edac, linux-kernel, linux-mm
+ Borislav Petkov, Tony Luck
This was a rather tricky series to get the recipients correct for and my script
did not realize that "supporter" was a pseudonym for "maintainer" so you were
missed off the original post. Appologies!
More context in cover letter:
https://lore.kernel.org/all/20241014105514.3206191-1-ryan.roberts@arm.com/
On 14/10/2024 11:58, Ryan Roberts wrote:
> To prepare for supporting boot-time page size selection, refactor code
> to remove assumptions about PAGE_SIZE being compile-time constant. Code
> intended to be equivalent when compile-time page size is active.
>
> Convert PAGES_TO_MiB() and MiB_TO_PAGES() to use the ternary operator so
> that they continue to work with boot-time page size; Boot-time page size
> can't be used with CPP because it's value is not known at compile time.
> For compile-time page size builds, the compiler will dead code strip for
> the same result.
>
> Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>
> ---
>
> ***NOTE***
> Any confused maintainers may want to read the cover note here for context:
> https://lore.kernel.org/all/20241014105514.3206191-1-ryan.roberts@arm.com/
>
> drivers/edac/edac_mc.h | 13 ++++++-------
> 1 file changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/edac/edac_mc.h b/drivers/edac/edac_mc.h
> index 881b00eadf7a5..22132ee86e953 100644
> --- a/drivers/edac/edac_mc.h
> +++ b/drivers/edac/edac_mc.h
> @@ -37,13 +37,12 @@
> #include <linux/workqueue.h>
> #include <linux/edac.h>
>
> -#if PAGE_SHIFT < 20
> -#define PAGES_TO_MiB(pages) ((pages) >> (20 - PAGE_SHIFT))
> -#define MiB_TO_PAGES(mb) ((mb) << (20 - PAGE_SHIFT))
> -#else /* PAGE_SHIFT > 20 */
> -#define PAGES_TO_MiB(pages) ((pages) << (PAGE_SHIFT - 20))
> -#define MiB_TO_PAGES(mb) ((mb) >> (PAGE_SHIFT - 20))
> -#endif
> +#define PAGES_TO_MiB(pages) (PAGE_SHIFT < 20 ? \
> + ((pages) >> (20 - PAGE_SHIFT)) :\
> + ((pages) << (PAGE_SHIFT - 20)))
> +#define MiB_TO_PAGES(mb) (PAGE_SHIFT < 20 ? \
> + ((mb) << (20 - PAGE_SHIFT)) : \
> + ((mb) >> (PAGE_SHIFT - 20)))
>
> #define edac_printk(level, prefix, fmt, arg...) \
> printk(level "EDAC " prefix ": " fmt, ##arg)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-10-16 14:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20241014105514.3206191-1-ryan.roberts@arm.com>
[not found] ` <20241014105912.3207374-1-ryan.roberts@arm.com>
2024-10-14 10:58 ` [RFC PATCH v1 31/57] edac: Remove PAGE_SIZE compile-time constant assumption Ryan Roberts
2024-10-16 14:46 ` Ryan Roberts
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox