mm.h's __page_to_virt() has a rather opaque expression. Comment it.
Reported-By: Ian Campbell <ian.campbell@citrix.com>
Suggested-by: Ian Jackson <ian.jackson@eu.citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
static inline void *__page_to_virt(const struct page_info *pg)
{
ASSERT((unsigned long)pg - FRAMETABLE_VIRT_START < FRAMETABLE_VIRT_END);
+ /*
+ * (sizeof(*pg) & -sizeof(*pg)) selects the LS bit of sizeof(*pg). The
+ * division and re-multiplication avoids one shift when sizeof(*pg) is a
+ * power of two (otherwise there would be a right shift followed by a
+ * left shift, which the compiler can't know it can fold into one).
+ */
return (void *)(DIRECTMAP_VIRT_START +
((unsigned long)pg - FRAMETABLE_VIRT_START) /
(sizeof(*pg) / (sizeof(*pg) & -sizeof(*pg))) *