From patchwork Mon Apr 23 07:09:15 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 8013 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 C5FF323E49 for ; Mon, 23 Apr 2012 07:10:32 +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 8E2E3A187EA for ; Mon, 23 Apr 2012 07:10:32 +0000 (UTC) Received: by mail-iy0-f180.google.com with SMTP id e36so22276722iag.11 for ; Mon, 23 Apr 2012 00:10:32 -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=uzNTdZ961efGe12yVzEJF/VruKkazJNuBt3/xv4231M=; b=AT1xdTjmxvMVhz/7IWUbKt7ZKryuSK/QMpEyDGDjzTE/5mHCNtuiS4OsBK6pKkC+Tw +i5LhBY0SGyKVWJ+ToP1Edk7Yj1Jgs/MRb+HhZRS+nWtCE5q/QTct8E8nho/+Qe6P4lC OQUyJaJaVYOicrGOyY9ZfsG9BEKO/jrX4EKvJd+i6K9qmZGjocdlsHRrM7438UdS9PNH hA0eX7j5ANhd0EEuDcg6iLlzVw4MdqTkQ9FJl/kIA/4tkX1oZe+gQ+vgrI6JHdUZM+yI JohTK1blqlyqAYDE2Y5Bq+/H4xe9Gv+TzuDFS6wjNC98TxPLQ8e+BoIUWykGxGFKFkbD /yhg== Received: by 10.50.154.167 with SMTP id vp7mr5393989igb.55.1335165032365; Mon, 23 Apr 2012 00:10:32 -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 x6csp91260ibt; Mon, 23 Apr 2012 00:10:32 -0700 (PDT) Received: by 10.182.122.4 with SMTP id lo4mr1656630obb.24.1335165031916; Mon, 23 Apr 2012 00:10:31 -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.10.31 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 23 Apr 2012 00:10:31 -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:10:31 -0700 (PDT) Received: by 10.182.119.6 with SMTP id kq6mr5385273obb.67.1335165031755; Mon, 23 Apr 2012 00:10:31 -0700 (PDT) Received: from localhost ([69.199.155.45]) by mx.google.com with ESMTPS id o9sm15206446obd.21.2012.04.23.00.10.30 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 23 Apr 2012 00:10:31 -0700 (PDT) Date: Mon, 23 Apr 2012 00:09:15 -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 6/9] blackfin: Fix possible deadlock in decode_address() Message-ID: <20120423070915.GF30752@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: ALoCoQk9HnCNsJ06c9PuajSF4PnCramOWwn2lZBQCicNQiDVje3eR1Mf+OJqpGrcQUkGL1zbc31/ Oleg Nesterov found an interesting deadlock possibility: > sysrq_showregs_othercpus() does smp_call_function(showacpu) > and showacpu() show_stack()->decode_address(). Now suppose that IPI > interrupts the task holding read_lock(tasklist). To fix this, blackfin should not grab the write_ variant of the tasklist lock, read_ one is enough. Suggested-by: Oleg Nesterov Signed-off-by: Anton Vorontsov --- arch/blackfin/kernel/trace.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/blackfin/kernel/trace.c b/arch/blackfin/kernel/trace.c index d08f0e3..f7f7a18 100644 --- a/arch/blackfin/kernel/trace.c +++ b/arch/blackfin/kernel/trace.c @@ -29,7 +29,7 @@ void decode_address(char *buf, unsigned long address) { struct task_struct *p; struct mm_struct *mm; - unsigned long flags, offset; + unsigned long offset; struct rb_node *n; #ifdef CONFIG_KALLSYMS @@ -113,7 +113,7 @@ void decode_address(char *buf, unsigned long address) * mappings of all our processes and see if we can't be a whee * bit more specific */ - write_lock_irqsave(&tasklist_lock, flags); + read_lock(&tasklist_lock); for_each_process(p) { struct task_struct *t; @@ -186,7 +186,7 @@ __continue: sprintf(buf, "/* kernel dynamic memory */"); done: - write_unlock_irqrestore(&tasklist_lock, flags); + read_unlock(&tasklist_lock); } #define EXPAND_LEN ((1 << CONFIG_DEBUG_BFIN_HWTRACE_EXPAND_LEN) * 256 - 1)