From: Gerd Knorr <kraxel@bytesex.org>
To: Marcelo Tosatti <marcelo@conectiva.com.br>,
Kernel List <linux-kernel@vger.kernel.org>
Subject: [patch] vmalloc_to_page() backport for 2.4
Date: Wed, 13 Mar 2002 17:51:22 +0100 [thread overview]
Message-ID: <20020313175122.C7949@bytesex.org> (raw)
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;
+}
next reply other threads:[~2002-03-13 16:50 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-03-13 16:51 Gerd Knorr [this message]
2002-03-13 18:50 ` [patch] vmalloc_to_page() backport for 2.4 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20020313175122.C7949@bytesex.org \
--to=kraxel@bytesex.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcelo@conectiva.com.br \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox