Received: by 2002:a17:90a:9103:0:0:0:0 with SMTP id k3csp11799762pjo; Thu, 2 Jan 2020 14:29:38 -0800 (PST) X-Google-Smtp-Source: APXvYqwFmU17Xgy85Ejvnpg0T+bXF6uJcH71PeS54gtxm/1IudnEUscdJ0/qhQTUZ/jHRhs7Q++4 X-Received: by 2002:a05:6830:18f1:: with SMTP id d17mr84767004otf.298.1578004178728; Thu, 02 Jan 2020 14:29:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578004178; cv=none; d=google.com; s=arc-20160816; b=FkeAclDP/PIyP39Qy+74BueQ12wumW+IWh8t5i0e3WFYPxawtVVs+iZ7XCXGgrnqgo VFhZzCHRSksI13xG5WjLVZZHAYWGDXWJt850QL5xpOLYYICWpr5NsTAkrvaG44up8aj+ m1xRkCvPpE4Y4WAOvcXniKl1+MWeFJuDrjZdwjE4qCuW+wZVMZwyfYwC/ST7tI0QfNRJ LVzXU70fkQS4sQ5YHk5PI7PwUOWqCG+lRTudQ4KP1nKaDBxOA2FTwQtofCdldlChuqGQ S0t9CiPnCi0r2SFpd34G59prsQcKQHjif2nUlb6Bg0AuQRlDIAg/WsNhTkjj622Am1+t IPjA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=hZcZHbnfNh/GP8oYWGzF/iJdJsD/rTgr+1GfXunyIzE=; b=lD5asklk8PIW0pSMWtFqSU56B+w8uKRQKuHFr/oOfiW92z2FKfrWnVzdngzXYI+O9r T8hL5F769jEA7g7oG76+A7hQ/jZjQjChbmiTbFdQVLkjtX5GkesAPCIlhLtPYASEMcot KJkLku+MRqa+Lr05IaJe6EiBcR/HyXcdSlEx7L+u5HpabLg7jSXtnfGWVodjGyTt+hBq UcNsk5JEvRSIXYKCr4+EoIh+GdwiySv+w955hi1iw3u61Sg2+UihCh/Mszu/wbJ1ukvA zr+DJwexl/lyT5T/4qp/vdtrPPzAlCfhnxmfPzMCGPSnmt81+2olASLCwp4IXBi1h7hP bN2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BxEK+ANM; 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 t25si18708071oth.246.2020.01.02.14.29.27; Thu, 02 Jan 2020 14:29:38 -0800 (PST) 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=@kernel.org header.s=default header.b=BxEK+ANM; 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 S1729678AbgABW2v (ORCPT + 99 others); Thu, 2 Jan 2020 17:28:51 -0500 Received: from mail.kernel.org ([198.145.29.99]:59118 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729954AbgABW2t (ORCPT ); Thu, 2 Jan 2020 17:28:49 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 45CDD20863; Thu, 2 Jan 2020 22:28:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578004128; bh=5h2VMuozqT83+Xvki4/sTYdyUzjxrDIHWWjHu3k4QyU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BxEK+ANMHBO31pNtiiesOhMZEJrMH9j6B9dNzGm6ZQlWAcFqEqd8uKQ5v0KuexYyW gikg9MsKbZ6EXqlgqJKDkFDI1QxrKosXTHDeHmW3dcmuhEIft6dCi9TSOAqVtMDMmA 7eGZUmMUiVNLYD9vjp2ZXZP/JAw5ACLt9l2XYhu0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yunfeng Ye , Sudeep Holla , Catalin Marinas , Sasha Levin Subject: [PATCH 4.9 042/171] arm64: psci: Reduce the waiting time for cpu_psci_cpu_kill() Date: Thu, 2 Jan 2020 23:06:13 +0100 Message-Id: <20200102220552.809554624@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200102220546.960200039@linuxfoundation.org> References: <20200102220546.960200039@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yunfeng Ye [ Upstream commit bfcef4ab1d7ee8921bc322109b1692036cc6cbe0 ] In cases like suspend-to-disk and suspend-to-ram, a large number of CPU cores need to be shut down. At present, the CPU hotplug operation is serialised, and the CPU cores can only be shut down one by one. In this process, if PSCI affinity_info() does not return LEVEL_OFF quickly, cpu_psci_cpu_kill() needs to wait for 10ms. If hundreds of CPU cores need to be shut down, it will take a long time. Normally, there is no need to wait 10ms in cpu_psci_cpu_kill(). So change the wait interval from 10 ms to max 1 ms and use usleep_range() instead of msleep() for more accurate timer. In addition, reducing the time interval will increase the messages output, so remove the "Retry ..." message, instead, track time and output to the the sucessful message. Signed-off-by: Yunfeng Ye Reviewed-by: Sudeep Holla Signed-off-by: Catalin Marinas Signed-off-by: Sasha Levin --- arch/arm64/kernel/psci.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/arch/arm64/kernel/psci.c b/arch/arm64/kernel/psci.c index 42816bebb1e0..e3713d6fb8e0 100644 --- a/arch/arm64/kernel/psci.c +++ b/arch/arm64/kernel/psci.c @@ -83,7 +83,8 @@ static void cpu_psci_cpu_die(unsigned int cpu) static int cpu_psci_cpu_kill(unsigned int cpu) { - int err, i; + int err; + unsigned long start, end; if (!psci_ops.affinity_info) return 0; @@ -93,16 +94,18 @@ static int cpu_psci_cpu_kill(unsigned int cpu) * while it is dying. So, try again a few times. */ - for (i = 0; i < 10; i++) { + start = jiffies; + end = start + msecs_to_jiffies(100); + do { err = psci_ops.affinity_info(cpu_logical_map(cpu), 0); if (err == PSCI_0_2_AFFINITY_LEVEL_OFF) { - pr_info("CPU%d killed.\n", cpu); + pr_info("CPU%d killed (polled %d ms)\n", cpu, + jiffies_to_msecs(jiffies - start)); return 0; } - msleep(10); - pr_info("Retrying again to check for CPU kill\n"); - } + usleep_range(100, 1000); + } while (time_before(jiffies, end)); pr_warn("CPU%d may not have shut down cleanly (AFFINITY_INFO reports %d)\n", cpu, err); -- 2.20.1