Message ID | 20220304174701.1453977-21-marco.solieri@minervasys.tech (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Arm cache coloring | expand |
On 04.03.2022 18:46, Marco Solieri wrote: > --- a/xen/common/page_alloc.c > +++ b/xen/common/page_alloc.c > @@ -230,6 +230,13 @@ static bool __read_mostly scrub_debug; > #define scrub_debug false > #endif > > +#ifdef CONFIG_COLORING > +/* Minimum size required for buddy allocator to work with colored one */ > +unsigned long buddy_required_size __read_mostly = MB(64); > +#else > +unsigned long buddy_required_size __read_mostly = 0; > +#endif Please avoid such redundancy when possible. Here perhaps easiest by having the value come from Kconfig. By giving that separate option a prompt, it would even become configurable at build time. > @@ -678,6 +685,13 @@ static void dump_col_heap(unsigned char key) > > printk("Total number of pages: %lu\n", total_avail_col_pages); > } > +static int __init parse_buddy_required_size(const char *s) > +{ > + buddy_required_size = simple_strtoull(s, &s, 0); > + > + return *s ? -EINVAL : 0; > +} > +custom_param("buddy_size", parse_buddy_required_size); Why not integer_param() or, even better fitting the purpose, size_param()? Also (I may have said so elsewhere already) please prefer - over _ in new command line option names. And of course the name needs to be unambiguous enough for it to be easy to associate the purpose. Jan
On 09.03.2022 15:45, Jan Beulich wrote: > On 04.03.2022 18:46, Marco Solieri wrote: >> --- a/xen/common/page_alloc.c >> +++ b/xen/common/page_alloc.c >> @@ -230,6 +230,13 @@ static bool __read_mostly scrub_debug; >> #define scrub_debug false >> #endif >> >> +#ifdef CONFIG_COLORING >> +/* Minimum size required for buddy allocator to work with colored one */ >> +unsigned long buddy_required_size __read_mostly = MB(64); >> +#else >> +unsigned long buddy_required_size __read_mostly = 0; >> +#endif > > Please avoid such redundancy when possible. Here perhaps easiest > by having the value come from Kconfig. By giving that separate > option a prompt, it would even become configurable at build time. Oh, and: Why is this not static? And without seeing what it's going to be used for it's quite hard to judge whether the initial value chosen is actually sufficient. I could imagine that this would rather want to be derived from total memory size. Jan
diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 82f6e8330a..fffa438029 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -230,6 +230,13 @@ static bool __read_mostly scrub_debug; #define scrub_debug false #endif +#ifdef CONFIG_COLORING +/* Minimum size required for buddy allocator to work with colored one */ +unsigned long buddy_required_size __read_mostly = MB(64); +#else +unsigned long buddy_required_size __read_mostly = 0; +#endif + /* * Bit width of the DMA heap -- used to override NUMA-node-first. * allocation strategy, which can otherwise exhaust low memory. @@ -678,6 +685,13 @@ static void dump_col_heap(unsigned char key) printk("Total number of pages: %lu\n", total_avail_col_pages); } +static int __init parse_buddy_required_size(const char *s) +{ + buddy_required_size = simple_strtoull(s, &s, 0); + + return *s ? -EINVAL : 0; +} +custom_param("buddy_size", parse_buddy_required_size); #else /* !CONFIG_COLORING */ #define init_col_heap_pages(x, y) init_heap_pages(x, y)