All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@domain.hid>
To: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
Cc: xenomai-core <xenomai@xenomai.org>
Subject: Re: [Xenomai-core] [PATCH] fix xnheap_alloc rounding
Date: Wed, 12 Jul 2006 14:38:10 +0200	[thread overview]
Message-ID: <44B4ED32.8040201@domain.hid> (raw)
In-Reply-To: <17588.60046.972123.383913@domain.hid>

[-- Attachment #1: Type: text/plain, Size: 1550 bytes --]

Gilles Chanteperdrix wrote:
> Jan Kiszka wrote:
>  > Hi,
>  > 
>  > playing a stupid rt_heap user (actually I didn't just play this...), I
>  > stumbled over this undocumented oddity:
>  > 
>  > rt_heap_create(&heap, name, 10000, H_PRIO|H_MAPPABLE);
>  > rt_heap_alloc(&heap, 10000, TM_NONBLOCK, &ptr);
>  > 
>  > Creation is successful, allocation fails. The reason: while during
>  > creation the net heap size is rounded down to page boundaries, the
>  > allocation of memory > PAGE_SIZE is rounded up. One could add H_SINGLE
>  > to the flags, but this may even result in allocating less memory than
>  > the user expected, causing severe problems later.
>  > 
>  > How to resolve this best? I thought about rounding twice in
>  > rt_head_create (one time the net size, the second time including the
>  > overhead), but this encodes characteristics of the underlying heap
>  > allocator into the skin (I have a generic heap allocator framework in
>  > mind for 2.3). So I decided to do this rounding in xnheap_overhead()
>  > instead, see attached patch. Hope I didn't skewed up any calculation. At
>  > least the scenario above now works fine.
> 
> The problem I see with this patch is that you are counting 
> (rounded_hsize - hsize) as part of the overhead, whereas you would like to
> count it as free space. Would not it make more sense to do the rounding
> in xnheap_init_mapped ?
> 

I was thinking of the open-coded

allocate(heap_size + xnheap_overhead)
xnheap_init()

in many skins as well.

Jan


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 250 bytes --]

  reply	other threads:[~2006-07-12 12:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-11 14:02 [Xenomai-core] [PATCH] fix xnheap_alloc rounding Jan Kiszka
2006-07-12 12:26 ` Gilles Chanteperdrix
2006-07-12 12:38   ` Jan Kiszka [this message]
2006-07-15  1:48 ` Philippe Gerum
2006-07-15  8:07   ` Jan Kiszka
2006-07-15  8:19     ` Philippe Gerum

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=44B4ED32.8040201@domain.hid \
    --to=jan.kiszka@domain.hid \
    --cc=gilles.chanteperdrix@xenomai.org \
    --cc=xenomai@xenomai.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.