From patchwork Sat Mar 24 10:28:31 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 148501 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id 49014B74D9 for ; Sat, 24 Mar 2012 23:57:26 +1100 (EST) Received: from mail-bk0-f51.google.com (mail-bk0-f51.google.com [209.85.214.51]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id CA258B6EEC for ; Sat, 24 Mar 2012 21:29:39 +1100 (EST) Received: by mail-bk0-f51.google.com with SMTP id j10so3226350bkw.38 for ; Sat, 24 Mar 2012 03:29:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent :x-gm-message-state; bh=uG6DQS7SM8Ug0muUlFmeRyTbQ4gmvueuPh9tap+xuc8=; b=GzdNd48bauLD55UxNkt7t7V6xTAkO8X6rqfI4Hu9cBuQHuHVbHi9d3WBHI9LmUCWe7 IuIcgIcH/HE30TMt3OigM4ypdcvSqEDNpo8384F75wDHhIi+yr0MvUQ0JYbQ0QaRDAp/ 0VN+qHSy+fnrM0e6Ysm0XklqvQ8RNSncCWHg1T5dGA84/dBZuexXZEhlDU/hba7YYX0b /6regVc4eyFh6nNjzYjhf6oh4g2aN6m2UG1FONtmLN6IrN20BOTUKsElEEg13Dv1PFAg l9HXScY9I+wKiegyIyP0eH8jnIRXKVNoWsZ+Q5bJ0hvHFYnk5huKvHZ8U7lc4m6LLqG8 76rg== Received: by 10.204.152.12 with SMTP id e12mr5881541bkw.29.1332584979079; Sat, 24 Mar 2012 03:29:39 -0700 (PDT) Received: from localhost ([83.149.9.160]) by mx.google.com with ESMTPS id u5sm20921357bka.5.2012.03.24.03.29.35 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 24 Mar 2012 03:29:38 -0700 (PDT) Date: Sat, 24 Mar 2012 14:28:31 +0400 From: Anton Vorontsov To: Andrew Morton , Oleg Nesterov Subject: [PATCH 03/10] powerpc: Use clear_tasks_mm_cpumask() Message-ID: <20120324102831.GC29067@lizard> References: <20120324102609.GA28356@lizard> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20120324102609.GA28356@lizard> User-Agent: Mutt/1.5.21 (2010-09-15) X-Gm-Message-State: ALoCoQlSR8k1t9bpuyuG3mhgtUfwxWyyvnZY1sc3eHiSLYS+b+RPq4AMIx0AQfqn2IVFOJTRQ/tT X-Mailman-Approved-At: Sat, 24 Mar 2012 23:53:15 +1100 Cc: Mike Frysinger , Peter Zijlstra , user-mode-linux-devel@lists.sourceforge.net, linux-sh@vger.kernel.org, Richard Weinberger , linux-kernel@vger.kernel.org, uclinux-dist-devel@blackfin.uclinux.org, linux-mm@kvack.org, Paul Mundt , John Stultz , KOSAKI Motohiro , Russell King , linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Current CPU hotplug code has some task->mm handling issues: 1. Working with task->mm w/o getting mm or grabing the task lock is dangerous as ->mm might disappear (exit_mm() assigns NULL under task_lock(), so tasklist lock is not enough). We can't use get_task_mm()/mmput() pair as mmput() might sleep, so we must take the task lock while handle its mm. 2. Checking for process->mm is not enough because process' main thread may exit or detach its mm via use_mm(), but other threads may still have a valid mm. To fix this we would need to use find_lock_task_mm(), which would walk up all threads and returns an appropriate task (with task lock held). clear_tasks_mm_cpumask() has all the issues fixed, so let's use it. Suggested-by: Oleg Nesterov Signed-off-by: Anton Vorontsov --- arch/powerpc/mm/mmu_context_nohash.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/arch/powerpc/mm/mmu_context_nohash.c b/arch/powerpc/mm/mmu_context_nohash.c index 5b63bd3..e779642 100644 --- a/arch/powerpc/mm/mmu_context_nohash.c +++ b/arch/powerpc/mm/mmu_context_nohash.c @@ -333,9 +333,7 @@ static int __cpuinit mmu_context_cpu_notify(struct notifier_block *self, unsigned long action, void *hcpu) { unsigned int cpu = (unsigned int)(long)hcpu; -#ifdef CONFIG_HOTPLUG_CPU - struct task_struct *p; -#endif + /* We don't touch CPU 0 map, it's allocated at aboot and kept * around forever */ @@ -358,12 +356,7 @@ static int __cpuinit mmu_context_cpu_notify(struct notifier_block *self, stale_map[cpu] = NULL; /* We also clear the cpu_vm_mask bits of CPUs going away */ - read_lock(&tasklist_lock); - for_each_process(p) { - if (p->mm) - cpumask_clear_cpu(cpu, mm_cpumask(p->mm)); - } - read_unlock(&tasklist_lock); + clear_tasks_mm_cpumask(cpu); break; #endif /* CONFIG_HOTPLUG_CPU */ }