Received: by 10.213.65.68 with SMTP id h4csp14380imn; Mon, 19 Mar 2018 17:56:37 -0700 (PDT) X-Google-Smtp-Source: AG47ELvypn+thAeFlx84W2D81aXsokqfUWIazGRM161GpkoI5gl0vfb2KF2rVQx2jUbBK0uBabtm X-Received: by 10.98.62.71 with SMTP id l68mr7828310pfa.98.1521507397833; Mon, 19 Mar 2018 17:56:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521507397; cv=none; d=google.com; s=arc-20160816; b=SkNeG5YLqAs3TluiG2/hecF1U2N/2jGkJAsamsJOOOmd5C13zwigSsfIQ5+PdDAYPQ ramXf6YeXYhIZj/cNlfwTD1PSaKkBAt9VXXGeFvVV4skjT20gYaZMfmjLY7d/UGAhI2N LfHmVUrE9tu8C2h152UJuyP38529ZUID/ERkVaKFZNYYqDLYyX7ql3G9IThuzO4TpSFD FbZKUT7JjhngxqlFAFhl6bYNs6/H11Vicu9xP4nPGYxKty4FTeEt9Pqd8pehdccFT7px gUpxT9otB+FXdxZMoL4jlBFawT9pCFz5Y//8uI8Es7mt2a1/AHJa8GTcKeiH1DHcJ+0j gNeg== 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 :arc-authentication-results; bh=TX3bDj2rGR4GJEKMv3tqJykIX6+mVrz5TV4sKNtOAB8=; b=rJ4MWNsnbD3myGvmR/vidKSUa8azGwrovjQPOYwUzsxgCvXDV9yAM+m2b5XF69JDls pqBYSgTQKa5KOIzNIqBZ1cVwZuenQF8MML44xp5ly7dL2/S+tNrtOaTJAZF1E9Eqz9G+ VgVtGkobLY41X1t+r+atp2aR9JR7UG+yPrwDT+jCXwktR4vmG4NOz75rmoiaJikLO44h OQQNtOama6GIEDa4lpIBuLRVmKPQUFu0RmENs6ewj+PpaCKtT0h7+g+9Af2U3BH+8K1M s45LYOXDpuNG0ht5I1JQVJkT5UIgnqzC+odhoIvmfv23FhnbhBLgIR2dYTtdqoBqEtz5 /8rg== 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 w5-v6si438904plz.239.2018.03.19.17.56.23; Mon, 19 Mar 2018 17:56:37 -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 S969791AbeCSSZt (ORCPT + 99 others); Mon, 19 Mar 2018 14:25:49 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:50512 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S969759AbeCSSZj (ORCPT ); Mon, 19 Mar 2018 14:25:39 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 7E076F72; Mon, 19 Mar 2018 18:25:38 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Paul E. McKenney" , Ingo Molnar , Peter Zijlstra , Sasha Levin Subject: [PATCH 4.9 171/241] sched: Stop resched_cpu() from sending IPIs to offline CPUs Date: Mon, 19 Mar 2018 19:07:16 +0100 Message-Id: <20180319180758.237861935@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180319180751.172155436@linuxfoundation.org> References: <20180319180751.172155436@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.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: "Paul E. McKenney" [ Upstream commit a0982dfa03efca6c239c52cabebcea4afb93ea6b ] The rcutorture test suite occasionally provokes a splat due to invoking resched_cpu() on an offline CPU: WARNING: CPU: 2 PID: 8 at /home/paulmck/public_git/linux-rcu/arch/x86/kernel/smp.c:128 native_smp_send_reschedule+0x37/0x40 Modules linked in: CPU: 2 PID: 8 Comm: rcu_preempt Not tainted 4.14.0-rc4+ #1 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Ubuntu-1.8.2-1ubuntu1 04/01/2014 task: ffff902ede9daf00 task.stack: ffff96c50010c000 RIP: 0010:native_smp_send_reschedule+0x37/0x40 RSP: 0018:ffff96c50010fdb8 EFLAGS: 00010096 RAX: 000000000000002e RBX: ffff902edaab4680 RCX: 0000000000000003 RDX: 0000000080000003 RSI: 0000000000000000 RDI: 00000000ffffffff RBP: ffff96c50010fdb8 R08: 0000000000000000 R09: 0000000000000001 R10: 0000000000000000 R11: 00000000299f36ae R12: 0000000000000001 R13: ffffffff9de64240 R14: 0000000000000001 R15: ffffffff9de64240 FS: 0000000000000000(0000) GS:ffff902edfc80000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00000000f7d4c642 CR3: 000000001e0e2000 CR4: 00000000000006e0 Call Trace: resched_curr+0x8f/0x1c0 resched_cpu+0x2c/0x40 rcu_implicit_dynticks_qs+0x152/0x220 force_qs_rnp+0x147/0x1d0 ? sync_rcu_exp_select_cpus+0x450/0x450 rcu_gp_kthread+0x5a9/0x950 kthread+0x142/0x180 ? force_qs_rnp+0x1d0/0x1d0 ? kthread_create_on_node+0x40/0x40 ret_from_fork+0x27/0x40 Code: 14 01 0f 92 c0 84 c0 74 14 48 8b 05 14 4f f4 00 be fd 00 00 00 ff 90 a0 00 00 00 5d c3 89 fe 48 c7 c7 38 89 ca 9d e8 e5 56 08 00 <0f> ff 5d c3 0f 1f 44 00 00 8b 05 52 9e 37 02 85 c0 75 38 55 48 ---[ end trace 26df9e5df4bba4ac ]--- This splat cannot be generated by expedited grace periods because they always invoke resched_cpu() on the current CPU, which is good because expedited grace periods require that resched_cpu() unconditionally succeed. However, other parts of RCU can tolerate resched_cpu() acting as a no-op, at least as long as it doesn't happen too often. This commit therefore makes resched_cpu() invoke resched_curr() only if the CPU is either online or is the current CPU. Signed-off-by: Paul E. McKenney Cc: Ingo Molnar Cc: Peter Zijlstra Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- kernel/sched/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -508,7 +508,8 @@ void resched_cpu(int cpu) unsigned long flags; raw_spin_lock_irqsave(&rq->lock, flags); - resched_curr(rq); + if (cpu_online(cpu) || cpu == smp_processor_id()) + resched_curr(rq); raw_spin_unlock_irqrestore(&rq->lock, flags); }