From d145a58240e4c60084530d88c2eadaa9d9481be2 Mon Sep 17 00:00:00 2001 From: Pavel Tatashin Date: Tue, 13 Jun 2017 13:15:29 -0700 Subject: [PATCH] Revert "sparc64: Restrict number of processes" This reverts commit 8fd2a52b3bcc87f809298093a3be374d08d030f2. The next patch set fixes the issue that limits the maximum number of processes to number of context. Thefore revert. Orabug: 24523680 Conflicts: arch/sparc/mm/tsb.c Signed-off-by: Pavel Tatashin Reviewed-by: Steve Sistare Signed-off-by: Allen Pais --- arch/sparc/include/asm/mmu_context_64.h | 1 - arch/sparc/mm/init_64.c | 10 +------ arch/sparc/mm/tsb.c | 35 +++---------------------- 3 files changed, 4 insertions(+), 42 deletions(-) diff --git a/arch/sparc/include/asm/mmu_context_64.h b/arch/sparc/include/asm/mmu_context_64.h index 251bde36d4dc..260b32063433 100644 --- a/arch/sparc/include/asm/mmu_context_64.h +++ b/arch/sparc/include/asm/mmu_context_64.h @@ -17,7 +17,6 @@ static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk) extern spinlock_t ctx_alloc_lock; extern unsigned long tlb_context_cache; extern unsigned long ctx_nr_bits; -extern int max_user_nctx; extern unsigned long mmu_context_bmap[]; void get_new_mmu_context(struct mm_struct *mm); diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c index 1509da6d3ff3..0e42c840cb32 100644 --- a/arch/sparc/mm/init_64.c +++ b/arch/sparc/mm/init_64.c @@ -29,7 +29,6 @@ #include #include #include -#include #include #include @@ -58,7 +57,6 @@ #include "init_64.h" unsigned long ctx_nr_bits = DEFAULT_CTX_NR_BITS; -int max_user_nctx; unsigned long kern_linear_pte_xor[4] __read_mostly; static unsigned long page_cache4v_flag; @@ -912,12 +910,8 @@ out: mm->context.sparc64_ctx_val = new_ctx | orig_pgsz_bits; spin_unlock(&ctx_alloc_lock); - if (unlikely(new_version)) { - pr_err_ratelimited("Context ID wrapped: %s(%d) CPU%d\n", - current->comm, task_pid_nr(current), - smp_processor_id()); + if (unlikely(new_version)) smp_new_mmu_context_version(); - } } static int numa_enabled = 1; @@ -2679,8 +2673,6 @@ void __init paging_init(void) sun4u_linear_pte_xor_finalize(); } - max_user_nctx = (1UL << ctx_nr_bits) - 1; - /* Flush the TLBs and the 4M TSB so that the updated linear * pte XOR settings are realized for all mappings. */ diff --git a/arch/sparc/mm/tsb.c b/arch/sparc/mm/tsb.c index cbdc1665a452..021895beaabc 100644 --- a/arch/sparc/mm/tsb.c +++ b/arch/sparc/mm/tsb.c @@ -14,7 +14,6 @@ #include #include #include -#include extern struct tsb swapper_tsb[KERNEL_TSB_NENTRIES]; @@ -616,8 +615,6 @@ retry_tsb_alloc: } } -static atomic_t nctxs = ATOMIC_INIT(0); - int init_new_context(struct task_struct *tsk, struct mm_struct *mm) { unsigned long mm_rss = get_mm_rss(mm); @@ -626,24 +623,6 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm) unsigned long saved_thp_pte_count; #endif unsigned int i; - int max_nctx = max_user_nctx; - int ret = 0; - int uid = current_cred()->uid.val; - - /* - * In the worst case, user(s) might use up all contexts and make the - * system unusable. Give root extra 100 grace ctxs to recover the - * system. E.g by killing some user processes. - */ - if (uid != 0) - max_nctx -= 100; - - if (unlikely(max_nctx <= atomic_inc_return(&nctxs))) { - pr_warn_ratelimited("Reached max(%d) number of processes for %s\n", - max_nctx, uid ? "users" : "root"); - ret = -EAGAIN; - goto error; - } spin_lock_init(&mm->context.lock); @@ -680,16 +659,10 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm) (saved_hugetlb_pte_count + saved_thp_pte_count) * REAL_HPAGE_PER_HPAGE); #endif + if (unlikely(!mm->context.tsb_block[MM_TSB_BASE].tsb)) + return -ENOMEM; - if (unlikely(!mm->context.tsb_block[MM_TSB_BASE].tsb)) { - ret = -ENOMEM; - goto error; - } - - return ret; -error: - atomic_dec(&nctxs); - return ret; + return 0; } static void tsb_destroy_one(struct tsb_config *tp) @@ -711,8 +684,6 @@ void destroy_context(struct mm_struct *mm) for (i = 0; i < MM_NUM_TSBS; i++) tsb_destroy_one(&mm->context.tsb_block[i]); - atomic_dec(&nctxs); - spin_lock_irqsave(&ctx_alloc_lock, flags); if (CTX_VALID(mm->context)) { -- 2.50.1