Atsushi Nemoto wrote: > On Wed, 11 Oct 2006 18:01:43 +0200, Franck Bui-Huu <vagabon.xyz@xxxxxxxxx> wrote: >>> __pa() is used in many place indirectly via virt_to_page(). >> what about make virt_to_page() use virt_to_phys() instead ? > > No objection for virt_to_phys(), but I found other __pa() usages in > kernel. > > drivers/char/mem.c: && addr >= __pa(high_memory); > drivers/char/mem.c: return addr >= __pa(high_memory); > drivers/char/mem.c: if (addr + count > __pa(high_memory)) > drivers/char/mem.c: pfn = __pa((u64)vma->vm_pgoff << PAGE_SHIFT) >> PAGE_SHIFT; > > So __pa() should handle >512MB address unless we change all __pa() usages. weird, I really thought that __pa() shouldn't be used by drivers... Let see what people on lkml think about this usage, you'll be CC'ed if you want to. > > How about something like this ? > > #if defined(CONFIG_64BITS) && !defined(CONFIG_BUILD_ELF64) > #define __pa(x) ((unsigned long)(x) - ((unsigned long)(x) >= CKSEG0 ? CKSEG0 : PAGE_OFFSET)) > #else > #define __pa(x) ((unsigned long)(x) - PAGE_OFFSET) > #endif > It would be safer indeed, specially because __pa() definition is not really well defined and seems to be confusing for most people. > In any case, I think virt_to_page() should use simpler virt_to_phys() > for better performance. I agree. Franck