mm/hugetlb: Use max() to simplify hugetlb_vmemmap_optimizable_size()
Subsystems (2)
PATCH 1/1 mm/hugetlb: Use max() to simplify hugetlb_vmemmap_optimizable_size()
Use max() to simplify hugetlb_vmemmap_optimizable_size() and improve its readability.
--- mm/hugetlb_vmemmap.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
mm/hugetlb_vmemmap.h +3 -3
@@ -11,6 +11,7 @@#include <linux/hugetlb.h> #include <linux/io.h> #include <linux/memblock.h> +#include <linux/minmax.h> /* * Reserve one vmemmap page, all vmemmap addresses are mapped to it. See
@@ -44,11 +45,10 @@ static inline unsigned int hugetlb_vmemmap_size(const struct hstate *h)*/ static inline unsigned int hugetlb_vmemmap_optimizable_size (const struct hstate *h) { -int size =hugetlb_vmemmap_size (h) -HUGETLB_VMEMMAP_RESERVE_SIZE ; -if (!is_power_of_2 (sizeof (struct page )))return 0 ; -return size >0 ? size :0 ; + +return max (0 ,hugetlb_vmemmap_size (h) -HUGETLB_VMEMMAP_RESERVE_SIZE ); }#else static inline int hugetlb_vmemmap_restore_folio (const struct hstate *h,struct folio *folio)
Signature · 1 line
2.50.1
Quoted 2 lines · Thorsten Blum
Use
max()to simplifyhugetlb_vmemmap_optimizable_size()and improve its readability.
That ... isn't clearer.
Quoted 9 lines
{
mm/hugetlb_vmemmap.h +2
-3-int size =hugetlb_vmemmap_size (h) -HUGETLB_VMEMMAP_RESERVE_SIZE ; -if (!is_power_of_2 (sizeof (struct page )))return 0 ; -return size >0 ? size :0 ; + +return max (0 ,hugetlb_vmemmap_size (h) -HUGETLB_VMEMMAP_RESERVE_SIZE ); }
Quoted 5 lines · Matthew Wilcox
Quoted 2 lines · Thorsten Blum
Use
max()to simplifyhugetlb_vmemmap_optimizable_size()and improve its readability.That ... isn't clearer.
No, it isn't.
Signature · 3 lines
Cheers, David / dhildenb
Quoted 7 lines · David Hildenbrand
Quoted 4 lines · Matthew Wilcox
Quoted 2 lines · Thorsten Blum
Use
max()to simplifyhugetlb_vmemmap_optimizable_size()and improve its readability.That ... isn't clearer.
No, it isn't.
I guess it's personal preference. I'd prefer max(0, x) over a ternary operator any time.
Thorsten
Quoted 11 lines · Thorsten Blum
Quoted 7 lines · David Hildenbrand
Quoted 4 lines · Matthew Wilcox
Quoted 2 lines · Thorsten Blum
Use
max()to simplifyhugetlb_vmemmap_optimizable_size()and improve its readability.That ... isn't clearer.
No, it isn't.
I guess it's personal preference. I'd prefer
max(0, x)over a ternary operator any time.
if (size > 0)
return size;
/* Nothing can be optimized out. */
return 0;
Signature · 3 lines
Cheers, David / dhildenb