...
Add new "busy" state to wperf-driver
See
for more Jira related information about this feature.Jira Legacy server System JIRA serverId 59107c6f-1e52-32bc-b58f-400d54bba998 key WPERF-116
Goal of this feature
To introduce user-space propagated reliable information about
wperf-driver
current activity. This will allow users on multi-user systems to (at least) be aware of other WindowsPerf activity.To avoid corrupted and unreliable measurements.
Definition of done
Add new BUSY state functionality to the driver and the IOCTL protocol.
In
WPERF-116
we do not have to add special “transaction” business logic. For example we do not have to add any checks if we start counting if sampling is ongoing.We will add business logic and tests as a separate functionality.
Required bahaviour
Ultimatelly remove the call to
WdfDeviceInitSetExclusive
.Create a persistent structure inside
wperf-driver
that capture driver’s “transition” current state, like if it is sampling, counting, if PMU resources are available or not. We want to capture:[bool flag] If driver is currently “counting” or “sampling” - this will set BUSY state to true.
[IOCTL request no.] Current IOCTL being processed - this is useful to determine in user space if we are actually counting/timeline or sampling or doing some other work.
How IOCTL will set BUSY state?
Some IOCTL will set (and clear after IOCTL is finished) busy state during IOCTL handling only, e.g.
PMU_CTL_RESET
orIOCTL_PMU_CTL_QUERY_HW_CFG
. This is because these “transactions” are pending during IOCTL handle and end after.Some IOCTLs will set BUSY state
Not all IOCTLs may set bus state as some do not “set in motion” the driver.
Update to driver ↔︎ user-space protocol.
User-space should handle properly BUSY state of the driver. E.g. warn that “continuing” IOCTL is ongoing.
Please note this creates a “transaction” / “scenario” for WindowsPerf.
We will send to user-space new set of flags:
BUSY flag and at least info about which IOCTL is ongoing.
If BUSY state is true: IOCTL field is valid with IOCTL being processed now.
List of IOCTLs and BUSY state
State “names”:
transient - lasts only during IOCTL handle (inside
deviceControl()
call).continuing - lasts after IOCTL handle in
deviceControl
is “finished”, e.g. when we start counting.
IOCTL | BUSY state / notes |
---|---|
IOCTL_PMU_CTL_START | continuing |
IOCTL_PMU_CTL_STOP | transient |
IOCTL_PMU_CTL_RESET | transient |
IOCTL_PMU_CTL_QUERY_HW_CFG | transient |
IOCTL_PMU_CTL_QUERY_SUPP_EVENTS | transient |
IOCTL_PMU_CTL_QUERY_VERSION | transient |
IOCTL_PMU_CTL_ASSIGN_EVENTS | transient |
IOCTL_PMU_CTL_READ_COUNTING | transient |
IOCTL_DSU_CTL_INIT | transient |
IOCTL_DSU_CTL_READ_COUNTING | transient |
IOCTL_DMC_CTL_INIT | transient |
IOCTL_DMC_CTL_READ_COUNTING | transient |
IOCTL_PMU_CTL_SAMPLE_SET_SRC | transient |
IOCTL_PMU_CTL_SAMPLE_START | continuing |
IOCTL_PMU_CTL_SAMPLE_STOP | transient |
IOCTL_PMU_CTL_SAMPLE_GET |
...
transient |
Considerations
Name | |
---|---|
Changing our current protocol between driver and app inside Here for example https://gitlab.com/Linaro/WindowsPerf/windowsperf/-/blob/main/wperf/pmu_device.cpp?ref_type=heads#L2468 we check the size of the returned struct to check if it is valid or not (which we should be doing in other places btw) We can make similar checks for busy or incomplete requests. Later, as those information gets richer, we will be able to handle this better depending on what is happening inside the driver | |
I think I have an idea how it might look, the driver will need to track the active object (context) of the CreateFile() call, so that an IOCTLS relating to that object are suceeded, and any others sent back with the status set to 'busy' |