From: David Daney<david.daney@cavium.com>
It was pointed out by David Rientjes that the dummy values for
HPAGE_MASK and HPAGE_SIZE are quite unsafe. It they are inadvertently
used with !CONFIG_HUGETLB_PAGE, compilation would succeed, but the
resulting code would surly not do anything sensible.
Place BUG() in the these dummy definitions, as we do in similar
circumstances in other places, so any abuse can be easily detected.
Since the only sane place to use these symbols when
!CONFIG_HUGETLB_PAGE is on dead code paths, the BUG() cause any actual
code to be emitted by the compiler.

I assume you meant "omitted" here.

I jumbled it up. It should read:

... the BUG() will not cause any actual code to be emitted by the
compiler. In fact I have verified this on both MIPS64 and x86_64 kernels.

I could re-spin the patch with a corrected changelog if desired.

But I don't think it's true. Any such code would occur after testing
is_vm_hugetlb_page() or similar, and would have been omitted anyway.

The point being that we are doing:
if (is_vm_hugetlb_page(vma)) {
/* Do something with HPAGE_MASK*/
} else {
/* Do something with PAGE_MASK */
}
In the !CONFIG_HUGETLB_PAGE case we have:
static inline int is_vm_hugetlb_page(struct vm_area_struct *vma)
{
return 0;
}

The compiler sees that the usage of the dummy definitions is in a dead
code path and nothing is emitted.