Re: [PATCH v6 3/3] KVM: selftests: randomize page access order

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Sean Christopherson <seanjc@xxxxxxxxxx> writes:

On Tue, Oct 11, 2022, Colton Lewis wrote:
Sean Christopherson <seanjc@xxxxxxxxxx> writes:
> Ya, I'm trippling (quadrupling?) down on my suggestion to improve the
> APIs.  Users
> should not be able to screw up like this, i.e. shouldn't need comments
> to warn
> readers, and adding another call to get a random number shouldn't affect
> unrelated
> code.

Previous calls to PRNGs always affect later calls to PRNGs. That's how
they work.

Ya, that's not the type of bugs I'm worried about.

This "screw up" would be equally likely with any API because the caller
always needs to decide if they should reuse the same random number or need a
new one.

I disagree, the in/out parameter _requires_ the calling code to store the random number in a variable. Returning the random number allows consuming the number
without needing an intermediate variable, e.g.

	if (random_bool())
		<do stuff>

which makes it easy to avoid an entire class of bugs.

Yes, but it's impossible to do this without hidden global state at the
implementation level. That sacrifices reentrancy and thread-safety.

Maybe that's an acceptable sacrifice, but I'd prefer an obvious pitfall
over a subtle one.



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux