Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 348277
b: refs/heads/master
c: 53a59fc
h: refs/heads/master
i:
  348275: 06ee7aa
v: v3
  • Loading branch information
Michal Hocko authored and Linus Torvalds committed Jan 5, 2013
1 parent b1e54fe commit 2195e0e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a458431e176ddb27e8ef8b98c2a681b217337393
refs/heads/master: 53a59fc67f97374758e63a9c785891ec62324c81
9 changes: 9 additions & 0 deletions trunk/include/asm-generic/tlb.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ struct mmu_gather_batch {
#define MAX_GATHER_BATCH \
((PAGE_SIZE - sizeof(struct mmu_gather_batch)) / sizeof(void *))

/*
* Limit the maximum number of mmu_gather batches to reduce a risk of soft
* lockups for non-preemptible kernels on huge machines when a lot of memory
* is zapped during unmapping.
* 10K pages freed at once should be safe even without a preemption point.
*/
#define MAX_GATHER_BATCH_COUNT (10000UL/MAX_GATHER_BATCH)

/* struct mmu_gather is an opaque type used by the mm code for passing around
* any data needed by arch specific code for tlb_remove_page.
*/
Expand All @@ -96,6 +104,7 @@ struct mmu_gather {
struct mmu_gather_batch *active;
struct mmu_gather_batch local;
struct page *__pages[MMU_GATHER_BUNDLE];
unsigned int batch_count;
};

#define HAVE_GENERIC_MMU_GATHER
Expand Down
5 changes: 5 additions & 0 deletions trunk/mm/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,14 @@ static int tlb_next_batch(struct mmu_gather *tlb)
return 1;
}

if (tlb->batch_count == MAX_GATHER_BATCH_COUNT)
return 0;

batch = (void *)__get_free_pages(GFP_NOWAIT | __GFP_NOWARN, 0);
if (!batch)
return 0;

tlb->batch_count++;
batch->next = NULL;
batch->nr = 0;
batch->max = MAX_GATHER_BATCH;
Expand Down Expand Up @@ -216,6 +220,7 @@ void tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, bool fullmm)
tlb->local.nr = 0;
tlb->local.max = ARRAY_SIZE(tlb->__pages);
tlb->active = &tlb->local;
tlb->batch_count = 0;

#ifdef CONFIG_HAVE_RCU_TABLE_FREE
tlb->batch = NULL;
Expand Down

0 comments on commit 2195e0e

Please sign in to comment.