From patchwork Mon Apr 23 07:08:38 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 8010 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 8B5FF23E49 for ; Mon, 23 Apr 2012 07:09:55 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id 51F4FA187EB for ; Mon, 23 Apr 2012 07:09:55 +0000 (UTC) Received: by mail-iy0-f180.google.com with SMTP id e36so22276722iag.11 for ; Mon, 23 Apr 2012 00:09:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf: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=Lid8xc67VjdNwbArxyMTyLqvbgehszbgYMiZx8XQ4vb7aTuBPXaNGKuhgtwRbXFGw7 RukK+hnPpAIsZ785N3u/+6Q1tEDOSOt1Cp9zQrHxK/Vtpc6qw+aBJOVQ0Xa++8v84aSe zkQCWcyctIqQVKBiqOzrh5pGLVufEkGfc9BpprCaDyBeyog9UYHRBbF6piUD2pVPJVN5 1mzj4Z7BADCwTywYtWCFCbL+VMca6YpDyjgOKTbYg2+JWb5hgDysEP4EziBbmlYP/juA Ils+54I0IYgtCm0ehVSMG80JuO2gtk4pEIF3Xl25nqlBcEcRuhzW5sEmYy5PqYR0MbNs M+pA== Received: by 10.50.185.233 with SMTP id ff9mr5395008igc.55.1335164995123; Mon, 23 Apr 2012 00:09:55 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.137.198 with SMTP id x6csp91217ibt; Mon, 23 Apr 2012 00:09:54 -0700 (PDT) Received: by 10.60.27.38 with SMTP id q6mr22065106oeg.20.1335164994611; Mon, 23 Apr 2012 00:09:54 -0700 (PDT) Received: from mail-ob0-f178.google.com (mail-ob0-f178.google.com [209.85.214.178]) by mx.google.com with ESMTPS id i9si7903064oba.81.2012.04.23.00.09.54 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 23 Apr 2012 00:09:54 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.214.178 is neither permitted nor denied by best guess record for domain of anton.vorontsov@linaro.org) client-ip=209.85.214.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.214.178 is neither permitted nor denied by best guess record for domain of anton.vorontsov@linaro.org) smtp.mail=anton.vorontsov@linaro.org Received: by mail-ob0-f178.google.com with SMTP id wc18so9042021obb.37 for ; Mon, 23 Apr 2012 00:09:54 -0700 (PDT) Received: by 10.182.174.71 with SMTP id bq7mr175402obc.29.1335164994434; Mon, 23 Apr 2012 00:09:54 -0700 (PDT) Received: from localhost ([69.199.155.45]) by mx.google.com with ESMTPS id qa9sm9322376obc.17.2012.04.23.00.09.52 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 23 Apr 2012 00:09:53 -0700 (PDT) Date: Mon, 23 Apr 2012 00:08:38 -0700 From: Anton Vorontsov To: Andrew Morton , Oleg Nesterov Cc: Russell King , Mike Frysinger , Benjamin Herrenschmidt , Richard Weinberger , Paul Mundt , Peter Zijlstra , KOSAKI Motohiro , John Stultz , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, uclinux-dist-devel@blackfin.uclinux.org, linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org, user-mode-linux-devel@lists.sourceforge.net, linaro-kernel@lists.linaro.org, patches@linaro.org, linux-mm@kvack.org Subject: [PATCH 3/9] powerpc: Use clear_tasks_mm_cpumask() Message-ID: <20120423070838.GC30752@lizard> References: <20120423070641.GA27702@lizard> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20120423070641.GA27702@lizard> User-Agent: Mutt/1.5.21 (2010-09-15) X-Gm-Message-State: ALoCoQkxbRw3SnIBvvyRBNOSxJiembUWDn6g2629ZscOq5F6ed13PTlrgfOxU1uXUTx8NyXxNnNM 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 */ }