lkml.org 
[lkml]   [2007]   [Sep]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    SubjectRe: [PATCH 4/4] dmapool: Improve memory usage for devices which can't cross boundaries
    Matthew Wilcox wrote:

    [...]

    > @@ -142,14 +144,13 @@ struct dma_pool *dma_pool_create(const char *name, struct device *dev,
    > if ((size % align) != 0)
    > size = ALIGN(size, align);
    >
    > - if (allocation == 0) {
    > - if (PAGE_SIZE < size)
    > - allocation = size;
    > - else
    > - allocation = PAGE_SIZE;
    > - // FIXME: round up for less fragmentation
    > - } else if (allocation < size)
    > + allocation = max_t(size_t, size, PAGE_SIZE);
    > +
    > + if (!boundary) {
    > + boundary = allocation;
    > + } else if ((boundary < size) || (boundary & (boundary - 1))) {
    > return NULL;
    > + }

    if (!boundary)
    boundary = allocation;
    else if (boundary < size || boundary & (boundary - 1))
    return NULL;

    [...]

    > @@ -190,11 +192,14 @@ struct dma_pool *dma_pool_create(const char *name, struct device *dev,
    > static void pool_initialise_page(struct dma_pool *pool, struct dma_page *page)
    > {
    > unsigned int offset = 0;
    > + unsigned int next_boundary = pool->boundary;
    >
    > do {
    > unsigned int next = offset + pool->size;
    > - if (unlikely((next + pool->size) >= pool->allocation))
    > - next = pool->allocation;
    > + if (unlikely((next + pool->size) >= next_boundary)) {

    if (unlikely(next + pool->size >= next_boundary)) {

    [...]
    -
    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/

    \
     
     \ /
      Last update: 2007-09-26 22:15    [W:2.450 / U:0.016 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site