Re: Implications of PG_locked and reference count in page structures....

Alan Cox (alan@lxorguk.ukuu.org.uk)
Wed, 15 Aug 2001 16:55:06 +0100 (BST)


> So, what I want to do is this: given a pointer to a previously
> kmalloc'ed block, and the length of that block, I want to (a) identify
> each page associated with the block and (b) lock each page. It appears
> that I can lock the page either by incrementing it's reference count, or
> by setting the PG_locked flag for the page.

If the block was allocated with kmalloc it isnt pageable. That means all you
need to do is to use the virt_to_bus() call. If you are doing PCI DMA
however the preferred approach from 2.4 onwards is the pci_alloc_* API
(see Documentation/DMA-mapping.txt)

> Which method is preferred? Is there another method I should be using
> instead?

You should be fine. If they were user pages then you would want to look
at the kiovec support for mapping user pages and locking them down. For
kernel allocated buffers it is nice and easy.

The only other oddment to note is that ISA bus DMA requires GFP_DMA as a
kmalloc flag, PCI DMA does not (GFP_DMA is "below 16Mb please")

Alan
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/