Received: by 10.192.165.148 with SMTP id m20csp4180948imm; Mon, 30 Apr 2018 13:19:49 -0700 (PDT) X-Google-Smtp-Source: AB8JxZraE4OJS4iXxbZXho4mOxQGqw3YiNk4OU78lbRu/8NRSXLU9FixDrwY1mNxzKtSZeNmv8bB X-Received: by 2002:a65:4b4a:: with SMTP id k10-v6mr11195843pgt.227.1525119589602; Mon, 30 Apr 2018 13:19:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525119589; cv=none; d=google.com; s=arc-20160816; b=kBxOPt6o8IPs74+gBiwpUH2n1jNIsgFJGHeGGtEJxI0SknPRwWNkACMFsvjapiQSrC TSQztlgHlpEuA/Xtk0Q00A6E4tSlCKFDvURNCZobO87u9dRMSVT/bsU63T8T2KzPWNZT WjtFsGGXSjmVyrWLnTil97viThopfBHlJlTmSwzot/ay788oO58E6Loyv0bIHuprE+7o 6/5STClquMWINe8GHx0fLYNMkLCXyxH8EswTbJfgFhcEd5oPLf71awxM4CdDeb1vbR6L T9ZFex5gRj6XL60x/FGWT6Fi6+0VoIukGCf9UjiiTX5BjkIJdLHHDBKGr2ewEHN6s/Fl l7dQ== 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=YClzwodmptRJcAKaBRx51XXsBX5fwZQ3Yo8/M575mJQ=; b=Ltg92a1l+vU+qZKELqaM2vOsYGeK3LR/PhjlbpXHL6Q4Rg/yhbmDCgchWMVcVqWRN1 c8xEsNaAW/EhuM4M7R9jaGP6osLDeYT0ZKPgXgJFFD1Bw/SygKQ50RER7uCnSV1cQUQ7 CKsQDWMyvfJL8ZMDTyFu/iG//fwhmXPs2kohOjpfL07Mkcci5GrzY8FsCJmJ+gdkorwl aQIkqinBAP6WgbgOj40udX/k0N80rY+YZCzexqOucTdK0YnQeMBQCRRyjzzUupcj8ts6 Cy+xBSDJGvTUlttZuCZj9ivJeH8emK269yBnr79vtYs7V9RCV/uKT4/FdsAZktilVU5v lMog== 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 v8-v6si8037005plo.306.2018.04.30.13.19.35; Mon, 30 Apr 2018 13:19:49 -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 S1755792AbeD3T0u (ORCPT + 99 others); Mon, 30 Apr 2018 15:26:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:60710 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755755AbeD3T0n (ORCPT ); Mon, 30 Apr 2018 15:26:43 -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 C180622DCC; Mon, 30 Apr 2018 19:26:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C180622DCC 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.9 53/61] cpufreq: powernv: Fix hardlockup due to synchronous smp_call in timer interrupt Date: Mon, 30 Apr 2018 12:24:56 -0700 Message-Id: <20180430183955.835618384@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180430183951.312721450@linuxfoundation.org> References: <20180430183951.312721450@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.9-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 @@ -599,6 +599,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; + } gpstates->last_sampled_time += time_diff; gpstates->elapsed_time += time_diff; @@ -626,10 +636,8 @@ void gpstate_timer_handler(unsigned long gpstates->last_gpstate_idx = pstate_to_idx(freq_data.gpstate_id); gpstates->last_lpstate_idx = pstate_to_idx(freq_data.pstate_id); + 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); } /*