2008-06-07 14:48:34

by Manfred Spraul

[permalink] [raw]
Subject: Re: [PATCH 1/4] ipc/sem.c: convert undo structures to struct list_head

Nadia Derbey wrote:
> Manfred Spraul wrote:
>> The undo structures contain two linked lists, the
>> attached patch replaces them with generic struct list_head lists.
>
> If I'm not wrong the undo list is a singly-linked list.
> So here we are moving from a set of 4 pointers to a set of 8 pointers.
> It's true that this makes the code much much more readable and clear,
> but I was wondering if it's worth?
>
IMHO yes: Everything is allocated on demand and memory is not that
expensive.

With regard to the asserts: I'm a big fan of asserts, I usually use them
to document the locking.
Perhaps assert_spin_locked() should evalute to a nop() for
non-CONFIG_DEBUG builds?

--
Manfred


2008-06-09 06:55:34

by Nadia Derbey

[permalink] [raw]
Subject: Re: [PATCH 1/4] ipc/sem.c: convert undo structures to struct list_head

Manfred Spraul wrote:
> Nadia Derbey wrote:
>
>> Manfred Spraul wrote:
>>
>>> The undo structures contain two linked lists, the
>>> attached patch replaces them with generic struct list_head lists.
>>
>>
>> If I'm not wrong the undo list is a singly-linked list.
>> So here we are moving from a set of 4 pointers to a set of 8 pointers.
>> It's true that this makes the code much much more readable and clear,
>> but I was wondering if it's worth?
>>
> IMHO yes: Everything is allocated on demand and memory is not that
> expensive.
>
> With regard to the asserts: I'm a big fan of asserts, I usually use them
> to document the locking.

And you're completely right: when I see your new semaphore code, we can
easily see what is the lock needed to protect a given field.

> Perhaps assert_spin_locked() should evalute to a nop() for
> non-CONFIG_DEBUG builds?

Well, it's unconditionally defined as a BUG_ON(!spin_is_locked())

Regards,
Nadia