Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp13386110ybl; Sun, 29 Dec 2019 10:37:55 -0800 (PST) X-Google-Smtp-Source: APXvYqzMvqveG07DwnIZV/EAQupq+UYrijOyNawLRzobfnmGrjFw9tSlYgeQDS2KgY+U4kK2/5Ef X-Received: by 2002:a05:6830:681:: with SMTP id q1mr71959047otr.162.1577644675274; Sun, 29 Dec 2019 10:37:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577644675; cv=none; d=google.com; s=arc-20160816; b=fSDY224vgGmEUF7ksWhUnP5PsKKcJrSWqr/P9xPJs/1T+Znzr+H6dzkuQ0sqP4+PIB tiR8OkhbEK7gBlpuiW2g2/RVhGkTpLIr9Iz6exeiZbnRVHQhWyNnNjKwVYQQ66bABDOc PfkozZXf5TRIAY7YQKzzmV/MT1Ti8WGIoulYWPT5dUjdh3I98oDLNymsdcJvyIiEg6QS ytkO4NUVE7WgtE7Whrx6PTAjvIWbQAtNQSxpswIsh3BAoXlabhXbovAhyirS5YzG/AXq 0mhEImL3VYmhQF+rRz2qsC+fYasvrtvKdKNCQhog+o9N4/Kb0veOfEgW5G+cdaq8hD1L skmw== 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=WqGgZmF2wESfipGS+p1yIyYLE3th7LKbwD9O/BdlBiQ=; b=Lrd3MSV8pQzqgHXUE0PWPECv0XDmnuFZ1W4K515LFpMqPq+rSIzcA3+8xZPYw+QEUT LHHIcxUOAQenU+9ByPp9XrbWp90a9P7B1LJp6lg+Dada3f0quXEI2a95z9d+8rMWVTl2 8S04Hq6pfH6jgFPHkdG/herXY8ZAyhqs3X0ZBjdUpv7ULiUvbe3zINPG3ZwcJW0BT9K7 +gZ6M6FMHA94w232dBgDTP8O7pNx9gI1f7jxKohWXWGkVGS8s02QmNVWRTkAgVRE3pTr tzHys313JgZgTk5n7hUiNmN9dYpkYvE2Qp1yELa0pTYQe2Zvuf58vbvUubxLOWoGXAuW WtAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XQhfK39c; 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 d12si20917717otf.141.2019.12.29.10.37.43; Sun, 29 Dec 2019 10:37:55 -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=XQhfK39c; 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 S1727611AbfL2RXw (ORCPT + 99 others); Sun, 29 Dec 2019 12:23:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:41856 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727264AbfL2RXt (ORCPT ); Sun, 29 Dec 2019 12:23: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 5AA1E207FD; Sun, 29 Dec 2019 17:23:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1577640228; bh=9RACWVCjpjTDOoaoIHWooaa+6h52XFm/sW+01Hb6ZPM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XQhfK39cTUEHHtXENBuMpG5zX/OFrLLx5gxOpvG3zPNzcpyKeX1VZG08FYSYRTHtS 6wNv1htRzapgWX14Pdz9ccNXaqeUNnwA52Utf3kGIUuBwYNtvSQD7eS8DEjj4LAqfR SihGWI48e9gGPry3NgAXMPTqNKIgY5dQbT1J6820= 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.14 070/161] arm64: psci: Reduce the waiting time for cpu_psci_cpu_kill() Date: Sun, 29 Dec 2019 18:18:38 +0100 Message-Id: <20191229162421.416747049@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191229162355.500086350@linuxfoundation.org> References: <20191229162355.500086350@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 e8edbf13302a..3856d51c645b 100644 --- a/arch/arm64/kernel/psci.c +++ b/arch/arm64/kernel/psci.c @@ -84,7 +84,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; @@ -94,16 +95,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