Re: [patch V2 08/16] x86/ioperm: Add bitmap sequence number

From: Peter Zijlstra
Date: Tue Nov 12 2019 - 04:23:25 EST


On Mon, Nov 11, 2019 at 11:03:22PM +0100, Thomas Gleixner wrote:
> Add a globally unique sequence number which is incremented when ioperm() is
> changing the I/O bitmap of a task. Store the new sequence number in the
> io_bitmap structure and compare it along with the actual struct pointer
> with the one which was last loaded on a CPU. Only update the bitmap if
> either of the two changes. That should further reduce the overhead of I/O
> bitmap scheduling when there are only a few I/O bitmap users on the system.

> + /* Update the sequence number to force an update in switch_to() */
> + iobm->sequence = atomic64_add_return(1, &io_bitmap_sequence);

> + if (tss->last_bitmap != iobm ||
> + tss->last_sequence != iobm->sequence)
> + switch_to_update_io_bitmap(tss, iobm);

Initially I wondered why we need a globally unique sequence number if we
already check the struct iobitmap pointer. That ought to make the
sequence number per-object.

However, that breaks for memory re-use. So yes, we need that thing to be
global.