Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp6332187ybp; Tue, 15 Oct 2019 13:16:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqycsc605/oDBosRUODcxn+4z+BwjASdzy14AMZcS/XIb/QGx6JgocaxHLk66Q5wCmimm+RH X-Received: by 2002:aa7:c38f:: with SMTP id k15mr36442711edq.100.1571170582998; Tue, 15 Oct 2019 13:16:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571170582; cv=none; d=google.com; s=arc-20160816; b=Uxe3AwlubHmMntf8DENuGGWJcNg7KSOvjSozNzKOhXsnTi7BEcB5In/7KXmu/O4yQV cxAJ57BCfiYgEZJJbUrwW/2ChCVdhYGIxx7mq4QdoGqU9F2LxqtcYyRxLw1qFriR22c7 ggAea7B/7DHNMBRy99YzqH+UDeHPKB+fEVDiDsniCKYrRqqksymQNjWGbIQbPUlreNpt OT244y8Pym/1v0g85ziGLQLhf79QFoqNUAEn1zmWcbqe/e8mit9JzWT7+kK10x0bRzDJ irmt1iVCqkz54iWCUnWgbuPbdXE7gcGwzrH1Erz1LPOsvUmJ3uiOKbiFIZihplqsp3ky pqTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=63NsDEGTMM/bZfyKRhvuN9COUoLwlN2tpq35qejql6E=; b=HK2fBqbifJ5wTYr7EozK6lhKpWtFv7tYuPpWufTvHU+gNs8s+QFjMajZcvFd1vm3ta O60iN3xSxaHZdrXyf+ZSGxka432pwwZ39b6chStL+U7b6/QmigI4oJFLik0MebAmR7Q5 VEtDPFOU01ZndnYg0HOjNhQDAzNtimIdoKnlW6WM18ZXerhT+CBWR3atcA2FncVaWHAL DX7Jum1IfuGvMArZEUL6NjD2QQnscY65rfoQy+OxACwZd4Gis1+L0XELvrNlueD+CM8J li2+cZj9ip6VOhGQvOvReBa0BVlaxwnw8EBPtdFjQ8Us0YdyiDiM8SGJXBqgLbsDhY4e 3hNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="StYJMA5/"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id rl13si14048739ejb.228.2019.10.15.13.15.59; Tue, 15 Oct 2019 13:16:22 -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; dkim=pass header.i=@kernel.org header.s=default header.b="StYJMA5/"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388034AbfJOQYF (ORCPT + 99 others); Tue, 15 Oct 2019 12:24:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:46904 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726237AbfJOQYF (ORCPT ); Tue, 15 Oct 2019 12:24:05 -0400 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (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 81B3F2086A; Tue, 15 Oct 2019 16:24:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1571156644; bh=+3bA41N9zG3Na8eiZmgyqf6wPpM7u7VDlcQ7i85yw3Y=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=StYJMA5/BLxta6Bq7ntiXfwvCAGN+ItksqqushdPMj8/N5YyCsnDGO0W16VHdpGB0 IxG4cxi6wDfDKCaXcI8oBfLjDBrt6KHc8VekcXdhf8yBRzt7ba+Z1BuhDx6bOHJUOo GMMMTfPhgpPP4m43Rut46SbGtc+mKa19vvgUyeJ0= Date: Tue, 15 Oct 2019 17:23:59 +0100 From: Will Deacon To: Yunfeng Ye , sudeep.holla@arm.com Cc: David Laight , "catalin.marinas@arm.com" , "kstewart@linuxfoundation.org" , "gregkh@linuxfoundation.org" , "ard.biesheuvel@linaro.org" , "tglx@linutronix.de" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "wuyun.wu@huawei.com" Subject: Re: [PATCH V2] arm64: psci: Reduce waiting time of cpu_psci_cpu_kill() Message-ID: <20191015162358.bt5rffidkv2j4xqb@willie-the-truck> References: <18068756-0f39-6388-3290-cf03746e767d@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <18068756-0f39-6388-3290-cf03746e767d@huawei.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Sat, Sep 21, 2019 at 07:21:17PM +0800, Yunfeng Ye wrote: > 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. Can you elaborate on "the right case" please? It's not clear to me exactly what problem you're solving here. I've also added Sudeep to the thread, since I'd like his ack on the change. Will > 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 >