Received: by 10.213.65.68 with SMTP id h4csp467008imn; Fri, 16 Mar 2018 08:37:32 -0700 (PDT) X-Google-Smtp-Source: AG47ELtCRb4mTRtHDArUOEuzWm0LFdbNDsh2ZaTwcNDfzMLGTGrZ+xhKL9B43fENvHbDk5gYJZeH X-Received: by 2002:a17:902:3303:: with SMTP id a3-v6mr2562772plc.399.1521214652124; Fri, 16 Mar 2018 08:37:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521214652; cv=none; d=google.com; s=arc-20160816; b=ELgc38JPsNe6AyNaSNJk6bvS1Mpz80uvmihMCQcM400Jyh+afcLnB0kajWAkCW4TaX OAi8qWcgbbXq5lioalb/It0aY2rV/U77a12i4yIyh8O92inSgrNVqvnm50QimZ4Y+i/A ktPSIczvZ6K+G0Y1ZOfl0UMt8FU3GHO7y2wANPPKfIF38MdQE99OyInRAWjLtQTgsQZN VtLDjQfW8z++QRCGKScZquQhZNgz0K8AupuWZOFRhUp8xdJMudtm+dSnOecKGpP3mE1Y A20cABHKGUc/N/SlQVmGxHskRLhE3wWasJk2XPGkj+suSkstWpqKEKJAEU23Ra/vHn4O eRHw== 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=7whDJqGLus6GnHTrehLn8ha+pIX8j2xn5px8lkvW5oQ=; b=x7qB5Ku1arNwLH4AeC0sgIVs2QHphPnmWxH4DXZV4nKkqb9fAEtfRkzrlLZpljXtDL 83ySZR8uKdCoTmzuylFJCF3eyemjioGt0BJ4bEBl3LAWZOuVcWQCu6Y/pqFoFIHdvNSs /FBmWKmipIE1/b0c4rk0o0FdaDmAlzeXa9XzMwyif51DNBgK40510NEoVsJ5PthHiAD6 301d4GSSfluRAvBOD15gET8d7Vamgy1cHvxeMDYu72FVZBI8Y921PnY8fU9TtnxUY8E5 hgyL6y1dSXFhzktklFsNIDY5e9PdKMLIuc6k6T33iL77YTaHllLGxyst5Fuxiqr2sd4S S5gA== 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 p5si2468364pgr.472.2018.03.16.08.37.17; Fri, 16 Mar 2018 08:37:32 -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 S934171AbeCPPfh (ORCPT + 99 others); Fri, 16 Mar 2018 11:35:37 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:39878 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933697AbeCPPfe (ORCPT ); Fri, 16 Mar 2018 11:35:34 -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 57EF3109B; Fri, 16 Mar 2018 15:35:33 +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.14 041/109] sched: Stop resched_cpu() from sending IPIs to offline CPUs Date: Fri, 16 Mar 2018 16:23:10 +0100 Message-Id: <20180316152332.182026981@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180316152329.844663293@linuxfoundation.org> References: <20180316152329.844663293@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.14-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 @@ -506,7 +506,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); }