|
From: Jenkins, L. <lje...@ur...> - 2020-02-29 02:47:13
|
Hello developers, I was wondering if anyone could help me with a bit of a problem I was experiencing a while ago. I have a Valgrind plugin that acts to simulate the problem having persistent memory (NVRAM) and a volatile cache (i.e. Intel's Optane DC NVDIMMs). I maintain a shadow region of memory that the user is interested in, and I have put into place mechanisms that reorder writes to the shadow memory (file-backed shadow region) in a similar fashion to how the hardware handles such writes to persistent memory. Now, this shadow region must be _verified_ by the user every now and then, so a user-provided verification function is called when simulating a power failure. I want this verification function to be callable from _inside_ of Valgrind, say in some fork. Right now, I have to escape the Valgrind VM by forcing the user to write a separate process to that is `execv`'d from some fork. This is not only _very_ inconvenient, but also extremely slow and it does not leverage itself to being parallelized due to requiring isolation of the shadow region (i.e. I need to copy the shadow region each time to allow it to be processed in parallel with the program continuing to run). Last time I tried naively calling a user-provided callback, passed through one of the Valgrind client requests, it would segfault after returning from a system call invoked in the guest function; something about being in an incorrect state. I am wondering if there is some procedure that must be called prior to invoking client code that will result in Valgrind switching to guest and back to host. If there is no official way to do this, is there a more 'hacky' way of doing this? I would very much so appreciate any assistance with this; if I could get a feature like this working, it would not only significantly speed up performance, but make it a _lot_ easier to use the tool as well. |