I had similar issue with VS2022.
I went to "Tools -> Options -> Debugging -> General", the option "Enabled Just My Code" was disabled, I could debug "external code", but it did not work for performance profiler.
Then I discovered in "Performance Report" window, there is "Settings -> Show Just My Code" option, and these "Just My Code" settings were not synchronized(it was checked by default). After disabling it, I can analyze "external code".