From: Casey Leedom <casey_leedom@yahoo.com>
To: linux-kernel@vger.kernel.org
Subject: Re: ZERO_PAGE() vs. loadable modules in Redhat 4.4 i386 kernels ...
Date: Wed, 27 Jun 2007 11:53:46 -0700 (PDT) [thread overview]
Message-ID: <951709.47871.qm@web30502.mail.mud.yahoo.com> (raw)
In-Reply-To: <1182969547.2718.0.camel@laptopd505.fenrus.org>
--- Arjan van de Ven <arjan@infradead.org> wrote:
> you forgot to attach your source code or provide a URL to it.....
Sorry, my bad. I'm just diving into Linux for the first time and wasn't
aware of the protocols. Here's the code fragment I'm currently using:
address = skb_vaddr(skb) & PAGE_MASK;
end = PAGE_ALIGN(skb_vaddr(skb) + len);
down_read(¤t->mm->mmap_sem);
vma = find_vma(current->mm, skb_vaddr(skb));
spin_lock(¤t->mm->page_table_lock);
for (i = 0; i < skb_shinfo(skb)->nr_frags; i++, address += PAGE_SIZE) {
pgd_t *pgd;
pud_t *pud;
pmd_t *pmd;
pte_t *ptep;
skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
/*
* If we're looking at the ZERO_PAGE() then we don't have to
* do anything. It's never going to be modified. See also
* where we avoid the ZERO_PAGE() in skb_dma_complete().
*/
if (frag->page == ZERO_PAGE(address))
continue;
atomic_inc(&frag->page->_mapcount);
/*
* If we're not dealing with the ZERO_PAGE() then it should
* not be possible to end up without a mapping to the page.
* But just in case we check here and issue a BUG() if the
* mapping is missing ...
*/
if (unlikely((pgd = pgd_offset(current->mm, address),
pgd_none(*pgd)) ||
(pud = pud_offset(pgd, address),
pud_none(*pud)) ||
(pmd = pmd_offset(pud, address),
pmd_none(*pmd)) ||
(ptep = pte_offset_map(pmd, address),
pte_none(*ptep)))) {
printk("skb_dma_pending: missing %s page mapping"
" for vaddr=%#lx, page=%p\n",
pgd_none(*pgd) ? "pgd"
: pud_none(*pud) ? "pud"
: pmd_none(*pmd) ? "pmd"
: "pte",
address, frag->page);
BUG();
}
ptep_set_wrprotect(current->mm, address, ptep);
pte_unmap(ptep);
}
spin_unlock(¤t->mm->page_table_lock);
flush_tlb_range(vma, address, end);
I hope that isn't too large but I wanted to provide sufficient context.
Casey
next prev parent reply other threads:[~2007-06-27 18:53 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-27 18:12 ZERO_PAGE() vs. loadable modules in Redhat 4.4 i386 kernels Casey Leedom
2007-06-27 18:39 ` Arjan van de Ven
2007-06-27 18:53 ` Casey Leedom [this message]
2007-06-27 20:18 ` Arjan van de Ven
2007-06-27 21:40 ` Casey Leedom
2007-06-27 22:43 ` Casey Leedom
2007-06-27 19:02 ` Hugh Dickins
2007-06-27 19:13 ` Casey Leedom
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=951709.47871.qm@web30502.mail.mud.yahoo.com \
--to=casey_leedom@yahoo.com \
--cc=linux-kernel@vger.kernel.org \
/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