Received: by 10.192.165.148 with SMTP id m20csp4164360imm; Mon, 30 Apr 2018 13:01:00 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqD6px4TiGEXrVlX/3GlBfBrV/I2HRTWLGds1tdYHELnOnmhENScGa+O6RjRpCyhH3PXgP3 X-Received: by 2002:a17:902:6113:: with SMTP id t19-v6mr13335833plj.372.1525118460272; Mon, 30 Apr 2018 13:01:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525118460; cv=none; d=google.com; s=arc-20160816; b=Sgk0Mw9ehz/BrXuTHRSDv4bE71cPgpbOFlTA1fTgIP8iJxvm0BDsU3uWxk5dewmdKm n99s58TliqpmBeO7INv5cMpy81sa30RIVeyMA11TW6lVFqlOg9X2WVgI9BLmUmI+ZGCU y05qIbYFV+CaKnqGXSSWBv1ETWdCW1UwGWsz8+upH3yah9Djk2lwEY9OU48fzO+eVu5s s0N0p9eV7w678p9niXPy+U5ZSvxeKUz3C3t15l+U7s2aZH6wYXr7pOAzNHo1xpooax7f l7eOtbTPZDnGN/vZPo1PPPj6Kw0nDqxU9yHEl8E8vrsLf0b96LCh6tp7/efzwB5au+La kWIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dmarc-filter :arc-authentication-results; bh=2EsYEnfJ/jzQxP/h1cIAngSys+WrYaKvvycIXh1nBDI=; b=ULSc1AaAJ4VA8Jww5rG1SeTd2Ztokhqm6LvkXbWXU1h4/Yw9YAU5ph711Af8z+uJoP M6mH1/rGohI1eZIkQzkbqhpPX/kmSuPScL5WIcitml0snFBXuDi1OGFLawi9h15diNT/ lYtXL4n9K5PFrGC0MphFUYKljSXXIEgtI9TWYCY6O8J8a03kM1Rw9FEXStr5xfz2QeGu 58JP5ZXWx84LJpJDKvbA95lNkXzjfKJ0LR7Ig/kl3uB9xrjc5cES038o3oN6HL70WdwQ fQPmbOJayIUp7WjfcrbAkop0mrcj6gQMVquYcw0yEaljtijVDYlW5carh4ULEKlNOYJm w0mg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u6-v6si4054530pgv.420.2018.04.30.13.00.45; Mon, 30 Apr 2018 13:01:00 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932236AbeD3T1n (ORCPT + 99 others); Mon, 30 Apr 2018 15:27:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:34404 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756021AbeD3T1i (ORCPT ); Mon, 30 Apr 2018 15:27:38 -0400 Received: from localhost (unknown [104.132.1.102]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C30FE22DCB; Mon, 30 Apr 2018 19:27:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C30FE22DCB Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: mail.kernel.org; spf=fail smtp.mailfrom=gregkh@linuxfoundation.org From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nicholas Piggin , Pridhiviraj Paidipeddi , Shilpasri G Bhat , Viresh Kumar , Vaidyanathan Srinivasan , Michael Ellerman Subject: [PATCH 4.14 78/91] cpufreq: powernv: Fix hardlockup due to synchronous smp_call in timer interrupt Date: Mon, 30 Apr 2018 12:25:00 -0700 Message-Id: <20180430184008.361858596@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180430184004.216234025@linuxfoundation.org> References: <20180430184004.216234025@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Shilpasri G Bhat commit c0f7f5b6c69107ca92909512533e70258ee19188 upstream. gpstate_timer_handler() uses synchronous smp_call to set the pstate on the requested core. This causes the below hard lockup: smp_call_function_single+0x110/0x180 (unreliable) smp_call_function_any+0x180/0x250 gpstate_timer_handler+0x1e8/0x580 call_timer_fn+0x50/0x1c0 expire_timers+0x138/0x1f0 run_timer_softirq+0x1e8/0x270 __do_softirq+0x158/0x3e4 irq_exit+0xe8/0x120 timer_interrupt+0x9c/0xe0 decrementer_common+0x114/0x120 -- interrupt: 901 at doorbell_global_ipi+0x34/0x50 LR = arch_send_call_function_ipi_mask+0x120/0x130 arch_send_call_function_ipi_mask+0x4c/0x130 smp_call_function_many+0x340/0x450 pmdp_invalidate+0x98/0xe0 change_huge_pmd+0xe0/0x270 change_protection_range+0xb88/0xe40 mprotect_fixup+0x140/0x340 SyS_mprotect+0x1b4/0x350 system_call+0x58/0x6c One way to avoid this is removing the smp-call. We can ensure that the timer always runs on one of the policy-cpus. If the timer gets migrated to a cpu outside the policy then re-queue it back on the policy->cpus. This way we can get rid of the smp-call which was being used to set the pstate on the policy->cpus. Fixes: 7bc54b652f13 ("timers, cpufreq/powernv: Initialize the gpstate timer as pinned") Cc: stable@vger.kernel.org # v4.8+ Reported-by: Nicholas Piggin Reported-by: Pridhiviraj Paidipeddi Signed-off-by: Shilpasri G Bhat Acked-by: Nicholas Piggin Acked-by: Viresh Kumar Acked-by: Vaidyanathan Srinivasan Signed-off-by: Michael Ellerman Signed-off-by: Greg Kroah-Hartman --- drivers/cpufreq/powernv-cpufreq.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) --- a/drivers/cpufreq/powernv-cpufreq.c +++ b/drivers/cpufreq/powernv-cpufreq.c @@ -646,6 +646,16 @@ void gpstate_timer_handler(unsigned long if (!spin_trylock(&gpstates->gpstate_lock)) return; + /* + * If the timer has migrated to the different cpu then bring + * it back to one of the policy->cpus + */ + if (!cpumask_test_cpu(raw_smp_processor_id(), policy->cpus)) { + gpstates->timer.expires = jiffies + msecs_to_jiffies(1); + add_timer_on(&gpstates->timer, cpumask_first(policy->cpus)); + spin_unlock(&gpstates->gpstate_lock); + return; + } /* * If PMCR was last updated was using fast_swtich then @@ -685,10 +695,8 @@ void gpstate_timer_handler(unsigned long if (gpstate_idx != gpstates->last_lpstate_idx) queue_gpstate_timer(gpstates); + set_pstate(&freq_data); 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); } /*