Received: by 10.192.165.148 with SMTP id m20csp4299403imm; Mon, 23 Apr 2018 23:49:48 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+Uy7VebSiwgAO08pAtXJpLytzbg1uKtiqbDY0m7l8wYbu4QVZLsaR06k8qJZPEHuCkyqKQ X-Received: by 2002:a17:902:28e8:: with SMTP id f95-v6mr20860923plb.250.1524552588681; Mon, 23 Apr 2018 23:49:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524552588; cv=none; d=google.com; s=arc-20160816; b=bMNVopZ8LDlydbPHo4TGgvlR3+xNhZF1WKQ5PSL7ATiQsTLmGNCCR+kNzJzcmjKqdT mK7K4hLK1t4OnJBMcTxQPDC1Ff4hadjvKGVg8nJWpxCklUFekBrt2lNOAGchcn394jPx q9iNoWKb5BMwJZrPIMUM7YD8u6WpRuiC+yR9hVXXOANEdiaHl+EXurJsAA8CpHAdskBD SoG+wRCEk4sRBQOL4XSjJlZstrIceGNIQqMU0tc/cZlJMhLAwm6gOwCEzr4FNOciycNh es1bYc/9RKxLhL6jb/pNC+aeVfKnz20M4Q62W9L9f7qWWVczIs8PpAZGb8iQJfjhlXBx DJJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature:arc-authentication-results; bh=j2RB7QNa1B1iUv/pXaUknEK6jzIkrhuVHgVnxk4kVcc=; b=BIOtwhgvtaaWQzTxRwWN4fozyGQE3KvkCA+a/yL34TRt5nLwUmyMhxQRkYkl9ZOAyr 9VAnRFppQZpVs4qIBHlar5M9ZndIt4j8xn6AMXYdbxNxhvQf/TJR/Q4ZCbYnBxf7uCI0 KpvvXR58BqlOD8MsMRrcJY/oVPuMoTOorsqpGThk8ywTvWu1fiu/mHHvjHy5y+RGeFv5 9hWbelnUYoC0+ou4OgQEZqFbq9UKZhoQfeJGo2kS9NGuIcgEbHhL01HcUJ6EanVvKxHR sVYHuxRjktuIac6cYiw0r0fv8wmjpjcs0Hl93d+vjascoBKX3++KXIMaEapZVLWSBKK7 6B0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=A1sg38if; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 7-v6si13091585pll.132.2018.04.23.23.49.34; Mon, 23 Apr 2018 23:49:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=A1sg38if; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756166AbeDXGAs (ORCPT + 99 others); Tue, 24 Apr 2018 02:00:48 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:44381 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752110AbeDXGAp (ORCPT ); Tue, 24 Apr 2018 02:00:45 -0400 Received: by mail-pf0-f193.google.com with SMTP id p15so11332457pff.11; Mon, 23 Apr 2018 23:00:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:in-reply-to:references :organization:mime-version:content-transfer-encoding; bh=j2RB7QNa1B1iUv/pXaUknEK6jzIkrhuVHgVnxk4kVcc=; b=A1sg38ifzZwfWFTBw+ljDuuRXEEm6PiPstGajVYL+pck6Rlm93Zf7ZJ45ZYObN58az /aCMoPBA3fhGqeB8on5vRkU6HVOl6gqF5PTh92Tlj5SJHXNLDjYI0jvinNxKkT5FU9yy 5mL0Qs/3ZywCmL+qwGg/okRWu6kQXyaDK0Y+F27L+s6OTmUThYQT8HCLzYcwKnXS21xL ya4fQouoMPecQlXqLpL+5V9MtBBTNuJSJ8qoXZwihFoLDxZpmrrMshc1t3GSKAXsvX5i fw2DL+MjtxSKTTtQHNQvkR8qcUxaUzipGhENSh3r/Sw9YPR5SZkRyFxFsqsP9WAjV0co 92Ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:organization:mime-version:content-transfer-encoding; bh=j2RB7QNa1B1iUv/pXaUknEK6jzIkrhuVHgVnxk4kVcc=; b=ROjKXKkMRQPtSTRdQqsSRnXy2Zw0u+6uCGAcWSzB5r2N25VMh2QJtVxwtScNbb6MQe auMkm/m2El+j2pA7Kzl6odT5vpsdEXEBrCDXZVOb62ZFyn7cgSl2RenTXE1WTiN2QJcB hBo7RE/mdp6noZyWul+9R8j0NW86hwcmIZWDl4d5n6vgNTwekOINPkwpZGqZUAbk4PFr srARGTgMKhmZLju6NS9LUskDFa154wDNmD23p7Dgn9da5LFKLriAxXf/K2pOHgf8r9Qt kMV1QWQmS7wo8KEcqhwHahFFrWMDK3+uKOuaDKY8zXMFJZGUroU/yjWZDk728r29Xyy7 +Tkw== X-Gm-Message-State: ALQs6tA1ZuGWqKtdWUwCA2l7GAH3TYJX5j9+ha40/Dk8K1XUzC6HTzfu uvxVfUWz5T7QtFRm8p3eEDU= X-Received: by 2002:a17:902:2947:: with SMTP id g65-v6mr20853931plb.346.1524549644684; Mon, 23 Apr 2018 23:00:44 -0700 (PDT) Received: from roar.ozlabs.ibm.com (59-102-70-78.tpgi.com.au. [59.102.70.78]) by smtp.gmail.com with ESMTPSA id h191sm20984256pgc.11.2018.04.23.23.00.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Apr 2018 23:00:43 -0700 (PDT) Date: Tue, 24 Apr 2018 16:00:34 +1000 From: Nicholas Piggin To: Shilpasri G Bhat Cc: rjw@rjwysocki.net, viresh.kumar@linaro.org, benh@kernel.crashing.org, mpe@ellerman.id.au, linux-pm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, ppaidipe@linux.vnet.ibm.com, svaidy@linux.vnet.ibm.com Subject: Re: [PATCH] cpufreq: powernv: Fix the hardlockup by synchronus smp_call in timer interrupt Message-ID: <20180424160034.6e9d2274@roar.ozlabs.ibm.com> In-Reply-To: <1524544906-31512-1-git-send-email-shilpa.bhat@linux.vnet.ibm.com> References: <1524544906-31512-1-git-send-email-shilpa.bhat@linux.vnet.ibm.com> Organization: IBM X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 24 Apr 2018 10:11:46 +0530 Shilpasri G Bhat wrote: > gpstate_timer_handler() uses synchronous smp_call to set the pstate > on the requested core. This causes the below hard lockup: > > [c000003fe566b320] [c0000000001d5340] smp_call_function_single+0x110/0x180 (unreliable) > [c000003fe566b390] [c0000000001d55e0] smp_call_function_any+0x180/0x250 > [c000003fe566b3f0] [c000000000acd3e8] gpstate_timer_handler+0x1e8/0x580 > [c000003fe566b4a0] [c0000000001b46b0] call_timer_fn+0x50/0x1c0 > [c000003fe566b520] [c0000000001b4958] expire_timers+0x138/0x1f0 > [c000003fe566b590] [c0000000001b4bf8] run_timer_softirq+0x1e8/0x270 > [c000003fe566b630] [c000000000d0d6c8] __do_softirq+0x158/0x3e4 > [c000003fe566b710] [c000000000114be8] irq_exit+0xe8/0x120 > [c000003fe566b730] [c000000000024d0c] timer_interrupt+0x9c/0xe0 > [c000003fe566b760] [c000000000009014] decrementer_common+0x114/0x120 > --- interrupt: 901 at doorbell_global_ipi+0x34/0x50 > LR = arch_send_call_function_ipi_mask+0x120/0x130 > [c000003fe566ba50] [c00000000004876c] arch_send_call_function_ipi_mask+0x4c/0x130 (unreliable) > [c000003fe566ba90] [c0000000001d59f0] smp_call_function_many+0x340/0x450 > [c000003fe566bb00] [c000000000075f18] pmdp_invalidate+0x98/0xe0 > [c000003fe566bb30] [c0000000003a1120] change_huge_pmd+0xe0/0x270 > [c000003fe566bba0] [c000000000349278] change_protection_range+0xb88/0xe40 > [c000003fe566bcf0] [c0000000003496c0] mprotect_fixup+0x140/0x340 > [c000003fe566bdb0] [c000000000349a74] SyS_mprotect+0x1b4/0x350 > [c000003fe566be30] [c00000000000b184] system_call+0x58/0x6c > > Fix this by using the asynchronus smp_call in the timer interrupt handler. > We don't have to wait in this handler until the pstates are changed on > the core. This change will not have any impact on the global pstate > ramp-down algorithm. > > Reported-by: Nicholas Piggin > Reported-by: Pridhiviraj Paidipeddi > Signed-off-by: Shilpasri G Bhat > --- > drivers/cpufreq/powernv-cpufreq.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cpufreq.c > index 0591874..7e0c752 100644 > --- a/drivers/cpufreq/powernv-cpufreq.c > +++ b/drivers/cpufreq/powernv-cpufreq.c > @@ -721,7 +721,7 @@ void gpstate_timer_handler(struct timer_list *t) > spin_unlock(&gpstates->gpstate_lock); > > /* Timer may get migrated to a different cpu on cpu hot unplug */ > - smp_call_function_any(policy->cpus, set_pstate, &freq_data, 1); > + smp_call_function_any(policy->cpus, set_pstate, &freq_data, 0); > } > > /* This can still deadlock because !wait case still ends up having to wait if another !wait smp_call_function caller had previously used the call single data for this cpu. If you go this way you would have to use smp_call_function_async, which is more work. As a rule it would be better to avoid smp_call_function entirely if possible. Can you ensure the timer is running on the right CPU? Use add_timer_on and try again if the timer is on the wrong CPU, perhaps? Thanks, Nick