A little helper that we use in the hotplug code.
Signed-off-by: Dave Hansen <[email protected]>
---
memhotplug-dave/include/linux/mmzone.h | 26 ++++++++++++++++++++++++++
mm/sparse.c | 0
2 files changed, 26 insertions(+)
diff -puN include/linux/mmzone.h~C3-__section_nr include/linux/mmzone.h
--- memhotplug/include/linux/mmzone.h~C3-__section_nr 2005-08-12 07:43:45.000000000 -0700
+++ memhotplug-dave/include/linux/mmzone.h 2005-08-12 07:43:45.000000000 -0700
@@ -511,6 +511,31 @@ static inline struct mem_section *__nr_t
}
/*
+ * Although written for the SPARSEMEM_EXTREME case, this happens
+ * to also work for the flat array case becase
+ * NR_SECTION_ROOTS==NR_MEM_SECTIONS.
+ */
+static inline int __section_nr(struct mem_section* ms)
+{
+ unsigned long root_nr;
+ struct mem_section* root;
+
+ for (root_nr = 0;
+ root_nr < NR_MEM_SECTIONS;
+ root_nr += SECTIONS_PER_ROOT) {
+ root = __nr_to_section(root_nr);
+
+ if (!root)
+ continue;
+
+ if ((ms >= root) && (ms < (root + SECTIONS_PER_ROOT)))
+ break;
+ }
+
+ return (root_nr * SECTIONS_PER_ROOT) + (ms - root);
+}
+
+/*
* We use the lower bits of the mem_map pointer to store
* a little bit of information. There should be at least
* 3 bits here due to 32-bit alignment.
@@ -606,3 +631,4 @@ unsigned long __init node_memmap_size_by
#endif /* !__ASSEMBLY__ */
#endif /* __KERNEL__ */
#endif /* _LINUX_MMZONE_H */
+
diff -puN mm/sparse.c~C3-__section_nr mm/sparse.c
_
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
|
|