Re: [patch V2 08/16] x86/ioperm: Add bitmap sequence numberc
From: Thomas Gleixner
Date: Tue Nov 12 2019 - 04:55:30 EST
On Tue, 12 Nov 2019, Peter Zijlstra wrote:
> 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.
Actually with a global 64bit wide counter we can just avoid the pointer
comparison. Assumed a ioperm() syscall every nanosecond it takes about 584
years of uptime to wrap around. :)
Thanks,
tglx