Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1509739

Re: [PATCH] lib/genalloc.c: Start search from start of chunk

From Andrew Morton <akpm@linux-foundation.org>
Newsgroups linux.kernel
Subject Re: [PATCH] lib/genalloc.c: Start search from start of chunk
Date 2016-10-26 21:40 +0200
Message-ID <swCdj-8aP-17@gated-at.bofh.it> (permalink)
References <sw91D-5BL-15@gated-at.bofh.it> <sweNI-Sp-17@gated-at.bofh.it> <swAXU-7td-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Wed, 26 Oct 2016 19:09:51 +0100 Will Deacon <will.deacon@arm.com> wrote:

> On Tue, Oct 25, 2016 at 11:36:44AM -0700, Daniel Mentz wrote:
> > gen_pool_alloc_algo() iterates over the chunks of a pool trying to find
> > a contiguous block of memory that satisfies the allocation request.
> > 
> > The shortcut
> > 
> > 	if (size > atomic_read(&chunk->avail))
> > 		continue;
> > 
> > makes the loop skip over chunks that do not have enough bytes left to
> > fulfill the request. There are two situations, though, where an
> > allocation might still fail:
> > 
> > (1) The available memory is not contiguous, i.e. the request cannot be
> > fulfilled due to external fragmentation.
> > 
> > (2) A race condition. Another thread runs the same code concurrently and
> > is quicker to grab the available memory.
> > 
> > In those situations, the loop calls pool->algo() to search the entire
> > chunk, and pool->algo() returns some value that is >= end_bit to
> > indicate that the search failed.  This return value is then assigned to
> > start_bit. The variables start_bit and end_bit describe the range that
> > should be searched, and this range should be reset for every chunk that
> > is searched.  Today, the code fails to reset start_bit to 0.  As a
> > result, prefixes of subsequent chunks are ignored. Memory allocations
> > might fail even though there is plenty of room left in these prefixes of
> > those other chunks.
> 
> Please add a CC stable.

You sure?  The changelog doesn't describe the end-user impacts very
well (it should always do so, please) but I'm thinking "little impact"?

> With that:
> 
> Acked-by: Will Deacon <will.deacon@arm.com>
> 
> Will

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] lib/genalloc.c: Start search from start of chunk Daniel Mentz <danielmentz@google.com> - 2016-10-25 04:00 +0200
  Re: [PATCH] lib/genalloc.c: Start search from start of chunk Mathieu Desnoyers <mathieu.desnoyers@efficios.com> - 2016-10-25 14:30 +0200
    [PATCH] lib/genalloc.c: Start search from start of chunk Daniel Mentz <danielmentz@google.com> - 2016-10-25 20:40 +0200
      Re: [PATCH] lib/genalloc.c: Start search from start of chunk Will Deacon <will.deacon@arm.com> - 2016-10-26 20:20 +0200
        Re: [PATCH] lib/genalloc.c: Start search from start of chunk Andrew Morton <akpm@linux-foundation.org> - 2016-10-26 21:40 +0200
          Re: [PATCH] lib/genalloc.c: Start search from start of chunk Daniel Mentz <danielmentz@google.com> - 2016-10-27 00:30 +0200

csiph-web