All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai] Locking in lib/boilerplate/hash.c
@ 2018-04-11 11:11 Jan Kiszka
  2018-04-11 13:10 ` Jan Kiszka
  2018-04-12  9:03 ` Philippe Gerum
  0 siblings, 2 replies; 4+ messages in thread
From: Jan Kiszka @ 2018-04-11 11:11 UTC (permalink / raw)
  To: Philippe Gerum, Xenomai

Hi Philippe,

many users of the hash functions prefer (and actually have to) call
those services under an external lock to close race windows, e.g.
between lookup and entry usage. Still, those services come with their
own, internal lock. That seems to protect only the hash list, thus
leaves races on the entries open. I understand that some APIs (e.g.
psos) cannot solve that easily, but I wonder if the other users should
pay for the internal lock that is unneeded given an outer one.

IOW: How about pulling the internal lock out to the user, removing it
from hash.c?

Jan

-- 
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Xenomai] Locking in lib/boilerplate/hash.c
  2018-04-11 11:11 [Xenomai] Locking in lib/boilerplate/hash.c Jan Kiszka
@ 2018-04-11 13:10 ` Jan Kiszka
  2018-04-12  9:03 ` Philippe Gerum
  1 sibling, 0 replies; 4+ messages in thread
From: Jan Kiszka @ 2018-04-11 13:10 UTC (permalink / raw)
  To: Philippe Gerum, Xenomai

On 2018-04-11 13:11, Jan Kiszka wrote:
> Hi Philippe,
> 
> many users of the hash functions prefer (and actually have to) call
> those services under an external lock to close race windows, e.g.
> between lookup and entry usage. Still, those services come with their
> own, internal lock. That seems to protect only the hash list, thus
> leaves races on the entries open. I understand that some APIs (e.g.
> psos) cannot solve that easily, but I wonder if the other users should
> pay for the internal lock that is unneeded given an outer one.
> 
> IOW: How about pulling the internal lock out to the user, removing it
> from hash.c?

Also: __hash_init, which is also used for pvhash in case of !PSHARED if
I read the code correctly, does not set the mutex protocol to PI. That
could have a "surprising" impact for RT users.

I'm looking into this right now as I have a need here to switch these
locks to prio-ceiling, in order to bring down the test switching rate in
the worst case scenario.

Jan

-- 
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Xenomai] Locking in lib/boilerplate/hash.c
  2018-04-11 11:11 [Xenomai] Locking in lib/boilerplate/hash.c Jan Kiszka
  2018-04-11 13:10 ` Jan Kiszka
@ 2018-04-12  9:03 ` Philippe Gerum
  2018-04-12  9:14   ` Jan Kiszka
  1 sibling, 1 reply; 4+ messages in thread
From: Philippe Gerum @ 2018-04-12  9:03 UTC (permalink / raw)
  To: Jan Kiszka, Xenomai

On 04/11/2018 01:11 PM, Jan Kiszka wrote:
> Hi Philippe,
> 
> many users of the hash functions prefer (and actually have to) call
> those services under an external lock to close race windows, e.g.
> between lookup and entry usage. Still, those services come with their
> own, internal lock. That seems to protect only the hash list, thus
> leaves races on the entries open. I understand that some APIs (e.g.
> psos) cannot solve that easily, but I wonder if the other users should
> pay for the internal lock that is unneeded given an outer one.
> 
> IOW: How about pulling the internal lock out to the user, removing it
> from hash.c?
> 

You will need to move part of the locking to the cluster abstraction,
notably in pshared mode for protecting the shared object dictionary
(main_catalog).

Also, [pv]cluster_addobj* callers generally don't implement any outer
lock, so this should be addressed too.

-- 
Philippe.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Xenomai] Locking in lib/boilerplate/hash.c
  2018-04-12  9:03 ` Philippe Gerum
@ 2018-04-12  9:14   ` Jan Kiszka
  0 siblings, 0 replies; 4+ messages in thread
From: Jan Kiszka @ 2018-04-12  9:14 UTC (permalink / raw)
  To: Philippe Gerum, Xenomai

On 2018-04-12 11:03, Philippe Gerum wrote:
> On 04/11/2018 01:11 PM, Jan Kiszka wrote:
>> Hi Philippe,
>>
>> many users of the hash functions prefer (and actually have to) call
>> those services under an external lock to close race windows, e.g.
>> between lookup and entry usage. Still, those services come with their
>> own, internal lock. That seems to protect only the hash list, thus
>> leaves races on the entries open. I understand that some APIs (e.g.
>> psos) cannot solve that easily, but I wonder if the other users should
>> pay for the internal lock that is unneeded given an outer one.
>>
>> IOW: How about pulling the internal lock out to the user, removing it
>> from hash.c?
>>
> 
> You will need to move part of the locking to the cluster abstraction,
> notably in pshared mode for protecting the shared object dictionary
> (main_catalog).
> 
> Also, [pv]cluster_addobj* callers generally don't implement any outer
> lock, so this should be addressed too.

Yeah, by now I'm rather thinking about making locking optional for hash
services so that users can opt-out.

Jan

-- 
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-04-12  9:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-11 11:11 [Xenomai] Locking in lib/boilerplate/hash.c Jan Kiszka
2018-04-11 13:10 ` Jan Kiszka
2018-04-12  9:03 ` Philippe Gerum
2018-04-12  9:14   ` Jan Kiszka

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.