AMDGPU: scope hotswap trampolines and clamp entry prefetch#3195
Conversation
|
LIT tests are failing and seem genuine (?) |
6f1f253 to
cff7756
Compare
this should be fixed now. please take another look. |
| 7u); | ||
| KernelEntryStubInstPrefLines); | ||
| EXPECT_EQ( | ||
| AMDHSA_BITS_GET(OutRsrc3, hsa::COMPUTE_PGM_RSRC3_GFX11_INST_PREF_SIZE), |
There was a problem hiding this comment.
Should test with INST_PREF_SIZE for gfx12 rather than 11
There was a problem hiding this comment.
I have removed the gfx11 check. this now only checks the gfx12 inst_pref field.
| uint32_t MaxInstPrefLines = 0; | ||
| for (const KernelDescriptorInfo &KD : Descriptors) { | ||
| std::optional<uint32_t> InstPrefLines = | ||
| Elf.getKernelDescriptorInstPrefSize(KD.KernelName, LS.Cpu); |
There was a problem hiding this comment.
If I understand correctly, we have 2 different sources for the prefetch. Is that intentional ?
There was a problem hiding this comment.
this is intentional. deferred trampolines use the original kernel descriptor prefetch for the trailing guard. entry stubs clamp their own descriptor value separately. I added comments to make this clearer.
| Work.push_back(KD); | ||
| uint32_t StubInstPrefLines = | ||
| std::min(*InstPrefLines, KernelEntryStubInstPrefLines); | ||
| MaxInstPrefLines = std::max(MaxInstPrefLines, StubInstPrefLines); |
There was a problem hiding this comment.
If I understand correctly, there are now 2 sources for the prefetch value ? Can they disagree?
There was a problem hiding this comment.
they can disagree intentionally. the original value may be larger, but the entry stub descriptor is clamped to the 256-byte stub stride. I renamed this to make that explicit.
| if (Sled.WritePos > Sled.FunctionEnd || | ||
| Needed > Sled.FunctionEnd - Sled.WritePos) |
There was a problem hiding this comment.
I have folded this into one usable-end check.
| log() << "hotswap: error: trampoline prefetch guard size " << GuardBytes | ||
| << " exceeds size_t.\n"; | ||
| return false; | ||
| } |
There was a problem hiding this comment.
I have removed it. the guard size is bounded by the descriptor field here.
| TEST(FindNearestSled, SkipsSledsOutsideInstructionFunctionRange) { | ||
| std::vector<NopSled> Sleds; | ||
| Sleds.push_back({0, 32, 0, 0, 32}); | ||
| Sleds.push_back({96, 128, 96, 96, 160}); |
There was a problem hiding this comment.
// {Start, End, WritePos, FunctionStart, FunctionEnd}
Sleds.push_back({/*Start=*/96, /*End=*/128, /*WritePos=*/96,
/*FunctionStart=*/96, /*FunctionEnd=*/160});
There was a problem hiding this comment.
I have added field comments for the sled initializers.
cff7756 to
627fea4
Compare
627fea4 to
737d5a5
Compare
Summary
Depends on #3182. Review commit: d49d6b2.
Testing
build-asan,LLVM_USE_SANITIZER=Address;ASAN_OPTIONS=detect_leaks=0 LSAN_OPTIONS=detect_leaks=0due local LSan/ptrace limitation):