Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp800939imm; Mon, 21 May 2018 14:44:14 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp3+eCcqQ4qN63aWf1NLCb8cxlAT5lpq5ZQqOkqMn6RXjxtIbdi9coVM+6aCmiL7WYsN5BU X-Received: by 2002:a63:6ac6:: with SMTP id f189-v6mr17287829pgc.308.1526939054039; Mon, 21 May 2018 14:44:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526939054; cv=none; d=google.com; s=arc-20160816; b=u6g8HxdMxv3g1fACuZxwl0o6uq2vE1fUYsVc54YHWsjCEtRG/K1aR7+A6eAz3ZLSLc HvtNCJjef+YdsKHWvduPe5/SshPZgJn/eOYWxE+1lwB2T3sBFHa23X4L6b/NmMnS3u1y 15zSKp+8+QdzjLbEBVEr0RCAS2ESZXRcY9u/RGGPPnM7spNn/ySId0Y+J85ZMkxrtoy+ 7sGi4IgPDYDVVU9GJx34sIZukkCufnEPiPE2tbxNUeVsVQZ7+JZ0FV6FPny/eom3i9bd osdzPXLSoyrgwXDArJ2hDA9LHM3cgQlHX9+nxk/RoFTqUCGpxWOlXiaHsOfZdLInmvgT jrYg== 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:dkim-signature :arc-authentication-results; bh=K1kkr//HmVHsKbQygVFljizo4JApU5OUpk4rQYLVrek=; b=ho/l8QY+VAnhl5huIpCL/9fRurAAYwSD4rpu1hXO0DSrw6aqkqXPxx4udAaRhttLtW 3pK9742eSE1uSHsB2qnbar4f8EqeiCq4HgBMW8SmQ8tFIR4rDV+eJOLvZMolEcnwBjrT GIlXKTTCz5OY5TJd9mjVz73Gl/VMpzP63GAV6Q4NfEcmhY6NwBDpHc9UwqbB8Z/LQauV 8hM9slQXMVySZqZGKLi1NQYMfPVpayY4ZgJ6/69uVBM/nNSgM6tiAy4IMoLNP2DGrT0w se0rOMrWkc/9euYOjyjRMlqTVGVDpphxOyEIrlfVW7e3PdDDg5gOGkQFgDAQPWds3vsL B7jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=g69PstjA; 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 u6-v6si14274435pfm.183.2018.05.21.14.43.59; Mon, 21 May 2018 14:44:13 -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=g69PstjA; 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 S932268AbeEUVYX (ORCPT + 99 others); Mon, 21 May 2018 17:24:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:39218 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932255AbeEUVYS (ORCPT ); Mon, 21 May 2018 17:24:18 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (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 5FBB520871; Mon, 21 May 2018 21:24:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1526937857; bh=g9wfOC3T4FNQxK/8spNjGJewr+nqh8N7J1VDL4j/OCI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g69PstjAH1ecPZm46laAkzTHHVI54kcKr9/iXaQ/e4x+KW2dfaqjg71Z/LE3t0Qlk 5/2cHO0v7wFzEVcB/4hkIjetboGaNsMB8th/d/S5Tw2A6Hnv3QkbLyGblZEpTwRx+H 86H6Kgiv1D/HSRnjYhCzkx9ficziNoI3kpzKa96g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dexuan Cui , Thomas Gleixner , Josh Poulson , "Michael Kelley (EOSG)" , Peter Zijlstra , Frederic Weisbecker , Rakib Mullick , Jork Loeser , Andrew Morton , KY Srinivasan , Linus Torvalds , Alexey Dobriyan , Dmitry Vyukov Subject: [PATCH 4.16 051/110] tick/broadcast: Use for_each_cpu() specially on UP kernels Date: Mon, 21 May 2018 23:11:48 +0200 Message-Id: <20180521210509.649360269@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180521210503.823249477@linuxfoundation.org> References: <20180521210503.823249477@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.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dexuan Cui commit 5596fe34495cf0f645f417eb928ef224df3e3cb4 upstream. for_each_cpu() unintuitively reports CPU0 as set independent of the actual cpumask content on UP kernels. This causes an unexpected PIT interrupt storm on a UP kernel running in an SMP virtual machine on Hyper-V, and as a result, the virtual machine can suffer from a strange random delay of 1~20 minutes during boot-up, and sometimes it can hang forever. Protect if by checking whether the cpumask is empty before entering the for_each_cpu() loop. [ tglx: Use !IS_ENABLED(CONFIG_SMP) instead of #ifdeffery ] Signed-off-by: Dexuan Cui Signed-off-by: Thomas Gleixner Cc: Josh Poulson Cc: "Michael Kelley (EOSG)" Cc: Peter Zijlstra Cc: Frederic Weisbecker Cc: stable@vger.kernel.org Cc: Rakib Mullick Cc: Jork Loeser Cc: Greg Kroah-Hartman Cc: Andrew Morton Cc: KY Srinivasan Cc: Linus Torvalds Cc: Alexey Dobriyan Cc: Dmitry Vyukov Link: https://lkml.kernel.org/r/KL1P15301MB000678289FE55BA365B3279ABF990@KL1P15301MB0006.APCP153.PROD.OUTLOOK.COM Link: https://lkml.kernel.org/r/KL1P15301MB0006FA63BC22BEB64902EAA0BF930@KL1P15301MB0006.APCP153.PROD.OUTLOOK.COM Signed-off-by: Greg Kroah-Hartman --- kernel/time/tick-broadcast.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/kernel/time/tick-broadcast.c +++ b/kernel/time/tick-broadcast.c @@ -612,6 +612,14 @@ static void tick_handle_oneshot_broadcas now = ktime_get(); /* Find all expired events */ for_each_cpu(cpu, tick_broadcast_oneshot_mask) { + /* + * Required for !SMP because for_each_cpu() reports + * unconditionally CPU0 as set on UP kernels. + */ + if (!IS_ENABLED(CONFIG_SMP) && + cpumask_empty(tick_broadcast_oneshot_mask)) + break; + td = &per_cpu(tick_cpu_device, cpu); if (td->evtdev->next_event <= now) { cpumask_set_cpu(cpu, tmpmask);