On 27 December 2011 23:12, Xin Tong <xerox.time.t...@gmail.com> wrote: > The reason I ask is that I am searching for alternatives to QEMU > current way of handling interrupt (unlink translation blocks on > interrupt). However, an obvious approach - checking for interrupt in > every basic block, seems to be too heavy ( too many tb enters/exits > ).
It's not awful -- an extra load-test-branch-not-taken per TB, which IIRC from last time I tried to measure it was ~3% speed penalty, obv. very variable with what the guest code is. I have a half-finished patch for this but since I don't have a decent benchmarking setup I've never got round to submitting it. > Maybe checking interrupt in a few basic blocks might be better, but > what is a good measure for the number of basic blocks to execute > before checking for interrupt ? The trouble is that you can't tell when you're translating the TB whether it's just one in a sequence A->B->C (where you could perhaps skip the check at the start of B), or if you're actually looking at a tight loop B->B (or B->C->B). So you don't have the information conveniently to hand to tell you whether you can skip compiling the interrupt check into this TB. (One heuristic for how often we need to check would be "every N instructions, or at every backwards branch or indirect-branch", but this doesn't fit with the idea of putting the checks at the start of the TB, they'd have to go in the middle of the TB which is probably awkward.) -- PMM