for (idx = 0; idx < KERNEL_TSB_NENTRIES; idx++) { struct tsb *ent = &swapper_tsb[idx]; unsignedlong match = idx << 13;
match |= (ent->tag << 22); if (match >= start && match < end)
ent->tag = (1UL << TSB_TAG_INVALID_BIT);
}
}
/* TSB flushes need only occur on the processor initiating the address * space modification, not on each cpu the address space has run on. * Only the TLB flush needs that treatment.
*/
hpage_entries = 1 << (hugepage_shift - hash_shift); for (i = 0; i < hpage_entries; i++)
__flush_tsb_one_entry(tsb, v + (i << hash_shift), hash_shift,
nentries);
}
/* Use the smallest page size that can map the whole TSB * in one TLB entry.
*/ switch (tsb_bytes) { case 8192 << 0:
tsb_reg = 0x0UL; #ifdef DCACHE_ALIASING_POSSIBLE
base += (tsb_paddr & 8192); #endif
page_sz = 8192; break;
/* When the RSS of an address space exceeds tsb_rss_limit for a TSB, * do_sparc64_fault() invokes this routine to try and grow it. * * When we reach the maximum TSB size supported, we stick ~0UL into * tsb_rss_limit for that TSB so the grow checks in do_sparc64_fault() * will not trigger any longer. * * The TSB can be anywhere from 8K to 1MB in size, in increasing powers * of two. The TSB must be aligned to its size, so f.e. a 512K TSB * must be 512K aligned. It also must be physically contiguous, so we * cannot use vmalloc(). * * The idea here is to grow the TSB when the RSS of the process approaches * the number of entries that the current TSB can hold at once. Currently, * we trigger when the RSS hits 3/4 of the TSB capacity.
*/ void tsb_grow(struct mm_struct *mm, unsignedlong tsb_index, unsignedlong rss)
{ unsignedlong max_tsb_size = 1 * 1024 * 1024; unsignedlong new_size, old_size, flags; struct tsb *old_tsb, *new_tsb; unsignedlong new_cache_index, old_cache_index; unsignedlong new_rss_limit;
gfp_t gfp_flags;
new_tsb = kmem_cache_alloc_node(tsb_caches[new_cache_index],
gfp_flags, numa_node_id()); if (unlikely(!new_tsb)) { /* Not being able to fork due to a high-order TSB * allocation failure is very bad behavior. Just back * down to a 0-order allocation and force no TSB * growing for this address space.
*/ if (mm->context.tsb_block[tsb_index].tsb == NULL &&
new_cache_index > 0) {
new_cache_index = 0;
new_size = 8192;
new_rss_limit = ~0UL; goto retry_tsb_alloc;
}
/* If we failed on a TSB grow, we are under serious * memory pressure so don't try to grow any more.
*/ if (mm->context.tsb_block[tsb_index].tsb != NULL)
mm->context.tsb_block[tsb_index].tsb_rss_limit = ~0UL; return;
}
/* Mark all tags as invalid. */
tsb_init(new_tsb, new_size);
/* Ok, we are about to commit the changes. If we are * growing an existing TSB the locking is very tricky, * so WATCH OUT! * * We have to hold mm->context.lock while committing to the * new TSB, this synchronizes us with processors in * flush_tsb_user() and switch_mm() for this address space. * * But even with that lock held, processors run asynchronously * accessing the old TSB via TLB miss handling. This is OK * because those actions are just propagating state from the * Linux page tables into the TSB, page table mappings are not * being changed. If a real fault occurs, the processor will * synchronize with us when it hits flush_tsb_user(), this is * also true for the case where vmscan is modifying the page * tables. The only thing we need to be careful with is to * skip any locked TSB entries during copy_tsb(). * * When we finish committing to the new TSB, we have to drop * the lock and ask all other cpus running this address space * to run tsb_context_switch() to see the new TSB table.
*/
spin_lock_irqsave(&mm->context.lock, flags);
/* Handle multiple threads trying to grow the TSB at the same time. * One will get in here first, and bump the size and the RSS limit. * The others will get in here next and hit this check.
*/ if (unlikely(old_tsb &&
(rss < mm->context.tsb_block[tsb_index].tsb_rss_limit))) {
spin_unlock_irqrestore(&mm->context.lock, flags);
/* If old_tsb is NULL, we're being invoked for the first time * from init_new_context().
*/ if (old_tsb) { /* Reload it on the local cpu. */
tsb_context_switch(mm);
/* Now force other processors to do the same. */
preempt_disable();
smp_tsb_sync(mm);
preempt_enable();
/* Now it is safe to free the old tsb. */
kmem_cache_free(tsb_caches[old_cache_index], old_tsb);
}
}
#ifdefined(CONFIG_HUGETLB_PAGE) || defined(CONFIG_TRANSPARENT_HUGEPAGE) /* We reset them to zero because the fork() page copying * will re-increment the counters as the parent PTEs are * copied into the child address space.
*/
saved_hugetlb_pte_count = mm->context.hugetlb_pte_count;
saved_thp_pte_count = mm->context.thp_pte_count;
mm->context.hugetlb_pte_count = 0;
mm->context.thp_pte_count = 0;
/* copy_mm() copies over the parent's mm_struct before calling * us, so we need to zero out the TSB pointer or else tsb_grow() * will be confused and think there is an older TSB to free up.
*/ for (i = 0; i < MM_NUM_TSBS; i++)
mm->context.tsb_block[i].tsb = NULL;
/* If this is fork, inherit the parent's TSB size. We would * grow it to that size on the first page fault anyways.
*/
tsb_grow(mm, MM_TSB_BASE, mm_rss);
for (i = 0; i < MM_NUM_TSBS; i++)
tsb_destroy_one(&mm->context.tsb_block[i]);
spin_lock_irqsave(&ctx_alloc_lock, flags);
if (CTX_VALID(mm->context)) { unsignedlong nr = CTX_NRBITS(mm->context);
mmu_context_bmap[nr>>6] &= ~(1UL << (nr & 63));
}
spin_unlock_irqrestore(&ctx_alloc_lock, flags);
/* If ADI tag storage was allocated for this task, free it */ if (mm->context.tag_store) {
tag_storage_desc_t *tag_desc; unsignedlong max_desc; unsignedchar *tags;
tag_desc = mm->context.tag_store;
max_desc = PAGE_SIZE/sizeof(tag_storage_desc_t); for (i = 0; i < max_desc; i++) {
tags = tag_desc->tags;
tag_desc->tags = NULL;
kfree(tags);
tag_desc++;
}
kfree(mm->context.tag_store);
mm->context.tag_store = NULL;
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.