Linus Torvalds writes: (Summary) I'm not entirely sure this matters much, but it certainly isn't
wrong either.
wrong either.
The reason I'm not 100% convinced this matters is that gcc can *still* mess things up for us by simply adding conditionals elsewhere. foo) { idx = array_idx_nospec(idx, foo); With the volatile on the array_idx_nospec(), we're guaranteed to use the right reduced idx, and there's only one user, so we're all good. We're not going to plug every theoretical hole, and I think the hole that the volatile plugs is theoretical, not practical.
wrong either.
The reason I'm not 100% convinced this matters is that gcc can *still* mess things up for us by simply adding conditionals elsewhere. foo) { idx = array_idx_nospec(idx, foo); With the volatile on the array_idx_nospec(), we're guaranteed to use the right reduced idx, and there's only one user, so we're all good. We're not going to plug every theoretical hole, and I think the hole that the volatile plugs is theoretical, not practical.