My proposal for support of extremely fragmented physical memory maps is
to use a hash table instead of a direct table lookup in the following
four functions:
logical_to_phys
phys_to_logica
pagenum_to_phys
phys_to_pagenum
With the page.h organization:
#ifdef CONFIG_NONLINEAR
#ifdef CONFIG_NONLINEAR_HASH
<the hash table versions of above>
#else
<the direct table mappings>
#endif
#else
/* Stub definitions */
#define logical_to_phys(p) (p)
#define phys_to_logical(p) (p)
#define ordinal_to_phys(n) ((n) << PAGE_SHIFT)
#define phys_to_ordinal(p) ((p) >> PAGE_SHIFT)
#endif
The hash tables only be updated when the memory configuration changes.
In fact, we will may likely only need the hash table in one direction, in
the case that the virtual memory map is less fragmented than physical memory.
Then we can use a direct table to go the other direction, and we might want:
#ifdef CONFIG_NONLINEAR
#ifdef CONFIG_NONLINEAR_PHASH
<the hash table versions of above>
#else
<the direct table mappings>
#endif
#else
#define phys_to_logical(p) (p)
#define phys_to_ordinal(p) ((p) >> PAGE_SHIFT)
#endif
#ifdef CONFIG_NONLINEAR
#ifdef CONFIG_NONLINEAR_VHASH
<the hash table versions of above>
#else
<the direct table mappings>
#endif
#else
#define logical_to_phys(p) (p)
#define ordinal_to_phys(n) ((n) << PAGE_SHIFT)
#endif
These are all per-arch, though one of my goals is to reduce the
difference between arches, where it doesn't involve any compromise.
-- Daniel - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/