-
Notifications
You must be signed in to change notification settings - Fork 41
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
KM XDPAPI prototype #409
base: main
Are you sure you want to change the base?
KM XDPAPI prototype #409
Conversation
Some results comparing the user-mode and kernel-mode APIs that were taken on a physical machine. The difference is mostly insignificant, which would be expected. perf suite commands:
PS N:\repos\xdp-for-windows> .\tools\xskperfcompare.ps1 -DataFile1 N:\shared\nigri\httpperf\xskperfsuite-user.csv -DataFile2 N:\shared\nigri\httpperf\xskperfsuite-kernel-cleaned.csv *xskperfsuite-kernel-cleaned.csv as I had to undo the "KERNEL" added to the test case name in order for xskperfcompare to do its thing. |
|
||
inline | ||
VOID | ||
PlatWaitThread(PLAT_THREAD *P, ULONG TimeoutMs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we take a dependency on the CxPlat library used by MsQuic/usersim?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, not yet. We haven't done all the refactoring to move stuff into microsoft/cxplat yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That cxplat repository looks stale. SHould we take a dependency on / contribute to https://github.com/microsoft/usersim/tree/main/cxplat ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nibanks / @mtfriesen ^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, don't add any extra dependencies yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, why not? A dependency seems better than duplicating code to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I have the context now that providing facilities in cxplat is the end goal, but it just hasn't been prioritized yet. I think we can cheaply add a cxplat copy into xdp now and migrate to the proper cxplat once it is in place. This avoids any extra work adding and then untangling a temporary dependency on usersim.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nibanks This is being brought up again. cxplat copies are littered throughout microsoft github repositories (msquic, ebpf-for-windows, usersim, ntosebpfext, win-net-test). Adding another in xdp brings the count higher than can be counted on one hand. What is the tipping point here? Would it be reasonable to start populating the cxplat repo with what xdp needs and have xdp be the first consumer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I absolutely want to move stuff there, but just don't have the time. But I do think we've reached that tipping point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can start this work by bringing in the cxplat pieces that xdp needs. Other workstreams can contribute more to cxplat as needed and eliminate cxplat copies when ready/possible. Does that seem like a reasonable plan?
Should |
src/xdp/xsk.c
Outdated
goto Exit; | ||
} | ||
if (RequestorMode != KernelMode) { | ||
Umem->Mapping.Mdl = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we always need an MDL, or at least need it if the bounce buffer is disabled and the underlying interface uses the MDL extension? Should be easy to repro a bugcheck if the XskDisableTxBounce
regkey is set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. Needs a test case though
15f1845
to
4f336a7
Compare
4f336a7
to
4feff6d
Compare
</Link> | ||
</ItemDefinitionGroup> | ||
<Target Name="BuildCxPlat" BeforeTargets="PrepareForBuild"> | ||
<MSBuild Projects="$(SolutionDir)submodules\cxplat\src\lib\cxplat.kernel.vcxproj" Properties="UndockedOut=$(OutDir)cxplat\"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm, we need to find a way to not build cxplat multiple times. we probably need to create a single dummy project in xdp now that it's being referenced in multiple places.
8436a65
to
7ec7922
Compare
|
||
inline | ||
NTSTATUS | ||
XdpNmrClientDetachProvider( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to MSDN this may be called at DISPATCH_LEVEL
. This means we must not use locks that require PASSIVE_LEVEL
, right?
Also, for the question of client cleaning up in the Detach
call, that means it could not wait for cleanup, right? That seems weird, to require clean up always supporting DISPATCH_LEVEL
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also in the documentation, a client can return STATUS_PENDING and then call NmrClientDetachProviderComplete at a later time. Client "cleanup" logic can be moved to ClientCleanupBindingContext which happens after both client and provider have completed detach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I understand, it is possible to use PASSIVE_LEVEL lock with DISPATCH_LEVEL function.
If multiple level components are mixed, lower level IRQL need to be used. PASSIVE_LEVEL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is possible, but the code will be inherently buggy. NickB is correct that we must not use passive level locks. Windows Internals is a highly recommended resource for this concept, I'll send a link offline
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clientDetachProvider and providerDetachClient are called at dispatch level only when you deregister client/provider at dispatch level. If we have not treated these as functions that can be called at dispatch elsewhere in xdp like XdpNmrClientDetachProvider, why do we care now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I understand, it is possible to use PASSIVE_LEVEL lock with DISPATCH_LEVEL function.
As NickG mentioned, you cannot use a passive lock at DISPATCH_LEVEL (because the lock can block/wait, which isn't allowed at dispatch). But you can use a dispatch lock at PASSIVE_LEVEL.
clientDetachProvider and providerDetachClient are called at dispatch level only when you deregister client/provider at dispatch level. If we have not treated these as functions that can be called at dispatch elsewhere in xdp like XdpNmrClientDetachProvider, why do we care now?
The NMR interface is generically defined to allow DISPATCH_LEVEL. My preference would be to not impose restrictions based on some assumptions for how XDP uses the interface today. What if XDP needs to be updated to deregister at dispatch in the future? @mtfriesen any opinion here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For code that is compiled into 3rd party code rather than something we own ourselves, we should do the right thing. IMO we should also fix code in XDP that makes incorrect assumptions about IRQL, but do that in a separate PR.
7ec7922
to
d5c8b5a
Compare
d47c5ba
to
88c561f
Compare
88c561f
to
b602c03
Compare
* unified close handle api * add one more API to XDP_FILE_DISPATCH * XdpDeleteProgram to follow the change, fix static annotations
KM XDPAPI prototype + hacks to test with xskbench and measure perf