diff mbox

linux-generic: buffers: bugfix: Fix bug 1031

Message ID 1420634785-20791-1-git-send-email-bill.fischofer@linaro.org
State Superseded
Headers show

Commit Message

Bill Fischofer Jan. 7, 2015, 12:46 p.m. UTC
Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>
---
 platform/linux-generic/include/odp_buffer_internal.h | 3 ---
 1 file changed, 3 deletions(-)

Comments

Ola Liljedahl Jan. 7, 2015, 2:13 p.m. UTC | #1
On 7 January 2015 at 13:46, Bill Fischofer <bill.fischofer@linaro.org> wrote:
> Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>
> ---
>  platform/linux-generic/include/odp_buffer_internal.h | 3 ---
>  1 file changed, 3 deletions(-)
>
> diff --git a/platform/linux-generic/include/odp_buffer_internal.h b/platform/linux-generic/include/odp_buffer_internal.h
> index 60f06c9..c64802b 100644
> --- a/platform/linux-generic/include/odp_buffer_internal.h
> +++ b/platform/linux-generic/include/odp_buffer_internal.h
> @@ -136,9 +136,6 @@ typedef struct odp_buffer_hdr_t {
>  typedef struct odp_buffer_hdr_stride {
>         uint8_t pad[ODP_CACHE_LINE_SIZE_ROUNDUP(sizeof(odp_buffer_hdr_t))];
>  } odp_buffer_hdr_stride;
> -/* Ensure next header starts from 8 byte align */
> -_ODP_STATIC_ASSERT((sizeof(odp_buffer_hdr_t) % 8) == 0,
> -                  "ODP_BUFFER_HDR_T__SIZE_ERROR");
Is this the preferred solution?
Do we have any alignment requirements on internal headers? Why was
this assert added to start with?
For the timer/timeout internal header I had to add 32-bit of padding
in order to make an equivalent static assert succeed. But perhaps the
assert is the problem?

>
>  typedef struct odp_buf_blk_t {
>         struct odp_buf_blk_t *next;
> --
> 2.1.0
>
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
Bill Fischofer Jan. 7, 2015, 2:19 p.m. UTC | #2
These asserts were vestigial from the previous linux-generic buffer
implementation where the buffer structs were packed within buffer pools and
hence needed to be padded to ensure 8-byte alignment.  In the current
implementation buffers are separately cache-aligned via the stride
mechanism so the size of the individual buffer headers is irrelevant.
That's a cleaner approach since the effect is maintenance can add whatever
it needs to the individual headers for new metadata items, etc. and the
alignment is adjusted automatically.

In the case of 32-bit implementations the pointers drop from 8 to 4 bytes
and this made the individual headers not be multiples of 8, which is why
the assert triggered.  But as noted, these structures are being cache
aligned independent of their individual size so these asserts serve no
purpose and can be safely deleted.

On Wed, Jan 7, 2015 at 8:13 AM, Ola Liljedahl <ola.liljedahl@linaro.org>
wrote:

> On 7 January 2015 at 13:46, Bill Fischofer <bill.fischofer@linaro.org>
> wrote:
> > Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>
> > ---
> >  platform/linux-generic/include/odp_buffer_internal.h | 3 ---
> >  1 file changed, 3 deletions(-)
> >
> > diff --git a/platform/linux-generic/include/odp_buffer_internal.h
> b/platform/linux-generic/include/odp_buffer_internal.h
> > index 60f06c9..c64802b 100644
> > --- a/platform/linux-generic/include/odp_buffer_internal.h
> > +++ b/platform/linux-generic/include/odp_buffer_internal.h
> > @@ -136,9 +136,6 @@ typedef struct odp_buffer_hdr_t {
> >  typedef struct odp_buffer_hdr_stride {
> >         uint8_t
> pad[ODP_CACHE_LINE_SIZE_ROUNDUP(sizeof(odp_buffer_hdr_t))];
> >  } odp_buffer_hdr_stride;
> > -/* Ensure next header starts from 8 byte align */
> > -_ODP_STATIC_ASSERT((sizeof(odp_buffer_hdr_t) % 8) == 0,
> > -                  "ODP_BUFFER_HDR_T__SIZE_ERROR");
> Is this the preferred solution?
> Do we have any alignment requirements on internal headers? Why was
> this assert added to start with?
> For the timer/timeout internal header I had to add 32-bit of padding
> in order to make an equivalent static assert succeed. But perhaps the
> assert is the problem?
>
> >
> >  typedef struct odp_buf_blk_t {
> >         struct odp_buf_blk_t *next;
> > --
> > 2.1.0
> >
> >
> > _______________________________________________
> > lng-odp mailing list
> > lng-odp@lists.linaro.org
> > http://lists.linaro.org/mailman/listinfo/lng-odp
>
Ola Liljedahl Jan. 7, 2015, 3:25 p.m. UTC | #3
On 7 January 2015 at 15:19, Bill Fischofer <bill.fischofer@linaro.org> wrote:
> These asserts were vestigial from the previous linux-generic buffer
> implementation where the buffer structs were packed within buffer pools and
> hence needed to be padded to ensure 8-byte alignment.  In the current
> implementation buffers are separately cache-aligned via the stride mechanism
> so the size of the individual buffer headers is irrelevant. That's a cleaner
> approach since the effect is maintenance can add whatever it needs to the
> individual headers for new metadata items, etc. and the alignment is
> adjusted automatically.
>
> In the case of 32-bit implementations the pointers drop from 8 to 4 bytes
> and this made the individual headers not be multiples of 8, which is why the
> assert triggered.  But as noted, these structures are being cache aligned
> independent of their individual size so these asserts serve no purpose and
> can be safely deleted.
OK. Then I need to do that for the new timer implementation as well.

These type of things should have comments so you know why they are
needed and when it might no longer be needed. I was just keeping the
code building without knowing why this was needed.


>
> On Wed, Jan 7, 2015 at 8:13 AM, Ola Liljedahl <ola.liljedahl@linaro.org>
> wrote:
>>
>> On 7 January 2015 at 13:46, Bill Fischofer <bill.fischofer@linaro.org>
>> wrote:
>> > Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>
>> > ---
>> >  platform/linux-generic/include/odp_buffer_internal.h | 3 ---
>> >  1 file changed, 3 deletions(-)
>> >
>> > diff --git a/platform/linux-generic/include/odp_buffer_internal.h
>> > b/platform/linux-generic/include/odp_buffer_internal.h
>> > index 60f06c9..c64802b 100644
>> > --- a/platform/linux-generic/include/odp_buffer_internal.h
>> > +++ b/platform/linux-generic/include/odp_buffer_internal.h
>> > @@ -136,9 +136,6 @@ typedef struct odp_buffer_hdr_t {
>> >  typedef struct odp_buffer_hdr_stride {
>> >         uint8_t
>> > pad[ODP_CACHE_LINE_SIZE_ROUNDUP(sizeof(odp_buffer_hdr_t))];
>> >  } odp_buffer_hdr_stride;
>> > -/* Ensure next header starts from 8 byte align */
>> > -_ODP_STATIC_ASSERT((sizeof(odp_buffer_hdr_t) % 8) == 0,
>> > -                  "ODP_BUFFER_HDR_T__SIZE_ERROR");
>> Is this the preferred solution?
>> Do we have any alignment requirements on internal headers? Why was
>> this assert added to start with?
>> For the timer/timeout internal header I had to add 32-bit of padding
>> in order to make an equivalent static assert succeed. But perhaps the
>> assert is the problem?
>>
>> >
>> >  typedef struct odp_buf_blk_t {
>> >         struct odp_buf_blk_t *next;
>> > --
>> > 2.1.0
>> >
>> >
>> > _______________________________________________
>> > lng-odp mailing list
>> > lng-odp@lists.linaro.org
>> > http://lists.linaro.org/mailman/listinfo/lng-odp
>
>
Bill Fischofer Jan. 7, 2015, 3:30 p.m. UTC | #4
The current timer code was updated to use stride mechanism so if you
delta'd off of it you should already have it.  The only issue here is
deleting these stale asserts.

On Wed, Jan 7, 2015 at 9:25 AM, Ola Liljedahl <ola.liljedahl@linaro.org>
wrote:

> On 7 January 2015 at 15:19, Bill Fischofer <bill.fischofer@linaro.org>
> wrote:
> > These asserts were vestigial from the previous linux-generic buffer
> > implementation where the buffer structs were packed within buffer pools
> and
> > hence needed to be padded to ensure 8-byte alignment.  In the current
> > implementation buffers are separately cache-aligned via the stride
> mechanism
> > so the size of the individual buffer headers is irrelevant. That's a
> cleaner
> > approach since the effect is maintenance can add whatever it needs to the
> > individual headers for new metadata items, etc. and the alignment is
> > adjusted automatically.
> >
> > In the case of 32-bit implementations the pointers drop from 8 to 4 bytes
> > and this made the individual headers not be multiples of 8, which is why
> the
> > assert triggered.  But as noted, these structures are being cache aligned
> > independent of their individual size so these asserts serve no purpose
> and
> > can be safely deleted.
> OK. Then I need to do that for the new timer implementation as well.
>
> These type of things should have comments so you know why they are
> needed and when it might no longer be needed. I was just keeping the
> code building without knowing why this was needed.
>
>
> >
> > On Wed, Jan 7, 2015 at 8:13 AM, Ola Liljedahl <ola.liljedahl@linaro.org>
> > wrote:
> >>
> >> On 7 January 2015 at 13:46, Bill Fischofer <bill.fischofer@linaro.org>
> >> wrote:
> >> > Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>
> >> > ---
> >> >  platform/linux-generic/include/odp_buffer_internal.h | 3 ---
> >> >  1 file changed, 3 deletions(-)
> >> >
> >> > diff --git a/platform/linux-generic/include/odp_buffer_internal.h
> >> > b/platform/linux-generic/include/odp_buffer_internal.h
> >> > index 60f06c9..c64802b 100644
> >> > --- a/platform/linux-generic/include/odp_buffer_internal.h
> >> > +++ b/platform/linux-generic/include/odp_buffer_internal.h
> >> > @@ -136,9 +136,6 @@ typedef struct odp_buffer_hdr_t {
> >> >  typedef struct odp_buffer_hdr_stride {
> >> >         uint8_t
> >> > pad[ODP_CACHE_LINE_SIZE_ROUNDUP(sizeof(odp_buffer_hdr_t))];
> >> >  } odp_buffer_hdr_stride;
> >> > -/* Ensure next header starts from 8 byte align */
> >> > -_ODP_STATIC_ASSERT((sizeof(odp_buffer_hdr_t) % 8) == 0,
> >> > -                  "ODP_BUFFER_HDR_T__SIZE_ERROR");
> >> Is this the preferred solution?
> >> Do we have any alignment requirements on internal headers? Why was
> >> this assert added to start with?
> >> For the timer/timeout internal header I had to add 32-bit of padding
> >> in order to make an equivalent static assert succeed. But perhaps the
> >> assert is the problem?
> >>
> >> >
> >> >  typedef struct odp_buf_blk_t {
> >> >         struct odp_buf_blk_t *next;
> >> > --
> >> > 2.1.0
> >> >
> >> >
> >> > _______________________________________________
> >> > lng-odp mailing list
> >> > lng-odp@lists.linaro.org
> >> > http://lists.linaro.org/mailman/listinfo/lng-odp
> >
> >
>
diff mbox

Patch

diff --git a/platform/linux-generic/include/odp_buffer_internal.h b/platform/linux-generic/include/odp_buffer_internal.h
index 60f06c9..c64802b 100644
--- a/platform/linux-generic/include/odp_buffer_internal.h
+++ b/platform/linux-generic/include/odp_buffer_internal.h
@@ -136,9 +136,6 @@  typedef struct odp_buffer_hdr_t {
 typedef struct odp_buffer_hdr_stride {
 	uint8_t pad[ODP_CACHE_LINE_SIZE_ROUNDUP(sizeof(odp_buffer_hdr_t))];
 } odp_buffer_hdr_stride;
-/* Ensure next header starts from 8 byte align */
-_ODP_STATIC_ASSERT((sizeof(odp_buffer_hdr_t) % 8) == 0,
-		   "ODP_BUFFER_HDR_T__SIZE_ERROR");
 
 typedef struct odp_buf_blk_t {
 	struct odp_buf_blk_t *next;