From patchwork Mon Apr 23 07:09:43 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 8016 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 752A323E49 for ; Mon, 23 Apr 2012 07:11:01 +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 3D2FDA188A6 for ; Mon, 23 Apr 2012 07:11:01 +0000 (UTC) Received: by mail-iy0-f180.google.com with SMTP id e36so22276722iag.11 for ; Mon, 23 Apr 2012 00:11:01 -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=Uix4IYdDC89Afv9KLRb9Bc1Xys6Ci5+2CAj85DjTWWc=; b=SzgR5Eh+29t3Egfe9j0Weu60qU+ujDCi3ouZTr9gLrovXOCtRTGj9GL3IxA7Z9KfkC 2yoN+gk2dD15/qyShmUKPioRGwt2dYPpYysEs4VIZbDcLlfPasYifModwvoPwFUihOCO z/5Ui5ZHhmjhF9o96th4WDZ4K2MudMC146lL6c8wgZsojpNt+fJ79rRZZl4Wy36Gy35W zR/nJFqpV/OqxR1A83XNd1ElE8UQDszUZG5W96Z1w7QeADn7rE7EjNp4N4fc1J3SgynI JpovpennFW565ymDLNv+7OFKB44dZBWJmjlAzJ+ceZAwgq7YL6Br9NwYRqkw8vf8xKxm s1DQ== Received: by 10.50.154.167 with SMTP id vp7mr5394874igb.55.1335165061023; Mon, 23 Apr 2012 00:11:01 -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 x6csp91291ibt; Mon, 23 Apr 2012 00:11:00 -0700 (PDT) Received: by 10.60.26.231 with SMTP id o7mr20974734oeg.31.1335165060392; Mon, 23 Apr 2012 00:11:00 -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.11.00 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 23 Apr 2012 00:11:00 -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:11:00 -0700 (PDT) Received: by 10.182.154.5 with SMTP id vk5mr351189obb.60.1335165060242; Mon, 23 Apr 2012 00:11:00 -0700 (PDT) Received: from localhost ([69.199.155.45]) by mx.google.com with ESMTPS id k2sm15218411obl.14.2012.04.23.00.10.58 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 23 Apr 2012 00:10:59 -0700 (PDT) Date: Mon, 23 Apr 2012 00:09:43 -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 9/9] um: Properly check all process' threads for a live mm Message-ID: <20120423070943.GI30752@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: ALoCoQlBV17I0t/CXAI5NVcN/kyBYGoTL0mjoi9zFk/5yrtWkKfN0Yf/hn3Wa8lSbMwZtBPoqhn2 kill_off_processes() might miss a valid process, this is because checking for process->mm is not enough. Process' main thread may exit or detach its mm via use_mm(), but other threads may still have a valid mm. To catch this we use find_lock_task_mm(), which walks up all threads and returns an appropriate task (with task lock held). Suggested-by: Oleg Nesterov Signed-off-by: Anton Vorontsov --- arch/um/kernel/reboot.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/arch/um/kernel/reboot.c b/arch/um/kernel/reboot.c index 1411f4e..3d15243 100644 --- a/arch/um/kernel/reboot.c +++ b/arch/um/kernel/reboot.c @@ -6,6 +6,7 @@ #include "linux/sched.h" #include "linux/spinlock.h" #include "linux/slab.h" +#include "linux/oom.h" #include "kern_util.h" #include "os.h" #include "skas.h" @@ -25,13 +26,13 @@ static void kill_off_processes(void) read_lock(&tasklist_lock); for_each_process(p) { - task_lock(p); - if (!p->mm) { - task_unlock(p); + struct task_struct *t; + + t = find_lock_task_mm(p); + if (!t) continue; - } - pid = p->mm->context.id.u.pid; - task_unlock(p); + pid = t->mm->context.id.u.pid; + task_unlock(t); os_kill_ptraced_process(pid, 1); } read_unlock(&tasklist_lock);