arch/sparc: Measure receiver forward progress to avoid send mondo timeout
PATCH 1/1 arch/sparc: Measure receiver forward progress to avoid send mondo timeout
A large sun4v SPARC system may have moments of intensive xcall activities, usually caused by unmapping many pages on many CPUs concurrently. This can flood receivers with CPU mondo interrupts for an extended period, causing some unlucky senders to hit send-mondo timeout. This problem gets worse as cpu count increases because sometimes mappings must be invalidated on all CPUs, and sometimes all CPUs may gang up on a single CPU.
But a busy system is not a broken system. In the above scenario, as long as the receiver is making forward progress processing mondo interrupts, the sender should continue to retry.
This patch implements the receiver's forward progress meter by introducing a per cpu counter 'cpu_mondo_counter[cpu]' where 'cpu' is in the range of 0..NR_CPUS. The receiver increments its counter as soon as it receives a mondo and the sender tracks the receiver's counter. Every 10000 retries, if the receiver has stopped making forward progress, the sender declares send-mondo-timeout and panic; otherwise, the receiver is allowed to keep making forward progress.
Orabug: 25476541
--- arch/sparc/include/asm/trap_block.h | 1 + arch/sparc/kernel/smp_64.c | 166 ++++++++++++++++++++-------------- arch/sparc/kernel/sun4v_ivec.S | 15 +++ arch/sparc/kernel/traps_64.c | 1 + 4 files changed, 115 insertions(+), 68 deletions(-)
arch/sparc/include/asm/trap_block.h +1 -0
@@ -54,6 +54,7 @@ struct trap_per_cpu {void init_cur_cpu_trap (struct thread_info *);void setup_tba (void );extern int ncpus_probed; +extern u64 cpu_mondo_counter[NR_CPUS ];unsigned long real_hard_smp_processor_id (void );
arch/sparc/kernel/smp_64.c +98 -68
214 lines not on this page · raw message
arch/sparc/kernel/sun4v_ivec.S +15 -0
@@ -26,6 +26,21 @@ sun4v_cpu_mondo: ldxa [%g0] ASI_SCRATCHPAD, %g4 sub %g4, TRAP_PER_CPU_FAULT_INFO, %g4 + /* Get smp_processor_id() into %g3 */ + sethi %hi(trap_block), %g5 + or %g5, %lo(trap_block), %g5 + sub %g4, %g5, %g3 + srlx %g3, TRAP_BLOCK_SZ_SHIFT, %g3 + + /* Increment cpu_mondo_counter[smp_processor_id()] */ + sethi %hi(cpu_mondo_counter), %g5 + or %g5, %lo(cpu_mondo_counter), %g5 + sllx %g3, 3, %g3 + add %g5, %g3, %g5 + ldx [%g5], %g3 + add %g3, 1, %g3 + stx %g3, [%g5] + /* Get CPU mondo queue base phys address into %g7. */ ldx [%g4 + TRAP_PER_CPU_CPU_MONDO_PA], %g7
arch/sparc/kernel/traps_64.c +1 -0
@@ -2733,6 +2733,7 @@ void do_getpsr(struct pt_regs *regs) } } +u64 cpu_mondo_counter[NR_CPUS ] = {0 };struct trap_per_cpu trap_block[NR_CPUS ];EXPORT_SYMBOL (trap_block);
Signature · 1 line
1.7.1
David Miller
maintainerFrom: Jane Chu <[email protected]>
Date: Wed, 28 Jun 2017 15:02:26 -0600
arch/sparc/kernel/smp_64.c static void cheetah_xcall_deliver(struct trap_per_cpu *tb, int cnt) · line 644
Quoted 12 lines
static void
hypervisor_xcall_deliver(struct trap_per_cpu *tb, int cnt){arch/sparc/kernel/smp_64.c +7
-1-int retries, this_cpu, prev_sent, i, saw_cpu_error; +int retries, this_cpu, prev_sent, i, rem; +uint16_t first_cpu =0xffff ; +unsigned long xc_rcvd =0 ; +int usec_wait = cnt *2 ;unsigned long status; +int ecpuerror_id =0 ; +int enocpu_id =0 ;u16 *cpu_list; +uint16_t cpu;
As you can see at the variable declarations around the ones you are adding, "u16" is the appropriate type to use. "uint16_t" is not.
So my concern about this patch is that in my mind, getting into a state where a cpu is looping and doing nothing but handling mondos is a bug.
That cpu is making no progress in it's execution stream, and that's problematic.
I'd rather we attack the issue that gets into this situation in the first place.
It's because we don't optimize large amounts of page TLB flushes properly.
Firstly, we don't have a way to pass the array of pages to flush. That would cut down the mondos by orders of magnitude.
We also could have a cutoff where we do a full MM flush instead of flushing individual pages.
I bet if you implemented these two things, it would not only make the mondo timeouts go away, it with make cpus actually make forward progress in their instruction stream rather than looping like crazy processing mondos.
Thanks.
Quoted 38 lines · David Miller
From: Jane Chu <[email protected]>
Date: Wed, 28 Jun 2017 15:02:26 -0600arch/sparc/kernel/smp_64.c static void cheetah_xcall_deliver(struct trap_per_cpu *tb, int cnt) · line 644
Quoted 12 lines
static void hypervisor_xcall_deliver(struct trap_per_cpu *tb, int cnt) {arch/sparc/kernel/smp_64.c +7
-1-int retries, this_cpu, prev_sent, i, saw_cpu_error; +int retries, this_cpu, prev_sent, i, rem; +uint16_t first_cpu =0xffff ; +unsigned long xc_rcvd =0 ; +int usec_wait = cnt *2 ;unsigned long status; +int ecpuerror_id =0 ; +int enocpu_id =0 ;u16 *cpu_list; +uint16_t cpu;As you can see at the variable declarations around the ones you are adding, "u16" is the appropriate type to use. "
uint16_t" is not.So my concern about this patch is that in my mind, getting into a state where a cpu is looping and doing nothing but handling mondos is a bug.
That cpu is making no progress in it's execution stream, and that's problematic.
I'd rather we attack the issue that gets into this situation in the first place.
It's because we don't optimize large amounts of page TLB flushes properly.
Firstly, we don't have a way to pass the array of pages to flush. That would cut down the mondos by orders of magnitude.
We also could have a cutoff where we do a full MM flush instead of flushing individual pages.
Quoted 6 lines
I bet if you implemented these two things, it would not only make the mondo timeouts go away, it with make cpus actually make forward progress in their instruction stream rather than looping like crazy processing mondos.
Thanks.
There is room for improvement in the TLB flush algorithms, and it is on our longer term list of things to do, as it will generally improve performance of demap operations. However, on another operating system for sparc, we have a large set of algorithms to use large pages extensively, batch translation shootdowns, transition to demap-context and demap-all, and use hardware MMU-group demap features, and it is still not enough to prevent mondo timeout panic under stressful conditions on large systems using the "sender counts" method of judging forward progress. The "receiver counts" method has proven to be a robust way of riding out mondo storms into calmer waters without panicking the system, and greatly reduced the number of bug reports from users due to mondo timeouts. This is a valuable feature that users appreciate.
(I removed linux-kernel from the CC list to reduce their traffic, since this is arch/sparc code).
- Steve
David Miller
maintainerFrom: Steven Sistare <[email protected]>
Date: Mon, 3 Jul 2017 09:34:48 -0400
Quoted 37 lines · David Miller
Quoted 27 lines
From: Jane Chu <[email protected]>
Date: Wed, 28 Jun 2017 15:02:26 -0600arch/sparc/kernel/smp_64.c static void cheetah_xcall_deliver(struct trap_per_cpu *tb, int cnt) · line 644
Quoted 12 lines
static void hypervisor_xcall_deliver(struct trap_per_cpu *tb, int cnt) {arch/sparc/kernel/smp_64.c +7
-1-int retries, this_cpu, prev_sent, i, saw_cpu_error; +int retries, this_cpu, prev_sent, i, rem; +uint16_t first_cpu =0xffff ; +unsigned long xc_rcvd =0 ; +int usec_wait = cnt *2 ;unsigned long status; +int ecpuerror_id =0 ; +int enocpu_id =0 ;u16 *cpu_list; +uint16_t cpu;As you can see at the variable declarations around the ones you are adding, "u16" is the appropriate type to use. "
uint16_t" is not. So my concern about this patch is that in my mind, getting into a state where a cpu is looping and doing nothing but handling mondos is a bug.
That cpu is making no progress in it's execution stream, and that's problematic.
I'd rather we attack the issue that gets into this situation in the first place.
It's because we don't optimize large amounts of page TLB flushes properly.
Firstly, we don't have a way to pass the array of pages to flush.Quoted 8 lines
That would cut down the mondos by orders of magnitude. We also could have a cutoff where we do a full MM flush instead of flushing individual pages.
I bet if you implemented these two things, it would not only make the mondo timeouts go away, it with make cpus actually make forward progress in their instruction stream rather than looping like crazy processing mondos.
Thanks.
Quoted 13 lines
There is room for improvement in the TLB flush algorithms, and it is on our longer term list of things to do, as it will generally improve performance of demap operations. However, on another operating system for sparc, we have a large set of algorithms to use large pages extensively, batch translation shootdowns, transition to demap-context and demap-all, and use hardware MMU-group demap features, and it is still not enough to prevent mondo timeout panic under stressful conditions on large systems using the "sender counts" method of judging forward progress. The "receiver counts" method has proven to be a robust way of riding out mondo storms into calmer waters without panicking the system, and greatly reduced the number of bug reports from users due to mondo timeouts. This is a valuable feature that users appreciate.
Ok, please make the variable type changes I suggested and submit that new version and I will think about this further.
Quoted 52 lines · David Miller
From: Steven Sistare <[email protected]>
Date: Mon, 3 Jul 2017 09:34:48 -0400Quoted 36 lines · David Miller
Quoted 27 lines
From: Jane Chu <[email protected]>
Date: Wed, 28 Jun 2017 15:02:26 -0600arch/sparc/kernel/smp_64.c static void cheetah_xcall_deliver(struct trap_per_cpu *tb, int cnt) · line 644
Quoted 12 lines
static void hypervisor_xcall_deliver(struct trap_per_cpu *tb, int cnt) {arch/sparc/kernel/smp_64.c +7
-1-int retries, this_cpu, prev_sent, i, saw_cpu_error; +int retries, this_cpu, prev_sent, i, rem; +uint16_t first_cpu =0xffff ; +unsigned long xc_rcvd =0 ; +int usec_wait = cnt *2 ;unsigned long status; +int ecpuerror_id =0 ; +int enocpu_id =0 ;u16 *cpu_list; +uint16_t cpu;As you can see at the variable declarations around the ones you are adding, "u16" is the appropriate type to use. "
uint16_t" is not. So my concern about this patch is that in my mind, getting into a state where a cpu is looping and doing nothing but handling mondos is a bug.
That cpu is making no progress in it's execution stream, and that's problematic.
I'd rather we attack the issue that gets into this situation in the first place.
It's because we don't optimize large amounts of page TLB flushes properly.
Firstly, we don't have a way to pass the array of pages to flush.Quoted 8 lines
That would cut down the mondos by orders of magnitude. We also could have a cutoff where we do a full MM flush instead of flushing individual pages.
I bet if you implemented these two things, it would not only make the mondo timeouts go away, it with make cpus actually make forward progress in their instruction stream rather than looping like crazy processing mondos.
Thanks.Quoted 13 lines
There is room for improvement in the TLB flush algorithms, and it is on our longer term list of things to do, as it will generally improve performance of demap operations. However, on another operating system for sparc, we have a large set of algorithms to use large pages extensively, batch translation shootdowns, transition to demap-context and demap-all, and use hardware MMU-group demap features, and it is still not enough to prevent mondo timeout panic under stressful conditions on large systems using the "sender counts" method of judging forward progress. The "receiver counts" method has proven to be a robust way of riding out mondo storms into calmer waters without panicking the system, and greatly reduced the number of bug reports from users due to mondo timeouts. This is a valuable feature that users appreciate.
Quoted 2 lines
Ok, please make the variable type changes I suggested and submit that new version and I will think about this further.
Sorry for my delay in reply. My colleague saw mondo timeout while performing
PCIe hotplug tests. The timeout came from a network thread sending a mondo to
a single cpu to raise software interrupt. Occasionally, the target cpu
made no
progress in 20msec. The reason I think, is that the target cpu was borrowed by hypervisor to service the correctable errors triggered by hotplug. As strand in hypervisor service cannot respond to mondo, we need to increase the
overall wait time to an agreeable value between hypervisor and OS.
I will revise the patch and fix the variable types.
thanks!
-jane
David Miller
maintainerFrom: [email protected]
Date: Mon, 10 Jul 2017 10:23:32 -0700
Quoted 13 lines
Sorry for my delay in reply. My colleague saw mondo timeout while performing
PCIe hotplug tests. The timeout came from a network thread sending a mondo to
a single cpu to raise software interrupt. Occasionally, the target cpu made no
progress in 20msec. The reason I think, is that the target cpu was borrowed
by hypervisor to service the correctable errors triggered by hotplug. As strand in hypervisor service cannot respond to mondo, we need to increase the
overall wait time to an agreeable value between hypervisor and OS.
Quoted 1 line
I will revise the patch and fix the variable types.
Ok, thanks for the update and additional information.
PATCH 1/1 arch/sparc: Measure receiver forward progress to avoid send mondo timeout
In reply to Jane ChuA large sun4v SPARC system may have moments of intensive xcall activities, usually caused by unmapping many pages on many CPUs concurrently. This can flood receivers with CPU mondo interrupts for an extended period, causing some unlucky senders to hit send-mondo timeout. This problem gets worse as cpu count increases because sometimes mappings must be invalidated on all CPUs, and sometimes all CPUs may gang up on a single CPU.
But a busy system is not a broken system. In the above scenario, as long as the receiver is making forward progress processing mondo interrupts, the sender should continue to retry.
This patch implements the receiver's forward progress meter by introducing a per cpu counter 'cpu_mondo_counter[cpu]' where 'cpu' is in the range of 0..NR_CPUS. The receiver increments its counter as soon as it receives a mondo and the sender tracks the receiver's counter. If the receiver has stopped making forward progress when the retry limit is reached, the sender declares send-mondo-timeout and panic; otherwise, the receiver is allowed to keep making forward progress.
In addition, it's been observed that PCIe hotplug events generate Correctable Errors that are handled by hypervisor and then OS. Hypervisor 'borrows' a guest cpu strand briefly to provide the service. If the cpu strand is simultaneously the only cpu targeted by a mondo, it may not be available for the mondo in 20msec, causing SUN4V mondo timeout. It appears that 1 second is the agreed wait time between hypervisor and guest OS, this patch makes the adjustment.
Orabug: 25476541
Orabug: 26417466
--- arch/sparc/include/asm/trap_block.h | 1 + arch/sparc/kernel/smp_64.c | 185 ++++++++++++++++++++++------------- arch/sparc/kernel/sun4v_ivec.S | 15 +++ arch/sparc/kernel/traps_64.c | 1 + 4 files changed, 132 insertions(+), 70 deletions(-)
arch/sparc/include/asm/trap_block.h +1 -0
@@ -54,6 +54,7 @@ struct trap_per_cpu {void init_cur_cpu_trap (struct thread_info *);void setup_tba (void );extern int ncpus_probed; +extern u64 cpu_mondo_counter[NR_CPUS ];unsigned long real_hard_smp_processor_id (void );
arch/sparc/kernel/smp_64.c +115 -70
231 lines not on this page · raw message
arch/sparc/kernel/sun4v_ivec.S +15 -0
@@ -26,6 +26,21 @@ sun4v_cpu_mondo: ldxa [%g0] ASI_SCRATCHPAD, %g4 sub %g4, TRAP_PER_CPU_FAULT_INFO, %g4 + /* Get smp_processor_id() into %g3 */ + sethi %hi(trap_block), %g5 + or %g5, %lo(trap_block), %g5 + sub %g4, %g5, %g3 + srlx %g3, TRAP_BLOCK_SZ_SHIFT, %g3 + + /* Increment cpu_mondo_counter[smp_processor_id()] */ + sethi %hi(cpu_mondo_counter), %g5 + or %g5, %lo(cpu_mondo_counter), %g5 + sllx %g3, 3, %g3 + add %g5, %g3, %g5 + ldx [%g5], %g3 + add %g3, 1, %g3 + stx %g3, [%g5] + /* Get CPU mondo queue base phys address into %g7. */ ldx [%g4 + TRAP_PER_CPU_CPU_MONDO_PA], %g7
arch/sparc/kernel/traps_64.c +1 -0
@@ -2733,6 +2733,7 @@ void do_getpsr(struct pt_regs *regs) } } +u64 cpu_mondo_counter[NR_CPUS ] = {0 };struct trap_per_cpu trap_block[NR_CPUS ];EXPORT_SYMBOL (trap_block);
Signature · 1 line
1.7.1
David Miller
maintainerFrom: Jane Chu <[email protected]>
Date: Tue, 11 Jul 2017 12:00:54 -0600
BTW, for sparc64 specific changes, please use the "sparc64: " subsystem prefix in your Subject lines. I've fixed it up for you this time.
Quoted 3 lines
But a busy system is not a broken system. In the above scenario, as long as the receiver is making forward progress processing mondo interrupts, the sender should continue to retry.
So I'm going to apply this patch, but I absolutely, fundamentally disagree with this statement.
Making forward progress only processing mondo interrupts _IS_ broken.
A cpu stuck doing nothing but processing mondo interrupts is in an error state.
I repeat, it is not valid for a cpu to be stuck doing mondo interrupt processing. This is true, even if it is making "forward progress" within that backlog of mondo interrupts.
A cpu must always, somehow, continually make forward progress in it's primary instruction stream.
In the kernel, for example, when we have so many software interrupts that the cpu is not making forward progress on anything else, we defer the software interrupt processing to a kernel thread instead of doing it immediately. This is absolutely required, so that the primary exectuion stream of the cpu always makes forward progress.
We must do something similar here with MONDOs.
Either we find a way to decrease the cost of the individual mondos (and this makes sense, mondos should be something that executes in an extremely small, finite, amount of time) so that these backlogs can't happen in the first place.
Or, we make some kind of deferral mechanism for the most expensive kinds of mondos.
I'm still pretty sure that unmaps are taking an unreasonable amount of time to execute. Our current range flush implementation is incredibly stupid, and could be improved by orders of magnitude. It allocates an entire kernel stack frame, just so that it can call __flush_tlb_pending().
In fact, we can end up doing this full trap entry/exit just for purging 2 or 3 pages.
So this means we need an in-assembler cross-call trap handler that can do the TLB pending flush directly. And, we also need a limiter that says "if the number of pages pending to TLB purge is greater than X, do an MM context TLB flush instead". X should probably be something on the order of the number of entries in the hardware TLB CAM.
To me this all is a huge red flag, and probably causes all of the mondo timesouts you've seen except for the PCI-E hotplug cases.
David Miller
maintainerFrom: David Miller <[email protected]>
Date: Fri, 14 Jul 2017 11:17:36 -0700 (PDT)
Quoted 7 lines
I'm still pretty sure that unmaps are taking an unreasonable amount of time to execute. Our current range flush implementation is incredibly stupid, and could be improved by orders of magnitude. It allocates an entire kernel stack frame, just so that it can call
__flush_tlb_pending().In fact, we can end up doing this full trap entry/exit just for purging 2 or 3 pages.
So I wanted to dig deeper into this, so I wrote a simple tracker for flush_tlb_pending() which keeps of how often we do flushes of various sizes.
The patch is below, the output from /proc/cpuinfo looks like:
TLB PENDING : Total 2441449 Chart [1365735 435807 105896 134569 134121 89929 55970 123867 0 0 0 0 0 0 0]
First is the total number of flushes, then there is a histogram of counts by power of 2. So the first slot is number of 1 entry flushes, the second slot is the number of 2 or 3 entry flushes, the third is the number of 4, 5, 6, or 7 entry flushes. And so on.
I did three kernel builds after a fresh boot and ended up with this (annotated):
Total 2437888
1: 1363857
2: 435389
4: 105582
8: 134329
16: 133978
32: 89821
64: 55833
128: 123544
256: 0
512: 0
1024: 0
2048: 0
4096: 0
8192: 0
16384: 0
Can you run with this patch on the test case that triggered these mondo timeouts and send the /proc/cpuinfo "TLB PENDING" line to this list?
Thanks!
arch/sparc/include/asm/tlb_64.h +7 -0
@@ -7,6 +7,13 @@#include <asm/tlbflush.h> #include <asm/mmu_context.h> +#define TLB_PENDING_STATS_SLOTS 15 +struct tlb_pending_stats { +unsigned long total; +unsigned long num_flushes[TLB_PENDING_STATS_SLOTS ]; +}; +extern struct tlb_pending_stats tpstats; +#ifdef CONFIG_SMP void smp_flush_tlb_pending (struct mm_struct *,unsigned long ,unsigned long *);
arch/sparc/kernel/cpu.c +8 -1
@@ -20,6 +20,7 @@#include <asm/psr.h> #include <asm/mbus.h> #include <asm/cpudata.h> +#include <asm/tlb.h> #include "kernel.h" #include "entry.h"
@@ -378,6 +379,7 @@ static int show_cpuinfo(struct seq_file *m, void *__unused)"ncpus active\t: %d\n" "D$ parity tl1\t: %u\n" "I$ parity tl1\t: %u\n" +"TLB PENDING\t: Total %lu Chart [%lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu]\n" #ifndef CONFIG_SMP"Cpu0ClkTck\t: %016lx\n" #endif
@@ -392,7 +394,12 @@ static int show_cpuinfo(struct seq_file *m, void *__unused) ncpus_probed,num_online_cpus (), dcache_parity_tl1_occurred, - icache_parity_tl1_occurred + icache_parity_tl1_occurred, + tpstats.total, + tpstats.num_flushes[0 ], tpstats.num_flushes[1 ], tpstats.num_flushes[2 ], tpstats.num_flushes[3 ], + tpstats.num_flushes[4 ], tpstats.num_flushes[5 ], tpstats.num_flushes[6 ], tpstats.num_flushes[7 ], + tpstats.num_flushes[8 ], tpstats.num_flushes[9 ], tpstats.num_flushes[10 ], tpstats.num_flushes[11 ], + tpstats.num_flushes[12 ], tpstats.num_flushes[13 ], tpstats.num_flushes[14 ] #ifndef CONFIG_SMP ,cpu_data (0 ).clock_tick #endif
arch/sparc/mm/tlb.c +10 -0
@@ -20,6 +20,8 @@ static DEFINE_PER_CPU(struct tlb_batch, tlb_batch); +struct tlb_pending_stats tpstats; +void flush_tlb_pending (void ) {struct tlb_batch *tb = &get_cpu_var (tlb_batch);
@@ -31,6 +33,14 @@ void flush_tlb_pending(void)flush_tsb_user (tb);if (CTX_VALID (mm->context)) { +u32 slot = tb->tlb_nr; + + tpstats.total++; + slot =ilog2 (slot); +if (slot >14 ) + slot =14 ; + tpstats.num_flushes[slot]++; +if (tb->tlb_nr =1 ) {global_flush_tlb_page (mm, tb->vaddrs[0 ]); }else {
Hi, David,
Quoted 43 lines · David Miller
From: David Miller <[email protected]>
Date: Fri, 14 Jul 2017 11:17:36 -0700 (PDT)Quoted 7 lines
I'm still pretty sure that unmaps are taking an unreasonable amount of time to execute. Our current range flush implementation is incredibly stupid, and could be improved by orders of magnitude. It allocates an entire kernel stack frame, just so that it can call
__flush_tlb_pending().In fact, we can end up doing this full trap entry/exit just for purging 2 or 3 pages.
So I wanted to dig deeper into this, so I wrote a simple tracker for
flush_tlb_pending()which keeps of how often we do flushes of various sizes.The patch is below, the output from
/proc/cpuinfolooks like:TLB PENDING : Total 2441449 Chart [1365735 435807 105896 134569 134121 89929 55970 123867 0 0 0 0 0 0 0]
First is the total number of flushes, then there is a histogram of counts by power of 2. So the first slot is number of 1 entry flushes, the second slot is the number of 2 or 3 entry flushes, the third is the number of 4, 5, 6, or 7 entry flushes. And so on.
I did three kernel builds after a fresh boot and ended up with this (annotated):
Total 2437888
1: 1363857
2: 435389
4: 105582
8: 134329
16: 133978
32: 89821
64: 55833
128: 123544
256: 0
512: 0
1024: 0
2048: 0
4096: 0
8192: 0
16384: 0
Quoted 2 lines
Can you run with this patch on the test case that triggered these mondo timeouts and send the
/proc/cpuinfo"TLB PENDING" line to this list?
Thanks for digging in. I will try your patch to gather what I could share the data.
thanks!
-jane
Quoted 83 lines
Thanks!
arch/sparc/include/asm/tlb_64.h +7
-0@@ -7,6 +7,13 @@#include <asm/tlbflush.h> #include <asm/mmu_context.h> +#define TLB_PENDING_STATS_SLOTS 15 +struct tlb_pending_stats { +unsigned long total; +unsigned long num_flushes[TLB_PENDING_STATS_SLOTS ]; +}; +extern struct tlb_pending_stats tpstats; +#ifdef CONFIG_SMP void smp_flush_tlb_pending (struct mm_struct *,unsigned long ,unsigned long *);arch/sparc/kernel/cpu.c +8
-1@@ -20,6 +20,7 @@#include <asm/psr.h> #include <asm/mbus.h> #include <asm/cpudata.h> +#include <asm/tlb.h> #include "kernel.h" #include "entry.h" @@ -378,6 +379,7 @@ static int show_cpuinfo(struct seq_file *m, void *__unused)"ncpus active\t: %d\n" "D$ parity tl1\t: %u\n" "I$ parity tl1\t: %u\n" +"TLB PENDING\t: Total %lu Chart [%lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu]\n" #ifndef CONFIG_SMP"Cpu0ClkTck\t: %016lx\n" #endif@@ -392,7 +394,12 @@ static int show_cpuinfo(struct seq_file *m, void *__unused) ncpus_probed,num_online_cpus (), dcache_parity_tl1_occurred, - icache_parity_tl1_occurred + icache_parity_tl1_occurred, + tpstats.total, + tpstats.num_flushes[0 ], tpstats.num_flushes[1 ], tpstats.num_flushes[2 ], tpstats.num_flushes[3 ], + tpstats.num_flushes[4 ], tpstats.num_flushes[5 ], tpstats.num_flushes[6 ], tpstats.num_flushes[7 ], + tpstats.num_flushes[8 ], tpstats.num_flushes[9 ], tpstats.num_flushes[10 ], tpstats.num_flushes[11 ], + tpstats.num_flushes[12 ], tpstats.num_flushes[13 ], tpstats.num_flushes[14 ] #ifndef CONFIG_SMP ,cpu_data (0 ).clock_tick #endifarch/sparc/mm/tlb.c +10
-0@@ -20,6 +20,8 @@ static DEFINE_PER_CPU(struct tlb_batch, tlb_batch); +struct tlb_pending_stats tpstats; +void flush_tlb_pending (void ) {struct tlb_batch *tb = &get_cpu_var (tlb_batch);@@ -31,6 +33,14 @@ void flush_tlb_pending(void)flush_tsb_user (tb);if (CTX_VALID (mm->context)) { +u32 slot = tb->tlb_nr; + + tpstats.total++; + slot =ilog2 (slot); +if (slot >14 ) + slot =14 ; + tpstats.num_flushes[slot]++; +if (tb->tlb_nr =1 ) {global_flush_tlb_page (mm, tb->vaddrs[0 ]); }else {
David Miller
maintainerFrom: [email protected]
Date: Mon, 17 Jul 2017 15:11:03 -0700
Quoted 2 lines
Thanks for digging in. I will try your patch to gather what I could share the data.
So, further inspection shows that we limit batches to 192 entries so we will never see the full extent of an unmap in the statistics for large operations.
David Miller
maintainerFrom: David Miller <[email protected]>
Date: Tue, 18 Jul 2017 11:39:43 -0700 (PDT)
Quoted 9 lines
From: [email protected]
Date: Mon, 17 Jul 2017 15:11:03 -0700Quoted 2 lines
Thanks for digging in. I will try your patch to gather what I could share the data.
So, further inspection shows that we limit batches to 192 entries so we will never see the full extent of an unmap in the statistics for large operations.
What follows is a rough attempt to mitigate the TLB flush overhead a little bit, I've kept the statistics gathering in there for now.
The initial heuristic is that if we fill up an entire TLB batch, we switch to a full TLB context flush, which we will perform at the end of the high level unmap operation (several more batch fills can happen until then).
Maybe the cut-off should be even lower, I don't know.
One major aspect, which we've been discussing, is that this keeps us from doing multiple expensive mondo's to remote cpus during the unmap. We just do one cheap one, for the TLB context flush. Therefore, qnother thing that comes to mind is that if the MM has only executed on the local cpu, we won't end up doing remote mondos, so maybe the cut-off can be a bit higher in that case.
We still flush the TSB entries one-by-one, but that always only occurs on the local cpu. It is possible to improve this as well, but we'd need to keep track of a range.
If you look in the kernel TSB flushing, we have an optimization in the range flushing case. If the range is too large, we don't probe, instead we scan the TSB from beginning to end, and do range comparisons on the virtual address in the TAG.
So the idea is that we maintain a "lowest" and "highest" address in the TLB batch structure, and if the number of batch entries get large we go into a TSB scan mode.
Integrating the TSB part into this is not easy. The trouble is that the cut-off for going to TSB scan mode needs to be a lot larger than the one used for entering TLB context flush mode. This is especially the case because of how we dynamically grow the TSB based roughly upon the thread's resident set size.
Anyways, patch follows...
arch/sparc/include/asm/tlb_64.h +8 -0
@@ -7,6 +7,14 @@#include <asm/tlbflush.h> #include <asm/mmu_context.h> +#define TLB_PENDING_STATS_SLOTS 9 +struct tlb_pending_stats { +unsigned long total; +unsigned long num_force_mm_flush; +unsigned long hist[TLB_PENDING_STATS_SLOTS ]; +}; +extern struct tlb_pending_stats tpstats; +#ifdef CONFIG_SMP void smp_flush_tlb_pending (struct mm_struct *,unsigned long ,unsigned long *);
arch/sparc/include/asm/tlbflush_64.h +1 -0
@@ -11,6 +11,7 @@ struct tlb_batch {unsigned int hugepage_shift;struct mm_struct *mm;unsigned long tlb_nr; +unsigned long force_mm_flush;unsigned long active;unsigned long vaddrs[TLB_BATCH_NR ]; };
arch/sparc/kernel/cpu.c +7 -1
@@ -20,6 +20,7 @@#include <asm/psr.h> #include <asm/mbus.h> #include <asm/cpudata.h> +#include <asm/tlb.h> #include "kernel.h" #include "entry.h"
@@ -378,6 +379,7 @@ static int show_cpuinfo(struct seq_file *m, void *__unused)"ncpus active\t: %d\n" "D$ parity tl1\t: %u\n" "I$ parity tl1\t: %u\n" +"TLB PENDING\t: Total %lu MM %lu [%lu %lu %lu %lu %lu %lu %lu %lu %lu]\n" #ifndef CONFIG_SMP"Cpu0ClkTck\t: %016lx\n" #endif
@@ -392,7 +394,11 @@ static int show_cpuinfo(struct seq_file *m, void *__unused) ncpus_probed,num_online_cpus (), dcache_parity_tl1_occurred, - icache_parity_tl1_occurred + icache_parity_tl1_occurred, + tpstats.total, tpstats.num_force_mm_flush, + tpstats.hist[0 ], tpstats.hist[1 ], tpstats.hist[2 ], tpstats.hist[3 ], + tpstats.hist[4 ], tpstats.hist[5 ], tpstats.hist[6 ], tpstats.hist[7 ], + tpstats.hist[8 ] #ifndef CONFIG_SMP ,cpu_data (0 ).clock_tick #endif
arch/sparc/mm/tlb.c +33 -3
@@ -19,16 +19,30 @@/* Heavily inspired by the ppc64 code. */ static DEFINE_PER_CPU(struct tlb_batch, tlb_batch); +struct tlb_pending_stats tpstats;void flush_tlb_pending (void ) {struct tlb_batch *tb = &get_cpu_var (tlb_batch);struct mm_struct *mm = tb->mm; +u32 slot = tb->tlb_nr;if (!tb->tlb_nr) goto out; + tpstats.total++; +if (slot =TLB_BATCH_NR ) { + slot =8 ; + }else { + slot =ilog2 (slot); +if (slot >=8 ) + slot =8 ; + } + tpstats.hist[slot]++; +flush_tsb_user (tb); +if (tb->force_mm_flush) + goto out_nr;if (CTX_VALID (mm->context)) {if (tb->tlb_nr =1 ) {
@@ -43,13 +57,24 @@ void flush_tlb_pending(void)#endif } } - +out_nr: tb->tlb_nr =0 ; out:put_cpu_var (tlb_batch); } +static void maybe_flush_mm_context (struct tlb_batch *tb) +{ +if (tb->force_mm_flush) { +struct mm_struct *mm = tb->mm; + +if (CTX_VALID (mm->context)) +do_flush_tlb_mm (mm); + tb->force_mm_flush =0 ; + } +} +void arch_enter_lazy_mmu_mode (void ) {struct tlb_batch *tb =this_cpu_ptr (&tlb_batch);
@@ -63,6 +88,7 @@ void arch_leave_lazy_mmu_mode(void)if (tb->tlb_nr)flush_tlb_pending (); +maybe_flush_mm_context (tb); tb->active =0 ; }
@@ -80,6 +106,7 @@ static void tlb_batch_add_one(struct mm_struct *mm, unsigned long vaddr,if (unlikely (nr !=0 && mm != tb->mm)) {flush_tlb_pending (); +maybe_flush_mm_context (tb); nr =0 ; }
@@ -96,15 +123,18 @@ static void tlb_batch_add_one(struct mm_struct *mm, unsigned long vaddr,if (tb->hugepage_shift != hugepage_shift) {flush_tlb_pending (); +maybe_flush_mm_context (tb); tb->hugepage_shift = hugepage_shift; nr =0 ; } tb->vaddrs[nr] = vaddr; tb->tlb_nr = ++nr; -if (nr >=TLB_BATCH_NR ) +if (nr >=TLB_BATCH_NR ) { + tpstats.num_force_mm_flush++; + tb->force_mm_flush =1 ;flush_tlb_pending (); - + } out:put_cpu_var (tlb_batch); }
Thanks David. I'll give this version of patch a try on a large system.
-jane
Quoted 211 lines · David Miller
From: David Miller <[email protected]>
Date: Tue, 18 Jul 2017 11:39:43 -0700 (PDT)Quoted 8 lines
From: [email protected]
Date: Mon, 17 Jul 2017 15:11:03 -0700Quoted 2 lines
Thanks for digging in. I will try your patch to gather what I could share the data.
So, further inspection shows that we limit batches to 192 entries so we will never see the full extent of an unmap in the statistics for large operations.
What follows is a rough attempt to mitigate the TLB flush overhead a little bit, I've kept the statistics gathering in there for now.
The initial heuristic is that if we fill up an entire TLB batch, we switch to a full TLB context flush, which we will perform at the end of the high level unmap operation (several more batch fills can happen until then).
Maybe the cut-off should be even lower, I don't know.
One major aspect, which we've been discussing, is that this keeps us from doing multiple expensive mondo's to remote cpus during the unmap. We just do one cheap one, for the TLB context flush. Therefore, qnother thing that comes to mind is that if the MM has only executed on the local cpu, we won't end up doing remote mondos, so maybe the cut-off can be a bit higher in that case.
We still flush the TSB entries one-by-one, but that always only occurs on the local cpu. It is possible to improve this as well, but we'd need to keep track of a range.
If you look in the kernel TSB flushing, we have an optimization in the range flushing case. If the range is too large, we don't probe, instead we scan the TSB from beginning to end, and do range comparisons on the virtual address in the TAG.
So the idea is that we maintain a "lowest" and "highest" address in the TLB batch structure, and if the number of batch entries get large we go into a TSB scan mode.
Integrating the TSB part into this is not easy. The trouble is that the cut-off for going to TSB scan mode needs to be a lot larger than the one used for entering TLB context flush mode. This is especially the case because of how we dynamically grow the TSB based roughly upon the thread's resident set size.
Anyways, patch follows...
arch/sparc/include/asm/tlb_64.h +8
-0@@ -7,6 +7,14 @@#include <asm/tlbflush.h> #include <asm/mmu_context.h> +#define TLB_PENDING_STATS_SLOTS 9 +struct tlb_pending_stats { +unsigned long total; +unsigned long num_force_mm_flush; +unsigned long hist[TLB_PENDING_STATS_SLOTS ]; +}; +extern struct tlb_pending_stats tpstats; +#ifdef CONFIG_SMP void smp_flush_tlb_pending (struct mm_struct *,unsigned long ,unsigned long *);arch/sparc/include/asm/tlbflush_64.h +1
-0@@ -11,6 +11,7 @@ struct tlb_batch {unsigned int hugepage_shift;struct mm_struct *mm;unsigned long tlb_nr; +unsigned long force_mm_flush;unsigned long active;unsigned long vaddrs[TLB_BATCH_NR ]; };arch/sparc/kernel/cpu.c +7
-1@@ -20,6 +20,7 @@#include <asm/psr.h> #include <asm/mbus.h> #include <asm/cpudata.h> +#include <asm/tlb.h> #include "kernel.h" #include "entry.h" @@ -378,6 +379,7 @@ static int show_cpuinfo(struct seq_file *m, void *__unused)"ncpus active\t: %d\n" "D$ parity tl1\t: %u\n" "I$ parity tl1\t: %u\n" +"TLB PENDING\t: Total %lu MM %lu [%lu %lu %lu %lu %lu %lu %lu %lu %lu]\n" #ifndef CONFIG_SMP"Cpu0ClkTck\t: %016lx\n" #endif@@ -392,7 +394,11 @@ static int show_cpuinfo(struct seq_file *m, void *__unused) ncpus_probed,num_online_cpus (), dcache_parity_tl1_occurred, - icache_parity_tl1_occurred + icache_parity_tl1_occurred, + tpstats.total, tpstats.num_force_mm_flush, + tpstats.hist[0 ], tpstats.hist[1 ], tpstats.hist[2 ], tpstats.hist[3 ], + tpstats.hist[4 ], tpstats.hist[5 ], tpstats.hist[6 ], tpstats.hist[7 ], + tpstats.hist[8 ] #ifndef CONFIG_SMP ,cpu_data (0 ).clock_tick #endifarch/sparc/mm/tlb.c +33
-3@@ -19,16 +19,30 @@/* Heavily inspired by the ppc64 code. */ static DEFINE_PER_CPU(struct tlb_batch, tlb_batch); +struct tlb_pending_stats tpstats;void flush_tlb_pending (void ) {struct tlb_batch *tb = &get_cpu_var (tlb_batch);struct mm_struct *mm = tb->mm; +u32 slot = tb->tlb_nr;if (!tb->tlb_nr) goto out; + tpstats.total++; +if (slot =TLB_BATCH_NR ) { + slot =8 ; + }else { + slot =ilog2 (slot); +if (slot >=8 ) + slot =8 ; + } + tpstats.hist[slot]++; +flush_tsb_user (tb); +if (tb->force_mm_flush) + goto out_nr;if (CTX_VALID (mm->context)) {if (tb->tlb_nr =1 ) {@@ -43,13 +57,24 @@ void flush_tlb_pending(void)#endif } } - +out_nr: tb->tlb_nr =0 ; out:put_cpu_var (tlb_batch); } +static void maybe_flush_mm_context (struct tlb_batch *tb) +{ +if (tb->force_mm_flush) { +struct mm_struct *mm = tb->mm; + +if (CTX_VALID (mm->context)) +do_flush_tlb_mm (mm); + tb->force_mm_flush =0 ; + } +} +void arch_enter_lazy_mmu_mode (void ) {struct tlb_batch *tb =this_cpu_ptr (&tlb_batch);@@ -63,6 +88,7 @@ void arch_leave_lazy_mmu_mode(void)if (tb->tlb_nr)flush_tlb_pending (); +maybe_flush_mm_context (tb); tb->active =0 ; }@@ -80,6 +106,7 @@ static void tlb_batch_add_one(struct mm_struct *mm, unsigned long vaddr,if (unlikely (nr !=0 && mm != tb->mm)) {flush_tlb_pending (); +maybe_flush_mm_context (tb); nr =0 ; }@@ -96,15 +123,18 @@ static void tlb_batch_add_one(struct mm_struct *mm, unsigned long vaddr,if (tb->hugepage_shift != hugepage_shift) {flush_tlb_pending (); +maybe_flush_mm_context (tb); tb->hugepage_shift = hugepage_shift; nr =0 ; } tb->vaddrs[nr] = vaddr; tb->tlb_nr = ++nr; -if (nr >=TLB_BATCH_NR ) +if (nr >=TLB_BATCH_NR ) { + tpstats.num_force_mm_flush++; + tb->force_mm_flush =1 ;flush_tlb_pending (); - + } out:put_cpu_var (tlb_batch); }
Quoted 41 lines · David Miller
From: David Miller <[email protected]>
Date: Tue, 18 Jul 2017 11:39:43 -0700 (PDT)Quoted 8 lines
From: [email protected]
Date: Mon, 17 Jul 2017 15:11:03 -0700Quoted 2 lines
Thanks for digging in. I will try your patch to gather what I could share the data.
So, further inspection shows that we limit batches to 192 entries so we will never see the full extent of an unmap in the statistics for large operations.
What follows is a rough attempt to mitigate the TLB flush overhead a little bit, I've kept the statistics gathering in there for now.
The initial heuristic is that if we fill up an entire TLB batch, we switch to a full TLB context flush, which we will perform at the end of the high level unmap operation (several more batch fills can happen until then).
Maybe the cut-off should be even lower, I don't know.
One major aspect, which we've been discussing, is that this keeps us from doing multiple expensive mondo's to remote cpus during the unmap. We just do one cheap one, for the TLB context flush. Therefore, qnother thing that comes to mind is that if the MM has only executed on the local cpu, we won't end up doing remote mondos, so maybe the cut-off can be a bit higher in that case.
We still flush the TSB entries one-by-one, but that always only occurs on the local cpu. It is possible to improve this as well, but we'd need to keep track of a range.
If you look in the kernel TSB flushing, we have an optimization in the range flushing case. If the range is too large, we don't probe, instead we scan the TSB from beginning to end, and do range comparisons on the virtual address in the TAG.
So the idea is that we maintain a "lowest" and "highest" address in the TLB batch structure, and if the number of batch entries get large we go into a TSB scan mode.
Quoted 7 lines
Integrating the TSB part into this is not easy. The trouble is that the cut-off for going to TSB scan mode needs to be a lot larger than the one used for entering TLB context flush mode. This is especially the case because of how we dynamically grow the TSB based roughly upon the thread's resident set size.
Anyways, patch follows...
I applied the patch on top the v4.13-rc1-25, tried it on a M8 with 2K cpus online.
After boot up, cat /proc/cpuinfo shows
ncpus active : 2048 D$ parity tl1 : 0 I$ parity tl1 : 0 TLB PENDING : Total 738958 MM 6122 [551489 82738 34578 24007 22278
5895 5234 11163 6122]
1: 551489 2: 82738 4: 34578 8: 24007 16: 22278 32: 5895 64: 5234
128: 11163
256: 6122
While I get a map-unmap test ready to run, I noticed the "rcu_sched kthread starved"
problem -
INFO: rcu_sched detected stalls on CPUs/tasks:
0-...: (2382 GPs behind) idle«0/0/0 softirqf4/666 fqs=0
1-...: (3003 GPs behind) idle‡0/0/0 softirqV1/563 fqs=0
<repeat>
2046-...: (3598 GPs behind) idle:4/0/0 softirq$/24 fqs=0
2047-...: (3629 GPs behind) idle50/0/0 softirq!/23 fqs=0
(detected by 512, t007 jiffies, g751, c750, q"9)
CPU[ 0]: TSTATE[0000000080001600] TPC[000000000042d83c]
TNPC[000000000042d840] TASK[swapper/0:0]
TPC[arch_cpu_idle+0x7c/0xa0] O7[arch_cpu_idle+0x68/0xa0] I7[default_idle_call+0x28/0x60] RPC[cpuidle_idle_call+0x24/0xa0] <repeat>
CPU[2047]: TSTATE[0000000080001606] TPC[000000000042d83c]
TNPC[000000000042d840] TASK[swapper/2047:0]
TPC[arch_cpu_idle+0x7c/0xa0] O7[arch_cpu_idle+0x68/0xa0]
I7[default_idle_call+0x28/0x60] RPC[cpuidle_idle_call+0x24/0xa0] rcu_sched kthread starved for 16726 jiffies! g3751 c3750 f0x0 RCU_GP_WAIT_FQS(3) ->state=0x1rcu_sched S 0 9 2 0x06000000
Call Trace: [0000000000aa8004] schedule+0x24/0xc0 [0000000000aab864] schedule_timeout+0x1a4/0x320 [00000000004d9a24] rcu_gp_kthread+0x284/0x460 [00000000004908ec] kthread+0xec/0x140 [0000000000406064] ret_from_fork+0x1c/0x2c [0000000000000000] (null)
The "rcu_sched kthread starved" problem wasn't seen in v4.12 when I tested my
patch. I'm not sure how your patch could have anything to do with it, so I will try the
bare v4.13-rc1-25 kernel without your patch and see what happens.
I also plan to get hold of a large M6 that doesn't have the HW demap features
and try it there.
thanks,
-jane
Quoted 163 lines
arch/sparc/include/asm/tlb_64.h +8
-0@@ -7,6 +7,14 @@#include <asm/tlbflush.h> #include <asm/mmu_context.h> +#define TLB_PENDING_STATS_SLOTS 9 +struct tlb_pending_stats { +unsigned long total; +unsigned long num_force_mm_flush; +unsigned long hist[TLB_PENDING_STATS_SLOTS ]; +}; +extern struct tlb_pending_stats tpstats; +#ifdef CONFIG_SMP void smp_flush_tlb_pending (struct mm_struct *,unsigned long ,unsigned long *);arch/sparc/include/asm/tlbflush_64.h +1
-0@@ -11,6 +11,7 @@ struct tlb_batch {unsigned int hugepage_shift;struct mm_struct *mm;unsigned long tlb_nr; +unsigned long force_mm_flush;unsigned long active;unsigned long vaddrs[TLB_BATCH_NR ]; };arch/sparc/kernel/cpu.c +7
-1@@ -20,6 +20,7 @@#include <asm/psr.h> #include <asm/mbus.h> #include <asm/cpudata.h> +#include <asm/tlb.h> #include "kernel.h" #include "entry.h" @@ -378,6 +379,7 @@ static int show_cpuinfo(struct seq_file *m, void *__unused)"ncpus active\t: %d\n" "D$ parity tl1\t: %u\n" "I$ parity tl1\t: %u\n" +"TLB PENDING\t: Total %lu MM %lu [%lu %lu %lu %lu %lu %lu %lu %lu %lu]\n" #ifndef CONFIG_SMP"Cpu0ClkTck\t: %016lx\n" #endif@@ -392,7 +394,11 @@ static int show_cpuinfo(struct seq_file *m, void *__unused) ncpus_probed,num_online_cpus (), dcache_parity_tl1_occurred, - icache_parity_tl1_occurred + icache_parity_tl1_occurred, + tpstats.total, tpstats.num_force_mm_flush, + tpstats.hist[0 ], tpstats.hist[1 ], tpstats.hist[2 ], tpstats.hist[3 ], + tpstats.hist[4 ], tpstats.hist[5 ], tpstats.hist[6 ], tpstats.hist[7 ], + tpstats.hist[8 ] #ifndef CONFIG_SMP ,cpu_data (0 ).clock_tick #endifarch/sparc/mm/tlb.c +33
-3@@ -19,16 +19,30 @@/* Heavily inspired by the ppc64 code. */ static DEFINE_PER_CPU(struct tlb_batch, tlb_batch); +struct tlb_pending_stats tpstats;void flush_tlb_pending (void ) {struct tlb_batch *tb = &get_cpu_var (tlb_batch);struct mm_struct *mm = tb->mm; +u32 slot = tb->tlb_nr;if (!tb->tlb_nr) goto out; + tpstats.total++; +if (slot =TLB_BATCH_NR ) { + slot =8 ; + }else { + slot =ilog2 (slot); +if (slot >=8 ) + slot =8 ; + } + tpstats.hist[slot]++; +flush_tsb_user (tb); +if (tb->force_mm_flush) + goto out_nr;if (CTX_VALID (mm->context)) {if (tb->tlb_nr =1 ) {@@ -43,13 +57,24 @@ void flush_tlb_pending(void)#endif } } - +out_nr: tb->tlb_nr =0 ; out:put_cpu_var (tlb_batch); } +static void maybe_flush_mm_context (struct tlb_batch *tb) +{ +if (tb->force_mm_flush) { +struct mm_struct *mm = tb->mm; + +if (CTX_VALID (mm->context)) +do_flush_tlb_mm (mm); + tb->force_mm_flush =0 ; + } +} +void arch_enter_lazy_mmu_mode (void ) {struct tlb_batch *tb =this_cpu_ptr (&tlb_batch);@@ -63,6 +88,7 @@ void arch_leave_lazy_mmu_mode(void)if (tb->tlb_nr)flush_tlb_pending (); +maybe_flush_mm_context (tb); tb->active =0 ; }@@ -80,6 +106,7 @@ static void tlb_batch_add_one(struct mm_struct *mm, unsigned long vaddr,if (unlikely (nr !=0 && mm != tb->mm)) {flush_tlb_pending (); +maybe_flush_mm_context (tb); nr =0 ; }@@ -96,15 +123,18 @@ static void tlb_batch_add_one(struct mm_struct *mm, unsigned long vaddr,if (tb->hugepage_shift != hugepage_shift) {flush_tlb_pending (); +maybe_flush_mm_context (tb); tb->hugepage_shift = hugepage_shift; nr =0 ; } tb->vaddrs[nr] = vaddr; tb->tlb_nr = ++nr; -if (nr >=TLB_BATCH_NR ) +if (nr >=TLB_BATCH_NR ) { + tpstats.num_force_mm_flush++; + tb->force_mm_flush =1 ;flush_tlb_pending (); - + } out:put_cpu_var (tlb_batch); }
David Miller
maintainerFrom: [email protected]
Date: Thu, 20 Jul 2017 16:42:18 -0700
Quoted 2 lines
While I get a map-unmap test ready to run, I noticed the "
rcu_schedkthread starved"
I get that with the current tree, it's not due to my patch.
Quoted 1 line
I'm not sure how your patch could have anything to do with it,
It doesn't.
Ignore the warnings, it happens on my system even when it's idle.
Can you post your map-unmap test? Maybe we can add it under tools/testing/selftests/ in the kernel tree.
Quoted 6 lines · David Miller
From: [email protected]
Date: Thu, 20 Jul 2017 16:42:18 -0700Quoted 2 lines
While I get a map-unmap test ready to run, I noticed the "
rcu_schedkthread starved"I get that with the current tree, it's not due to my patch.
Okay.
Quoted 9 lines
Quoted 2 lines
I'm not sure how your patch could have anything to do with it,
It doesn't.
Ignore the warnings, it happens on my system even when it's idle.
Can you post your map-unmap test? Maybe we can add it under
tools/testing/selftests/in the kernel tree.
I'm working on it at the moment. When I get it in a reasonable shape, will post it.
thanks,
-jane