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

Commits on Feb 16, 2023

  1. CA-375276: xenctrlext_stubs.c: xc_get_last_error is not thread safe, …

    …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>
    edwintorok committed Feb 16, 2023
    Configuration menu
    Copy the full SHA
    4077bf5 View commit details
    Browse the repository at this point in the history
  2. [maintenance] xa_auth_stubs.c: move free inside the blocking section

    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>
    edwintorok committed Feb 16, 2023
    Configuration menu
    Copy the full SHA
    f601c89 View commit details
    Browse the repository at this point in the history
  3. CA-375277: xenctrlext_stubs.c: add missing enter/leave blocking section

    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>
    edwintorok committed Feb 16, 2023
    Configuration menu
    Copy the full SHA
    a7cf4ff View commit details
    Browse the repository at this point in the history
  4. CA-375277: unixpwd_stubs.c: factor out common code and use enter/leav…

    …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>
    edwintorok committed Feb 16, 2023
    Configuration menu
    Copy the full SHA
    6b386b8 View commit details
    Browse the repository at this point in the history
  5. C stubs: add a .clang-format

    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 committed Feb 16, 2023
    Configuration menu
    Copy the full SHA
    8545741 View commit details
    Browse the repository at this point in the history