Received: by 2002:a25:b323:0:0:0:0:0 with SMTP id l35csp2842467ybj; Mon, 23 Sep 2019 10:17:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqwYkXa8R+k3KuXhOJ3a9che1oUNhnJE/g98lNO5F0RsFCdH+6myc0Alf7khmLNk5mtLnYIm X-Received: by 2002:a05:6402:2cb:: with SMTP id b11mr1200693edx.285.1569259029807; Mon, 23 Sep 2019 10:17:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569259029; cv=none; d=google.com; s=arc-20160816; b=ULziyKtNaB7BjqjQOg27UwUtP/GFkGX3Zqf5bytpxTC9nx0b/+FxfvtBkbs6jwiOUH tIHgoHQMKIf5q2L2RgI6ws/jV66RVb5+wECqwhPySsMOp7+4it8hLRJVKxPq/m/DcpPP jj0AfAWX85IcvQI9Dk++sATfI1Al0MIHHlxG6mhWkw+t5SuDW/O0jjXt+8XVdTgfvMwc 7wH+JdREM0ErBywsxwH9yzJLPy9v9kYFK0p3JKyCl3ExWvhF4Uo22AnKy/x96YEwy91/ SaIxKQUrN8ykrW2dSJa5aqdfbMvo+0Sqbi5i6moWpcs471bL8R8speE8S1bgSlpc7m6A pWAA== 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 :content-language:mime-version:user-agent:date:message-id:subject :from:cc:to; bh=4FmM113kPsPxqDCUb6b9IUAETSGjHZ2phla6Vk9na6E=; b=cwv86HwmWopp4PokLKQGIxZdAxcX34fbZWEHjko/IYhtWZCCeA+7RMSGZVQDUy85t2 zJNOgo6yWD5z4j6N8qfcjHWtH0kZJHlT9/VmYAI6t+GjqhRtySmBciWih5QYQ3bZsc24 4aUQqHkx8RbjIGPrdfyDRS7ll5GpUnK6TvoEpk7FE/MIi6In3dZZp8oNkQ+l4O36vv6K EZk1s/jDVQ3N/uXzlTFNXaynHH56aBiLvNYpQ8bCn1D++KNvVXPy6o6jaKl0YdnSBwo/ +xBLU3FUGVm7zP1E+ijxa7D9ITLb1upZbwMTzDivW2fjdcY9/boNLwlXRpF68JrmdM6R op+Q== 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 gz26si5291864ejb.65.2019.09.23.10.16.45; Mon, 23 Sep 2019 10:17:09 -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 S2437774AbfIULVd (ORCPT + 99 others); Sat, 21 Sep 2019 07:21:33 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:41716 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2407437AbfIULVd (ORCPT ); Sat, 21 Sep 2019 07:21:33 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id CDF62BE18E877A097D69; Sat, 21 Sep 2019 19:21:31 +0800 (CST) Received: from [127.0.0.1] (10.177.251.225) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.439.0; Sat, 21 Sep 2019 19:21:23 +0800 To: David Laight , "catalin.marinas@arm.com" , "will@kernel.org" , "kstewart@linuxfoundation.org" , "gregkh@linuxfoundation.org" , "ard.biesheuvel@linaro.org" , "tglx@linutronix.de" CC: "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "wuyun.wu@huawei.com" From: Yunfeng Ye Subject: [PATCH V2] arm64: psci: Reduce waiting time of cpu_psci_cpu_kill() Message-ID: <18068756-0f39-6388-3290-cf03746e767d@huawei.com> Date: Sat, 21 Sep 2019 19:21:17 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.251.225] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If psci_ops.affinity_info() fails, it will sleep 10ms, which will not take so long in the right case. Use usleep_range() instead of msleep(), reduce the waiting time, and give a chance to busy wait before sleep. Signed-off-by: Yunfeng Ye --- V1->V2: - use usleep_range() instead of udelay() after waiting for a while arch/arm64/kernel/psci.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/arch/arm64/kernel/psci.c b/arch/arm64/kernel/psci.c index c9f72b2..99b3122 100644 --- a/arch/arm64/kernel/psci.c +++ b/arch/arm64/kernel/psci.c @@ -82,6 +82,7 @@ static void cpu_psci_cpu_die(unsigned int cpu) static int cpu_psci_cpu_kill(unsigned int cpu) { int err, i; + unsigned long timeout; if (!psci_ops.affinity_info) return 0; @@ -91,16 +92,24 @@ 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++) { + i = 0; + timeout = jiffies + 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); return 0; } - msleep(10); - pr_info("Retrying again to check for CPU kill\n"); - } + /* busy-wait max 1ms */ + if (i++ < 100) { + cond_resched(); + udelay(10); + continue; + } + + usleep_range(100, 1000); + } while (time_before(jiffies, timeout)); pr_warn("CPU%d may not have shut down cleanly (AFFINITY_INFO reports %d)\n", cpu, err); -- 2.7.4.huawei.3