microsoft / microsoft/perfview
LBR state is incorrect during nt!SwapContext
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 4.7k
- Forks
- 775
- Avg merge
- 5d 11h
- Merged PRs (30d)
- 9
Description
I've been playing around with -LbrSources:PmcInterrupt -LbrFilters:StackMode data and about ~0.1% of the LBR records are attributed to the wrong process.
In my investigation of these misattributed LBR records, execution is always somewhere in nt!SwapContext
Even worse, if I try to emit the LBR stacks for ContextSwitch events then these are 100% attributed to the wrong process.
The steps currently taken in SwapContext appear to be -
- Perform context swap - the LBR stack is now invalid for the current thread
- Trace context swap - the associated LBR event is always attributed to the wrong thread here
- Clear LBR stack - the (empty) LBR stack is now valid again
And any PmcInterrupt events occurring between 1 and 3 will be attributed to the wrong thread.
I would have thought that the tracing then clearing would need to occur immediately prior to the context swap -
- Trace context swap - the LBR stack is still valid here
- Clear LBR stack
- Perform context swap
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by investigating the ordering of context switching, context-switch tracing, and LBR clearing in nt!SwapContext, using the PmcInterrupt and ContextSwitch observations in the issue. Done means LBR records and emitted ContextSwitch stacks are attributed to the correct process and thread, including events occurring during the swap sequence.
Written by the indexing model from the issue text.
Assessment
- Domain
- operating-systems, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100