Re: ZERO_PAGE() vs. loadable modules in Redhat 4.4 i386 kernels ...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



--- Arjan van de Ven <[email protected]> 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(&current->mm->mmap_sem);
	vma = find_vma(current->mm, skb_vaddr(skb));

	spin_lock(&current->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(&current->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
-
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]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux