mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alexey Skidanov <alexey.skidanov@intel.com>
To: Daniel Mentz <danielmentz@google.com>
Cc: Stephen Bates <sbates@raithlin.com>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.co>,
	lkml <linux-kernel@vger.kernel.org>,
	labbott@redhat.com
Subject: Re: lib/genalloc
Date: Fri, 2 Nov 2018 22:56:34 +0200	[thread overview]
Message-ID: <de2e1756-329b-7df2-559e-a603a7edc2ff@intel.com> (raw)
In-Reply-To: <CAE2F3rBifp4y=WQFC6CTcYtPUFyvLD4ZZMrZSzu4P+Fzot_f0A@mail.gmail.com>



On 11/2/18 9:17 PM, Daniel Mentz wrote:
> On Thu, Nov 1, 2018 at 10:07 AM Alexey Skidanov
> <alexey.skidanov@intel.com> wrote:
>> On 11/1/18 18:48, Stephen  Bates wrote:
>>>>    I use gen_pool_first_fit_align() as pool allocation algorithm allocating
>>>>    buffers with requested alignment. But if a chunk base address is not
>>>>    aligned to the requested alignment(from some reason), the returned
>>>>    address is not aligned too.
>>>
>>> Alexey
>>>
>>> Can you try using gen_pool_first_fit_order_align()? Will that give you the alignment you need?
>>>
>>> Stephen
>>>
>>>
>> I think it will not help me. Let's assume that the chunk base address is
>> 0x2F400000 and I want to allocate 16MB aligned buffer. I get back the
>> 0x2F400000. I think it happens because of this string in the
>> gen_pool_alloc_algo():
>>
>> addr = chunk->start_addr + ((unsigned long)start_bit << order);
>>
>> and the gen_pool_first_fit_align() implementation that doesn't take into
>> account the "incorrect" chunk base alignment.
> 
> gen_pool_first_fit_align() has no information about the chunk base
> alignment. Hence, it can't take it into account.
> 
> How do you request the alignment in your code?
> 
> I agree with your analysis that gen_pool_first_fit_align() performs
> alignment only with respect to the start of the chunk not the memory
> address that gen_pool_alloc_algo() returns. I guess a solution would
> be to only add chunks that satisfy all your alignment requirements. In
> your case, you must only add chunks that are 16MB aligned.
> I am unsure whether this is by design, but I believe it's the way that
> the code currently works.
> 

Daniel,

I think the better solution is to use bitmap_find_next_zero_area_off()
that receives the bit offset (CMA allocator uses it to solve the same
issue). Of course, we need to pass the chunk base address to the
gen_pool_first_fit_align().

What do you think?

Thanks,
Alexey

  reply	other threads:[~2018-11-02 20:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-01 16:43 lib/genalloc Alexey Skidanov
2018-11-01 16:48 ` lib/genalloc Stephen  Bates
2018-11-01 17:08   ` lib/genalloc Alexey Skidanov
2018-11-02 19:17     ` lib/genalloc Daniel Mentz
2018-11-02 20:56       ` Alexey Skidanov [this message]
2018-11-02 21:16         ` lib/genalloc Daniel Mentz
2018-11-02 22:18           ` lib/genalloc Alexey Skidanov

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=de2e1756-329b-7df2-559e-a603a7edc2ff@intel.com \
    --to=alexey.skidanov@intel.com \
    --cc=danielmentz@google.com \
    --cc=labbott@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.co \
    --cc=sbates@raithlin.com \
    /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

all inboxes | Powered by JetHome®