Re: [v7 0/8] Reduce cross CPU IPI interference

From: Gilad Ben-Yossef
Date: Fri Feb 10 2012 - 15:25:00 EST


On Fri, Feb 10, 2012 at 8:38 PM, Peter Zijlstra <a.p.zijlstra@xxxxxxxxx> wrote:
> On Thu, 2012-02-02 at 10:41 -0500, Chris Metcalf wrote:
>>
>> /*
>>  * Quiesce the timer interrupt before returning to user space after a
>>  * system call.  Normally if a task on a dataplane core makes a
>>  * syscall, the system will run one or more timer ticks after the
>>  * syscall has completed, causing unexpected interrupts in userspace.
>>  * Setting DP_QUIESCE avoids that problem by having the kernel "hold"
>>  * the task in kernel mode until the timer ticks are complete.  This
>>  * will make syscalls dramatically slower.
>>  *
>>  * If multiple dataplane tasks are scheduled on a single core, this
>>  * in effect silently disables DP_QUIESCE, which allows the tasks to make
>>  * progress, but without actually disabling the timer tick.
>>  */
>> #define DP_QUIESCE      0x1
>
> This is what Frederics work does

Actually it's not quite the same I believe. Frederic's patch set
disables the tick
for an adaptive tick task at some timer tick interrupt after the
system call, but
the task doesn't know when that happens, so if timing determinism guarantee is
what you are after you don't quite know in your user task if its safe
to start doing
real time stuff or know.

If I understood Chris quote correctly, they hold the task in kernel
space until the
timer tick is off, so that when the user space task continues to run
after the system
call it can assume the tick is off.

Of course, nothing stops something (IPI?) from re-enabling it later,
but I guess it at least
lets you start in a known state.

I think the concept of giving the task some way to know if the tick is
disabled or not is nice.
Not sure the exact feature and surely not the interface are what we
should adopt - maybe
allow registering to receive a signal at the end of the tick when it
is disabled an re-enabled?

>
>>
>> /*
>>  * Disallow the application from entering the kernel in any way,
>>  * unless it calls set_dataplane() again without this bit set.
>>  * Issuing any other syscall or causing a page fault would generate a
>>  * kernel message, and "kill -9" the process.
>>  *
>>  * Setting this flag automatically sets DP_QUIESCE as well.
>>  */
>> #define DP_STRICT       0x2
>
> This is a debug feature.. you'd better know what your own software does.
>
>>
>> /*
>>  * Debug dataplane interrupts, so that if any interrupt source
>>  * attempts to involve a dataplane cpu, a kernel message and stack
>>  * backtrace will be generated on the console.  As this warning is a
>>  * slow event, it may make sense to avoid this mode in production code
>>  * to avoid making any possible interrupts even more heavyweight.
>>  *
>>  * Setting this flag automatically sets DP_QUIESCE as well.
>>  */
>> #define DP_DEBUG        0x4
>
> This too is a debug feature, one that doesn't cover all possible
> scenarios.

I like the idea of these but suspect a trace event is more suitable to
provide the same information.

>
>> /*
>>  * Cause all memory mappings to be populated in the page table.
>>  * Specifying this when entering dataplane mode ensures that no future
>>  * page fault events will occur to cause interrupts into the Linux
>>  * kernel, as long as no new mappings are installed by mmap(), etc.
>>  * Note that since the hardware TLB is of finite size, there will
>>  * still be the potential for TLB misses that the hypervisor handles,
>>  * either via its software TLB cache (fast path) or by walking the
>>  * kernel page tables (slow path), so touching large amounts of memory
>>  * will still incur hypervisor interrupt overhead.
>>  */
>> #define DP_POPULATE     0x8
>
> map()s MAP_POPULATE will pre-populate the stuff for you, as will
> mlock(), the latter will (mostly) ensure they stay around.
>

Yeap.


I think it's a collection of nice ideas that somehow got grouped together
under a specific interface and I guess we adopt the ideas but not neccisiarly
the implementation or interface:

- trace events for the debug notifications
- recommend mlock & friends for the VM stuff
- Perhaps a signal handler for tick notification?

Gilad

--
Gilad Ben-Yossef
Chief Coffee Drinker
gilad@xxxxxxxxxxxxx
Israel Cell: +972-52-8260388
US Cell: +1-973-8260388
http://benyossef.com

"If you take a class in large-scale robotics, can you end up in a
situation where the homework eats your dog?"
 -- Jean-Baptiste Queru
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/