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 *spacemodification,notoneachcputheaddressspacehasrunon. *OnlytheTLBflushneedsthattreatment.
*/
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);
}
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 *allocationfailureisverybadbehavior.Justback *downtoa0-orderallocationandforcenoTSB *growingforthisaddressspace.
*/ 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 *memorypressuresodon'ttrytogrowanymore.
*/ 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 *growinganexistingTSBthelockingisverytricky, *soWATCHOUT! * *Wehavetoholdmm->context.lockwhilecommittingtothe *newTSB,thissynchronizesuswithprocessorsin *flush_tsb_user()andswitch_mm()forthisaddressspace. * *Butevenwiththatlockheld,processorsrunasynchronously *accessingtheoldTSBviaTLBmisshandling.ThisisOK *becausethoseactionsarejustpropagatingstatefromthe *LinuxpagetablesintotheTSB,pagetablemappingsarenot *beingchanged.Ifarealfaultoccurs,theprocessorwill *synchronizewithuswhenithitsflush_tsb_user(),thisis *alsotrueforthecasewherevmscanismodifyingthepage *tables.Theonlythingweneedtobecarefulwithisto *skipanylockedTSBentriesduringcopy_tsb(). * *WhenwefinishcommittingtothenewTSB,wehavetodrop *thelockandaskallothercpusrunningthisaddressspace *toruntsb_context_switch()toseethenewTSBtable.
*/
spin_lock_irqsave(&mm->context.lock, flags);
/* Handle multiple threads trying to grow the TSB at the same time. *Onewillgetinherefirst,andbumpthesizeandtheRSSlimit. *Theotherswillgetinherenextandhitthischeck.
*/ 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 *frominit_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 *willre-incrementthecountersastheparentPTEsare *copiedintothechildaddressspace.
*/
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,soweneedtozeroouttheTSBpointerorelsetsb_grow() *willbeconfusedandthinkthereisanolderTSBtofreeup.
*/ 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 *growittothatsizeonthefirstpagefaultanyways.
*/
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.