RFR: 8074101: Add verification that all tasks are actually claimed during roots processing

Kim Barrett kbarrett at openjdk.java.net
Tue Jan 12 17:16:55 UTC 2021


On Tue, 12 Jan 2021 15:02:27 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:

>> The first commit removes some obsolete enum items, while the second commit adds the verification logic. Commit 2 introduces some "empty" task claims for the verification logic, explicitly marked in the comments.
>> 
>> Test: hotspot_gc
>
> src/hotspot/share/gc/g1/g1RootProcessor.cpp line 66:
> 
>> 64:   // already processed in java roots.
>> 65:   _process_strong_tasks.try_claim_task(G1RP_PS_CodeCache_oops_do);
>> 66: #endif
> 
> Rather than these fake claims, consider something like this:
> 
> template<typename... Ts>
> void all_tasks_completed(uint nworkers, Ts... tags) {
>   // Type-check more_skipped are all of the same type as first_skipped.
>   T0 typed_skipped[] = { first_skipped, more_skipped... };
>   uint skipped[] = { static_cast<uint>(tags)... };
>   all_tasks_completed_impl(nworkers, skipped, ARRAY_SIZE(skipped));
> }
> 
> void all_tasks_completed(uint nworkers) {
>   all_tasks_completed_impl(nworkers, nullptr, 0);
> }
> 
> Usage:
> 
> all_tasks_completed(n_workers(),
>                     G1RP_PS_CodeCache_oops_do,
>                     G1RP_PS_refProcessor_oops_do)
> 
> all_tasks_completed_impl can check that all tasks have been claimed except
> the skipped ones, which have not been claimed.
> 
> There might be better ways to write the variadic all_tasks_completed.  It's
> been a while since I've done anything with variadic templates.

Here's a better version of the variadic `all_tasks_completed`

template<typename T0, typename... Ts,
         ENABLE_IF(Conjunction<std::is_same<T0, Ts>...>::value)>
void all_tasks_completed(uint n_threads, T0 first_skipped, Ts... more_skipped) {
  static_assert(std::is_convertible<T0, uint>::value, "not convertible");
  uint skipped[] = { static_cast<uint>(first_skipped), static_cast<uint>(more_skipped)... };
  all_tasks_completed_impl(n_threads, skipped, ARRAY_SIZE(skipped));
}
`Conjunction` is in metaprogramming/logical.hpp.

-------------

PR: https://git.openjdk.java.net/jdk/pull/2046



More information about the hotspot-gc-dev mailing list