public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] vmalloc_to_page() backport for 2.4
@ 2002-03-13 16:51 Gerd Knorr
  2002-03-13 18:50 ` Tigran Aivazian
  0 siblings, 1 reply; 10+ messages in thread
From: Gerd Knorr @ 2002-03-13 16:51 UTC (permalink / raw)
  To: Marcelo Tosatti, Kernel List

  Hi,

This is a 2.4.x backport of the new 2.5.x vmalloc_to_page() function.
I'd like to see that function in 2.4.x too because it makes driver
maintaining easier.

  Gerd

==============================[ cut here ]==============================
--- linux-2.4.19-pre3/include/linux/mm.h	Tue Mar 12 09:59:02 2002
+++ linux/include/linux/mm.h	Tue Mar 12 18:15:02 2002
@@ -670,6 +670,8 @@
 
 extern struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr);
 
+extern struct page * vmalloc_to_page(void *addr);
+
 #endif /* __KERNEL__ */
 
 #endif
--- linux-2.4.19-pre3/kernel/ksyms.c	Tue Mar 12 10:00:44 2002
+++ linux/kernel/ksyms.c	Tue Mar 12 10:00:44 2002
@@ -108,6 +108,7 @@
 EXPORT_SYMBOL(kfree);
 EXPORT_SYMBOL(vfree);
 EXPORT_SYMBOL(__vmalloc);
+EXPORT_SYMBOL_GPL(vmalloc_to_page);
 EXPORT_SYMBOL(mem_map);
 EXPORT_SYMBOL(remap_page_range);
 EXPORT_SYMBOL(max_mapnr);
--- linux-2.4.19-pre3/mm/memory.c	Tue Mar 12 09:59:02 2002
+++ linux/mm/memory.c	Tue Mar 12 10:00:44 2002
@@ -1471,3 +1471,24 @@
 			len, write, 0, NULL, NULL);
 	return ret == len ? 0 : -1;
 }
+
+struct page * vmalloc_to_page(void * vmalloc_addr)
+{
+	unsigned long addr = (unsigned long) vmalloc_addr;
+	struct page *page = NULL;
+	pmd_t *pmd;
+	pte_t *pte;
+	pgd_t *pgd;
+	
+	pgd = pgd_offset_k(addr);
+	if (!pgd_none(*pgd)) {
+		pmd = pmd_offset(pgd, addr);
+		if (!pmd_none(*pmd)) {
+			pte = pte_offset(pmd, addr);
+			if (pte_present(*pte)) {
+				page = pte_page(*pte);
+			}
+		}
+	}
+	return page;
+}

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2002-03-19 23:39 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-03-13 16:51 [patch] vmalloc_to_page() backport for 2.4 Gerd Knorr
2002-03-13 18:50 ` Tigran Aivazian
2002-03-13 19:20   ` Alan Cox
2002-03-14 12:30     ` Tigran Aivazian
2002-03-14 12:33       ` Tigran Aivazian
2002-03-14 13:13       ` David Woodhouse
2002-03-14 13:58       ` Alan Cox
2002-03-14 14:46         ` Hugh Dickins
2002-03-19 16:30           ` Arjan van de Ven
2002-03-19 23:40             ` Hugh Dickins

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox