Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib/uklock: Remove the rwlock_{upgrade,downgrade} functions #1090

Closed

Conversation

mschlumpp
Copy link
Member

Prerequisite checklist

  • Read the contribution guidelines regarding submitting new changes to the project;
  • Tested your changes against relevant architectures and platforms;
  • Ran the checkpatch.uk on your commit series before opening this PR;
  • Updated relevant documentation.

Base target

  • Architecture(s): N/A
  • Platform(s): N/A
  • Application(s): N/A

Additional configuration

Description of changes

In the current form they impose very strong synchronization requirements, making it impossible to implement a more efficient read-write lock design.

Most rwlocks sidestep this by either using a weaker try_upgrade variant or having a separate lock_upgradable function (allowing multiple readers but only one upgradable lock/writer lock).

This removes these two functions for now to prevent new code relying on these functions. This change is breaking because it already was part of the previous release.

In the current form they impose very strong synchronization requirements,
making it impossible to implement a more efficient read-write lock design.

Most rwlocks sidestep this by either using a weaker `try_upgrade` variant
or having a separate `lock_upgradable` function (allowing multiple readers
but only one upgradable lock/writer lock).

This removes these two functions for now to prevent new code relying on
these functions. This change is breaking because it already was part of the
previous release.

Signed-off-by: Marco Schlumpp <marco@unikraft.io>
@mschlumpp mschlumpp requested a review from a team as a code owner September 12, 2023 11:27
@unikraft-bot
Copy link
Member

Checkpatch passed

Beep boop! I ran Unikraft's checkpatch.pl support script on your pull request and it all looks good!

SHA commit checkpatch
5b04e73 lib/uklock: Remove the rwlock_{upgrade,downgrade} functions

@unikraft-bot unikraft-bot added area/lib Internal Unikraft Microlibrary lang/c Issues or PRs to do with C/C++ lib/uklock labels Sep 12, 2023
@razvand razvand assigned razvand and unassigned nderjung Sep 27, 2023
@razvand razvand removed request for a team and craciunoiuc September 27, 2023 04:45
@razvand razvand added this to the v0.14.1 (Prometheus) milestone Sep 27, 2023
Copy link
Contributor

@andreittr andreittr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually considered using uk_rwlock_upgrade these past days in some code, but wasn't convinced the implementation guaranteed atomic upgrades (i.e. "cutting in front of the writer wait queue") and IMO in that case it's no different to runlock + wlock. That alone is a good argument for either a rewrite or removal.

However, if implementing atomic upgrades is performance-prohibitive as you suggest, then removing these functions now is the best call, before Unikraft components start relying on them (and we're in 0.x so the API is somewhat flexible). If we later really need upgradable locks, we can look into the alternatives you mentioned.

Thanks!

Reviewed-by: Andrei Tatar andrei@unikraft.io

Copy link
Contributor

@razvand razvand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved-by: Razvan Deaconescu razvand@unikraft.io

@razvand razvand closed this in 975aa92 Oct 3, 2023
@mschlumpp mschlumpp deleted the mschlumpp/fix/rwlock-upgrade branch October 6, 2023 09:08
razvand pushed a commit that referenced this pull request Oct 20, 2023
In the current form they impose very strong synchronization requirements,
making it impossible to implement a more efficient read-write lock design.

Most rwlocks sidestep this by either using a weaker `try_upgrade` variant
or having a separate `lock_upgradable` function (allowing multiple readers
but only one upgradable lock/writer lock).

This removes these two functions for now to prevent new code relying on
these functions. This change is breaking because it already was part of the
previous release.

Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Andrei Tatar <andrei@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1090
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/lib Internal Unikraft Microlibrary lang/c Issues or PRs to do with C/C++ lib/uklock
Projects
Status: Done!
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

5 participants