On Fri, Mar 11, 2022 at 5:31 AM Luis Chamberlain <mcgrof@xxxxxxxxxx> wrote: > > On Tue, Mar 08, 2022 at 01:03:08AM +0800, Muchun Song wrote: > > On Tue, Mar 8, 2022 at 12:35 AM Luis Chamberlain <mcgrof@xxxxxxxxxx> wrote: > > > > > > On Mon, Mar 07, 2022 at 09:07:05PM +0800, Muchun Song wrote: > > > > If the size of "struct page" is not the power of two and this > > > > feature is enabled, then the vmemmap pages of HugeTLB will be > > > > corrupted after remapping (panic is about to happen in theory). > > > > > > Huh what? If a panic is possible best we prevent this in kconfig > > > all together. I'd instead just put some work into this instead of > > > adding all this run time hacks. > > > > If the size of `struct page` is not power of 2, then those lines added > > by this patch will be optimized away by the compiler, therefore there > > is going to be no extra overhead to detect this. > > > > > > > > Can you try to add kconfig magic to detect if a PAGE_SIZE is PO2? > > > > > > > I agree with you that it is better if we can move this check > > into Kconfig. I tried this a few months ago. It is not easy to > > do this. How to check if a `struct page size` is PO2 in > > Kconfig? If you have any thoughts please let me know. > > Can you query this with a script? > > config HAS_PAGE_SIZE_PO2 > bool > default $(shell, scripts/check_po2_page_size.sh arguments_are_allowed) > Excellent. I'll try this approach. Thanks very much.