Received: by 10.213.65.68 with SMTP id h4csp767084imn; Fri, 23 Mar 2018 15:58:51 -0700 (PDT) X-Google-Smtp-Source: AG47ELvdIHN63FonUij1nJTJPtf1LR5L99t/BsBccKQ3hDF0lML5lQu8iXsWguIq1jQBa0LmdOrv X-Received: by 10.99.101.193 with SMTP id z184mr22815257pgb.429.1521845931467; Fri, 23 Mar 2018 15:58:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521845931; cv=none; d=google.com; s=arc-20160816; b=e37wQiaeyTRmWiUDMWP7xyA395KVtllJiqidcF9CZxvcrmBj8HQOwM6u6WnN7HTAR1 Z8QOXZVUG8ufyi43jqyzcaOKicA+PLFG3yAHuJhdf6Rl3q5X6IrmhIOEw4EoFZIfdMn7 J6HeMmkT8EVaEB64+ou1Npgbzs+VOVvbIfKVEeCpYPTHBo/CoxBOspo73M1/R1T34BwU GV2ta2pdjVhnhODDBqi4M0Jsmf/k0id5BtTL1Jwr4tfDSsjWt2JiNHxXeSIcybhH3+K/ 3HNMrm9ExtPqwG+bhTIsdGIx1rNKGVqPfrskDD5XFnD+0fOHzW53D05NHmL2hOHrnae0 3pvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=zoSmCQMImdNRUQFQi8DhgbxmXiwB31VzLJE1UDR2eh8=; b=dYl9hcTty8WhWeM12tZ31jiCJxA/eJFIHzawnEhEkbpLRgGlhwqYmiM/diWI4hDJOx aYDSvMD/CRtusslHcdUHn7fjtjRar1/m13IQhOhrMHvDo1x+bcdLCmp6vWbQsqbkEjRf nQJxVwcq/Yg8S1Fjzamv0EuXVJau1DeIWSMHIiBpgzjCZxDmhwojaF5s06+0ILm0q+pG qGauRL7mFIeaLbx9vja8lFTpJ6S/CxTjdbqRY5Nk6EWNbdbukTIxiP+YzJnZ18QGz4UB A9DYyAbFhRJegUo7Km4fFzuIz25jhFZjCJFACP8Nm6fSiUBIHZyWXujQWqZ5Eb7+Kh7x ddbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=QhrtbZGA; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u70si6591550pgd.619.2018.03.23.15.58.37; Fri, 23 Mar 2018 15:58:51 -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=@google.com header.s=20161025 header.b=QhrtbZGA; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752667AbeCWW5I (ORCPT + 99 others); Fri, 23 Mar 2018 18:57:08 -0400 Received: from mail-it0-f67.google.com ([209.85.214.67]:34756 "EHLO mail-it0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752163AbeCWW5G (ORCPT ); Fri, 23 Mar 2018 18:57:06 -0400 Received: by mail-it0-f67.google.com with SMTP id z7-v6so6664439iti.1 for ; Fri, 23 Mar 2018 15:57:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=zoSmCQMImdNRUQFQi8DhgbxmXiwB31VzLJE1UDR2eh8=; b=QhrtbZGAWlAF/m0h671lWeAhvyjw7MpyNEXU1sboW6EgLOTuGy3HEZdkKHkpFiEqJh j4Aq49Eh4nLFrHA4VPTdTGUmxJ2IIx4bFmXMV2xH3wU7msoMD6+I5KsLb0VoX9A2Sj+v Rvw16YRv/5A2Pab2MP7zSkktxy6y6ZeYc7KA+PSLLNtGxD+A4IOFWXvkeQuvDafir9sF RzztvM4aQ8c0HPTNQFInnDGLRSnXCYq6JjPtnx5V9c4cBkVvYoGGRulMhNnB3UMueli2 z66QhRfZAYWoles9RVxxtj1OJQzFG94T7cJ/mHckiG1x6Ls5AR7caZE73ocyB2zCIyvT iHiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=zoSmCQMImdNRUQFQi8DhgbxmXiwB31VzLJE1UDR2eh8=; b=bnonqzvWCkCQLcSg/bIyrWhzyANApxGH/PbynBpWjWWeJKRYkG/IvUZMSk1/ETZVN7 AIdXOzYCm8KXq68WdQJsUdEhl26dTb8DQUjsksnyIwiVfEgthgrH6h6FpeR1dPj+OH6h k/Ear3nUIHyFLTTIfraQm6A/qsaJNC0LQCbANIiNSihgS4wBsHV2DeWbkEDLvnli95Kj Nvxeyk9YRo8O2Xhkw8V6QPKUa7K2Id6UhD+KNBe+LACPrVLMPlMj/kvXXfnI7NVzeIQH f84hqY08nsEGFtwxLv6D7LrWuN9VvvZQbDCqo9C2k0ObDvkzVF17aeGgeKDRMQjYu9Im jWrg== X-Gm-Message-State: AElRT7HhZNLAfEeVB55xzFUN+LGcw/p0sAzDUXq7INTcTSXDN6JQFW5H xKB/V0iL0Iir5U/Hp2rVvM2OR7ZMtNAfcOGwTEYDCw== X-Received: by 2002:a24:9184:: with SMTP id i126-v6mr15604551ite.41.1521845825072; Fri, 23 Mar 2018 15:57:05 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.11.158 with HTTP; Fri, 23 Mar 2018 15:57:04 -0700 (PDT) In-Reply-To: <20180323174023.60579f45@gandalf.local.home> References: <20180323172843.763579a9@gandalf.local.home> <20180323174023.60579f45@gandalf.local.home> From: Joel Fernandes Date: Fri, 23 Mar 2018 15:57:04 -0700 Message-ID: Subject: Re: rcu: Add might_sleep() check to synchronize_rcu() To: Steven Rostedt Cc: Thomas Gleixner , LKML , "Paul E. McKenney" , Peter Zijlstra , Josh Triplett , Mathieu Desnoyers , Lai Jiangshan 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 On Fri, Mar 23, 2018 at 2:40 PM, Steven Rostedt wrote: > On Fri, 23 Mar 2018 22:33:29 +0100 (CET) > Thomas Gleixner wrote: > >> On Fri, 23 Mar 2018, Steven Rostedt wrote: >> >> > On Fri, 23 Mar 2018 22:12:24 +0100 (CET) >> > Thomas Gleixner wrote: >> > >> > > synchronize_rcu() lacks a might_sleep() check which would have caught that >> > > issue way earlier because it would trigger with the minimal debug options >> > > enabled. >> > > >> > > Add a might_sleep() check to catch such cases. >> > >> > I'm not against the patch, but really? I would think that >> > synchronize_rcu() would pretty much always schedule, and scheduling >> > from atomic would have triggered with minimal debug options enabled. >> >> Dunno. The reported splat is here: >> >> https://pastebin.com/raw/puvh0cXE > > [ 150.560848] ODEBUG: object is not on stack, but annotated > [ 150.566398] ------------[ cut here ]------------ > [ 150.571133] WARNING: CPU: 1 PID: 0 at lib/debugobjects.c:300 __debug_object_init+0x526/0xc40 > [ 150.579682] Kernel panic - not syncing: panic_on_warn set ... > [ 150.579682] > [ 150.587012] CPU: 1 PID: 0 Comm: swapper/1 Not tainted 4.9.89-g960923f #61 > [ 150.593906] Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 > [ 150.603233] ffff8801db307a08 ffffffff81d96069 ffffffff83a482c0 ffff8801db307ae0 > [ 150.611190] ffffffff83c19700 ffffffff81dfefb6 0000000000000009 ffff8801db307ad0 > [ 150.619157] ffffffff8142fbd1 0000000041b58ab3 ffffffff8418bd08 ffffffff8142fa15 > [ 150.627118] Call Trace: > [ 150.629667] [ 150.631700] [] dump_stack+0xc1/0x128 > [ 150.637051] [] ? __debug_object_init+0x526/0xc40 > [ 150.643431] [] panic+0x1bc/0x3a8 > [ 150.648416] [] ? percpu_up_read_preempt_enable.constprop.53+0xd7/0xd7 > [ 150.656611] [] ? load_image_and_restore+0xf9/0xf9 > [ 150.663070] [] ? vprintk_default+0x1d/0x30 > [ 150.668925] [] ? __warn+0x1a9/0x1e0 > [ 150.674170] [] ? __debug_object_init+0x526/0xc40 > [ 150.680543] [] __warn+0x1c4/0x1e0 > [ 150.685614] [] warn_slowpath_null+0x2c/0x40 > [ 150.691972] [] __debug_object_init+0x526/0xc40 > [ 150.698174] [] ? debug_object_fixup+0x30/0x30 > [ 150.704283] [] debug_object_init_on_stack+0x19/0x20 > [ 150.710917] [] __wait_rcu_gp+0x93/0x1b0 > [ 150.716508] [] synchronize_rcu.part.65+0x101/0x110 > [ 150.723054] [] ? rcu_pm_notify+0xc0/0xc0 > [ 150.728735] [] ? __call_rcu.constprop.72+0x910/0x910 > [ 150.735459] [] ? __lock_is_held+0xa1/0xf0 > [ 150.741223] [] synchronize_rcu+0x27/0x90 > [ 150.746908] [] __l2tp_session_unhash+0x3d5/0x550 > > Looks like __l2tp_session_unhash() is the real culprit here. > > [ 150.753281] [] ? __l2tp_session_unhash+0x1bf/0x550 > [ 150.759828] [] ? __local_bh_enable_ip+0x6a/0xd0 > [ 150.766123] [] ? l2tp_udp_encap_recv+0xd90/0xd90 > [ 150.772497] [] l2tp_tunnel_closeall+0x1e7/0x3a0 > [ 150.778782] [] l2tp_tunnel_destruct+0x30e/0x5a0 > [ 150.785067] [] ? l2tp_tunnel_destruct+0x1aa/0x5a0 > [ 150.791537] [] ? l2tp_tunnel_del_work+0x460/0x460 > [ 150.797997] [] __sk_destruct+0x53/0x570 > [ 150.803588] [] rcu_process_callbacks+0x898/0x1300 > [ 150.810048] [] ? rcu_process_callbacks+0x977/0x1300 > [ 150.816684] [] ? __sk_dst_check+0x240/0x240 > [ 150.822625] [] __do_softirq+0x206/0x951 > [ 150.828223] [] irq_exit+0x165/0x190 > [ 150.833557] [] smp_apic_timer_interrupt+0x7b/0xa0 > [ 150.840018] [] apic_timer_interrupt+0xa0/0xb0 > [ 150.846132] [ 150.848166] [] ? native_safe_halt+0x6/0x10 > [ 150.854036] [] ? trace_hardirqs_on+0xd/0x10 > [ 150.859973] [] default_idle+0x55/0x360 > [ 150.865478] [] arch_cpu_idle+0xa/0x10 > > I think you want this instead, as __l2tp_session_unhash is what looks > like might be hiding the call to synchronize_rcu(). It's not called in > all instances, and I don't think your patch would have triggered the > issues before hand. You want this: > > diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c > index 194a7483bb93..857b494bee29 100644 > --- a/net/l2tp/l2tp_core.c > +++ b/net/l2tp/l2tp_core.c > @@ -1677,6 +1677,8 @@ void __l2tp_session_unhash(struct l2tp_session *session) > { > struct l2tp_tunnel *tunnel = session->tunnel; > > + might_sleep(); > + > /* Remove the session from core hashes */ > if (tunnel) { > /* Remove from the per-tunnel hash */ Thanks Thomas and Steven, also shouldn't this code be calling synchronize_rcu_bh instead of synchronize_rcu, to complement the rcu_read_lock_bh? In which situations would you call one versus the other? Also it seems rcu_read_lock_bh does a might_sleep already in rcu_blocking_is_gp. thanks, - Joel