Skip to contentSkip to conversation

Locking in lib/boilerplate/hash.c

Xenomai Jan Kiszka 2 participants 4 messages Apr 11, 2018 – Apr 12, 2018

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

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

Signature · 2 lines
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux
author
#1 lore raw
Quoted 10 lines · Jan Kiszka

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.

Quoted 2 lines

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

Signature · 2 lines
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux
#2 lore raw
In reply to Jan Kiszka
Quoted 10 lines · Jan Kiszka

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.

Quoted 3 lines

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.

Signature · 1 line
Philippe.
author
#3 lore raw
Quoted 15 lines · Philippe Gerum
Quoted 10 lines · Jan Kiszka

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.

Quoted 3 lines

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

Quoted 6 lines

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

Signature · 2 lines
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux