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

CA-391656: OCaml C stubs: release runtime lock around all xenctrl calls #4916

Draft
wants to merge 5 commits into
base: feature/perf
Choose a base branch
from

Conversation

edwintorok
Copy link
Contributor

There was a commit in the past that added enter/leave around all stubs, however since then more stubs got added, and not all of them released the runtime.

This is opened as draft, since it is a riskier change that needs a bit more stress testing too (not just a BST), and potentially also an improved static analyzer.

This PR builds on top of the C stub bugfix PR

Review only these 3 commits here:

854574107858b4443b5144d8e13de8bb8e2b334b (HEAD -> private/edvint/toolstack/improve-enter-leave, edwintorok/private/edvint/toolstack/improve-enter-leave) C stubs: add a .clang-format
6b386b8c6dc87d799bdbc23377042f1f9f649e33 CA-375277: unixpwd_stubs.c: factor out common code and use enter/leave blocking section where possible
a7cf4ff74db9a49a1aed670fb776e5c89ec00e38 CA-375277: xenctrlext_stubs.c: add missing enter/leave blocking section

edwintorok and others added 5 commits February 16, 2023 16:01
…use just errno which is

It is usually set to XC_INTERNAL_ERROR, except in xenguest, but we have no
bindings for that.

This API might get deleted in upstream Xen too: the error code is stored in the
xenctrl handle, but we made that global per process, and shared among all
threads. Which means that xenctrl calls from different threads can overwrite
each-others' error code.

Also do not use a 'static' buffer, this will no longer be thread safe with
OCaml 5.0 where the runtime lock is per domain instead of global.

Signed-off-by: Edwin Török <edvin.torok@citrix.com>
This is a C call, and might benefit from a bit more parallelism if it inside
the blocking section.

Signed-off-by: Edwin Török <edvin.torok@citrix.com>
Most of these calls pass only integers or pointers allocated in C,
so it is safe to release the OCaml runtime lock.

Replace direct passing of Xfm_val/Caml_ba_data_val with storing in a temporary
local variable (the result of Xfm_val or Caml_ba_data_val won't move since they
are C pointers, but the OCaml value passed in as params to these macros might!)

Signed-off-by: Edwin Török <edvin.torok@citrix.com>
…e blocking section where possible

unshadow is not thread safe, but the other ones should be.

TODO: double check all C API calls in unixpwd.c with the MT-safe portion of the manpage

Signed-off-by: Edwin Török <edvin.torok@citrix.com>
We may intend to upstream the xenctrlext stubs to Xen, so it should follow
the Xen CODING_STYLE.
The .clang-format here is based on a version I sent upstream that tries to
follow that coding style.

Signed-off-by: Edwin Török <edwin.torok@cloud.com>
@edwintorok edwintorok changed the base branch from master to feature/epoll February 15, 2024 10:58
@edwintorok edwintorok changed the base branch from feature/epoll to feature/perf February 15, 2024 14:21
@edwintorok
Copy link
Contributor Author

This PR has been open for more than a year with 0 comments.

@edwintorok
Copy link
Contributor Author

I should fix the conflicts here, and run the static analyzer. I'll keep the PR open meanwhile though.

@edwintorok edwintorok changed the title OCaml C stubs: release runtime lock around all xenctrl calls CA-391656: OCaml C stubs: release runtime lock around all xenctrl calls Apr 15, 2024
@edwintorok edwintorok closed this Apr 15, 2024
@robhoes robhoes reopened this Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants