Repository navigation
Add some kfd ioctl decoding - #236
ZenithalHourlyRate wants to merge 4 commits into
Conversation
| case 'K': | ||
| return kd_ioctl(tcp, code, arg); | ||
| /* FIXME: this is ugly, and wont work forever */ | ||
| if (_IOC_NR(code) >= _IOC_NR(KIOCSOUND)) { |
There was a problem hiding this comment.
Though I didn't finish revising after reviewing, the patch I proposed in https://lists.strace.io/pipermail/strace-devel/2022-March/010996.html adds the ability to distinguish the type of file descriptors to strace. Just comment.
|
On Thu, Feb 09, 2023 at 08:21:08PM -0800, Masatake YAMATO wrote:
Though I didn't finish revising after reviewing, the patch I proposed in https://lists.strace.io/pipermail/strace-devel/2022-March/010996.html adds the ability to distinguish the type of file descriptors to strace. Just comment.
By the way, do you have any plans revisiting that series?
|
Yes, I'm revising now. I'm also interested in kfd. So I would like to make my patches working well with this pull request. |
|
@ZenithalHourlyRate @ldv-alt However, the development of the patchset was staneeded morenot find enough timestrafe'srstand strace's printing routines and TTY layers of Linux. So I will split the patchset into two, and I will focus on the A part. Could you see https://github.com/masatake/strace/commits/finfo-v0 especially |
|
The main problem with this PR is the absence of tests for the new ioctl decoder. |
To be honest, I think your original patchset was closer to be merged because, unlike this PR, it contained tests. |
* NEWS: mention this change * bundled/Makefile.am: include new file * bundled/linux/include/uapi/linux/kfd_ioctl.h: new file from Linux 6.1 * src/Makefile.am: include new file * src/defs.h: declare kfd ioctl * src/ioctl.c: redirect ioctl decoding to kfd_ioctl * src/kfd_ioctl.c: new file * src/xlat/kfd_alloc_mem_flags.in: flags from header * src/xlat/kfd_cache_policy.in: likewise * src/xlat/kfd_event_type.in: likewise * src/xlat/kfd_queue_type.in: likewise TODOs in this patch will not be addressed in this patchset. They could be implemented later when I get the time. Signed-off-by: Hongren (Zenithal) Zheng <i@zenithal.me>
Signed-off-by: Hongren (Zenithal) Zheng <i@zenithal.me>
b3f04d1 to
357f62e
Compare
I have added tests now. The data in the tests are collected from my GPU program and I used a script to generate the test functions. ioctls that my GPU program does not call are now deleted and wont be addressed in this patchset due to a limited time budget. They have beed splitted to kfd-dev branch and anyone interested could add tests for them and get them upstreamed.
I've tested this branch on my machine and it worked. I am marking this PR as ready for review now. The FIXME mentioned above could be addressed if masatake's patchset get merged first, but I'll leave it for now. |
* bundled/Makefile.am: include new file * bundled/linux/include/uapi/drm/drm.h: new file from Linux 6.1, stripped __user * bundled/linux/include/uapi/drm/drm_mode.h: new file from Linux 6.1
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #236 +/- ##
==========================================
+ Coverage 90.09% 90.23% +0.13%
==========================================
Files 289 290 +1
Lines 24877 25225 +348
==========================================
+ Hits 22414 22761 +347
- Misses 2463 2464 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Can I see the script?
I would like to try to push your efforts to the upstream. The parts of my patches were merged into These two patches are needed: masatake@2aa88bd @ldv-alt Should I use strace-list to get your review? or can I use this GitHub interface? |
https://gist.github.com/ZenithalHourlyRate/3eb418e2ab231c81ca8a7975b6dad07d |
|
@ZenithalHourlyRate Thanks. |
I prefer the mailing list, but I can cope with the github interface, too. |
|
I've gone through the new finfo interface, there are some questions regarding how it can be used for kfd ioctl decoding In
The leaving stage problem can be resolved by changing the logic in In summary, there must be some fallback ways to distinguish kfd and kd, and the code looks like this And the current ugly hack can not be avoided. Since we always need a fallback way, and there is actualy no overlap for now, I think kfd/kd distinguish can just use the hacky way for now to reduce the complexity. In the future when there are overlaps, finfo could be used. |
|
See the last three commits at https://github.com/masatake/strace/commits/kfd.
Basically, I agree with you.
|
@ldv-alt How do you think about it. |
kfd (/dev/kfd) is an interface exposed by amdgpu kernel driver for user space drivers (e.g. ROCm)
FIXME
KD and KFD both use the 'K' base. Fortunately they currently do not overlap and can be distinguished from NR. However, as KFD is gradually adding ioctls, one day they may overlap.
More generously, how do we decode ioctls arg with the same base? We already have
ioctl_next_matchfor displaying ioctls with the same code, do we have similar mechanisms?Note
TODOs in code will not be addressed in this patchset. They could be implemented later when I get the time.
Also, the variable length array handling for
struct kfd_ioctl_svm_attribute attrs[];could be generalized to e.g.defs.hthenprint_field.h. I thinktfetch_objafter the end of the struct is quite unsafe. If kernel returned an invalidnattr, e.g. -1, then we will access the whole memory. What's your opinion on this.TODO