Received: by 10.213.65.68 with SMTP id h4csp485305imn; Fri, 16 Mar 2018 09:09:59 -0700 (PDT) X-Google-Smtp-Source: AG47ELu6ta8F5tuzQTRs4YyFi7aN3nRy6qHhhG2YoV6fHOEq0wo/QPrldB2lHwpWVxstHsdRDoK6 X-Received: by 2002:a17:902:b691:: with SMTP id c17-v6mr2752749pls.308.1521216599526; Fri, 16 Mar 2018 09:09:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521216599; cv=none; d=google.com; s=arc-20160816; b=TraNlN6Aa++1mIb75NfvyUIyE+z5gc1eISMhTkMSv72JnIRXt8tOsM+i4+wHxBMWG0 /uSSxMdJNUCcpzobsItf0Be99NeEc3dnDvR9y/9JBEwixkbQ/7jxKTrKH4js02SxIuGO SzHnBu4x19HE8nTbmsnJ0X3kwt3oYZTxZDQOsliOaT7Uu2ijuPqzOexsaLD3PLstlezt nfVTliYqm8OiLDLujvZXcVE+1DKvcHl/SEk52EQ0G63Z/Z/E2U3/rS1zAlTxni3UedJN A0j9dfwz/YIsrlmGbtp5+jZ4/sTRxd4iMop+XJyAcZSrNVZFXp/lhPWJetxA8BOb5fp3 M19w== 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=BeuYRk9GDG42v1lLWOnPHeJK+yoibCcj3A6ueC89vA8=; b=Rj3TrYjQ4+l1Rct5rO5tog08R+T+hUh4vFXpRPNMOXKDLcCORQNL8Ka78Tk00VtfvD w5jPwBshG7lY35CSij4OtWVKNSqIa1GcU8NCmSVjUNVukTZVkRgHoJmR7GgkXAhSD4cl LIHzIgFHUa4NZbbkDqwT80QxSPKQIUJjqdZl3Qfr9nNWwNIma71R/CX3VZFkDIWXJmX1 2IaPdkAfqFOCZG4+8IZ0Y6Km31yv8TBoiCx/5WR6kGtQpxHxxSYd6CN8MukIE/MNJO6l AxyG3f5UrUuglTx2bnPXsJQ6Efi75BjGew96wgXGU4KKi8cITm9yldxS6cJoyN7nih9t aopA== 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 q1si5173810pgr.455.2018.03.16.09.09.44; Fri, 16 Mar 2018 09:09:59 -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 S933420AbeCPQIz (ORCPT + 99 others); Fri, 16 Mar 2018 12:08:55 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:43860 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965149AbeCPPlI (ORCPT ); Fri, 16 Mar 2018 11:41:08 -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 B3DDCEE3; Fri, 16 Mar 2018 15:41:07 +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.15 047/128] sched: Stop resched_cpu() from sending IPIs to offline CPUs Date: Fri, 16 Mar 2018 16:23:08 +0100 Message-Id: <20180316152339.163139756@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180316152336.199007505@linuxfoundation.org> References: <20180316152336.199007505@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.15-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); }