从无代码KEXT迁移到DEXT后的性能问题 [英] Performance issue after migrating from codeless KEXT to DEXT
问题描述
我正在将无代码KEXT迁移到DriverKit.用于为在固件升级模式下显示为符合HID的USB设备禁用IOKit HID驱动程序.
I am working on migrating a codeless KEXT to DriverKit. It is used to disable the IOKit HID driver for USB devices that present themselves as HID compliant in firmware upgrade mode.
到目前为止,我已经设法将IOService
的空子类与相关设备进行匹配.
这是我正在使用的IOKitPersonalities
条目的示例:
So far I have managed to match an empty subclass of IOService
to the relevant devices.
Here's an example of the IOKitPersonalities
entries I'm using:
<dict>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleIdentifierKernel</key>
<string>com.apple.kpi.iokit</string>
<key>IOClass</key>
<string>IOUserService</string>
<key>IOProviderClass</key>
<string>IOUSBHostInterface</string>
<key>IOResourceMatch</key>
<string>IOKit</string>
<key>IOUserClass</key>
<string>DriverKitTestExtension</string>
<key>IOUserServerName</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>bConfigurationValue</key>
<integer>1</integer>
<key>bInterfaceNumber</key>
<integer>0</integer>
<key>idVendor</key>
<integer><!-- USB Vendor ID --></integer>
<key>idProduct</key>
<integer><!-- USB Product ID --></integer>
</dict>
使用IOUSBHostInterface
作为此用例的提供程序类是否正确?我也尝试过使用旧的(不推荐使用的)IOUSBInterface
,但是它与IOUSBHostInterface
一样存在相同的问题.
Is it correct to use IOUSBHostInterface
as the provider class for this use case? I've also tried using the old (deprecated) IOUSBInterface
, but it has the same problems as IOUSBHostInterface
.
新的DEXT正在运行,但是我在固件更新代码中看到一些不良的性能下降.调用libusb花费数十秒钟.如果我使用旧的KEXT,它们会立即返回.
The new DEXT is working but I am seeing some bad performance regressions in our firmware update code. Calls to libusb are taking tens of seconds. If I use the old KEXT, they return immediately.
以下是该问题的一些示例痕迹:
Here are some example traces of the problem:
5 redacted 3168.0 libusb_claim_interface ..../libusb/Sources/libusb/core.c:1310
4 redacted 3168.0 darwin_claim_interface ..../libusb/Sources/libusb/darwin_usb.c:1089
3 IOUSBLib 1668.0 IOUSBInterfaceClass::USBInterfaceOpen(bool)
2 IOKit 1668.0 io_service_wait_quiet
1 libsystem_kernel.dylib 1668.0 mach_msg
0 libsystem_kernel.dylib 1668.0 mach_msg_trap
并且:
7 redacted 1859.0 libusb_get_device_list ..../libusb/Sources/libusb/core.c:632
6 redacted 1859.0 darwin_get_device_list ..../libusb/Sources/libusb/darwin_usb.c:780
5 redacted 1859.0 process_new_device ..../libusb/Sources/libusb/darwin_usb.c:726
4 redacted 1766.0 darwin_check_configuration ..../libusb/Sources/libusb/darwin_usb.c:540
3 IOKit 1766.0 IOIteratorNext
2 IOKit 1766.0 io_iterator_next
1 libsystem_kernel.dylib 1766.0 mach_msg
0 libsystem_kernel.dylib 1766.0 mach_msg_trap
0 libsystem_kernel.dylib 1766.0 mach_msg_trap
这些记录在启用了记录等待线程"的"Time Profiler"工具中.
These are recorded in the "Time Profiler" instrument with "Record Waiting Threads" enabled.
我可以在DEXT中做任何事情来解决此问题吗?我已经尝试将IOUSBHostInterface
而不是IOService
继承为子类,但这没什么区别.
Can I do anything in the DEXT to fix this problem? I've tried subclassing IOUSBHostInterface
instead of IOService
, but that made no difference.
这是运行"ioreg -lirc IOUSBHostInterface"的相关输出:
Here's the relevant output from running "ioreg -lirc IOUSBHostInterface":
+-o IOUSBHostInterface@0
| {
| "USBSpeed" = 1
| "iInterface" = 0
| "IOServiceLegacyMatchingRegistryID" = 4294971983
| "bInterfaceProtocol" = 0
| "bAlternateSetting" = 0
| "idProduct" =
| "bcdDevice" = 292
| "USB Product Name" =
| "locationID" = 338690048
| "bInterfaceClass" = 3
| "bInterfaceSubClass" = 0
| "IOCFPlugInTypes" = {"2d9786c6-9ef3-11d4-ad51-000a27052861"="IOUSBHostFamily.kext/Contents/PlugIns/IOUSBLib.bundle"}
| "USBPortType" = 0
| "bConfigurationValue" = 1
| "bInterfaceNumber" = 0
| "USB Vendor Name" =
| "IOServiceDEXTEntitlements" = (("com.apple.developer.driverkit.transport.usb"))
| "idVendor" =
| "bNumEndpoints" = 2
| "IOGeneralInterest" = "IOCommand is not serializable"
| "IOClassNameOverride" = "IOUSBInterface"
| }
|
+-o DriverKitTestExtension
{
"IOClass" = "IOUserService"
"CFBundleIdentifier" =
"IOProviderClass" = "IOUSBHostInterface"
"IOUserServerCDHash" = "faa70138281d36b53946591685ccdceba4a5d638"
"idProduct" =
"IOResourceMatch" = "IOKit"
"bConfigurationValue" = 1
"IOProbeScore" = 90000
"IOMatchCategory" = "com.apple.null.driver"
"IOUserServerName" =
"IOMatchedPersonality" = {"IOClass"="IOUserService","CFBundleIdentifier"=" ","IOProviderClass"="IOUSBHostInterface","IOUserServerCDHash"="faa70138281d36b53946591685ccdceba4a5d638","idProduct"=,"IOResourceMatch"="IOKit","bConfigurationValue"=1,"IOMatchCategory"="com.apple.null.driver","IOUserServerName"=,"idVendor"=,"CFBundleIdentifierKernel"="com.apple.kpi.iokit","bInterfaceNumber"=0,"IOUserClass"="DriverKitTestExtension"}
"idVendor" =
"CFBundleIdentifierKernel" = "com.apple.kpi.iokit"
"bInterfaceNumber" = 0
"IOUserClass" = "DriverKitTestExtension"
}
欢迎任何输入!
推荐答案
我终于找到了问题!阅读如何设置`com.apple.developer. driverkit.transport.usb的权利?,我决定尝试使用DEXT的权利.这让我意识到DEXT根本没有被加载.
I finally found the problem! After reading How to set `com.apple.developer.driverkit.transport.usb` entitlement?, I decided to experiment with the entitlements for my DEXT. This made me realize that the DEXT was not being loaded at all.
我从以下位置更改了DEXT权利:
I changed the DEXT entitlements from:
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.developer.driverkit</key>
<true/>
<key>com.apple.developer.driverkit.transport.usb</key>
<true/>
</dict>
</plist>
收件人:
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.developer.driverkit</key>
<true/>
<key>com.apple.developer.driverkit.transport.usb</key>
<array>
<dict>
<key>idVendor</key>
<integer><!-- USB Vendor ID --></integer>
</dict>
</array>
</dict>
</plist>
此后,现在显示来自我的IOService
子类的日志消息(将log stream
与grep
结合使用).固件升级期间的性能已恢复正常.
After this, the log message from my IOService
subclass is now showing up (using log stream
with grep
). Performance during the firmware upgrade is back to normal.
这篇关于从无代码KEXT迁移到DEXT后的性能问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!