Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1710237pxj; Sun, 9 May 2021 02:43:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzfhNGZUPOp6YDFjEOXotBootRPsFTWx6mheIksPujypUitx25fbRxDR3nQOVRtAS8K4NRO X-Received: by 2002:a05:6e02:154d:: with SMTP id j13mr16054874ilu.46.1620553427049; Sun, 09 May 2021 02:43:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620553427; cv=none; d=google.com; s=arc-20160816; b=aD3UAGnk2N5rcpJapfHk7evnUrUUJ6mbTDzmfZ+5QaetxCDT563ZTAZT9Xxv9Tvrim arKQrp/tt4owUpnAlnkOjYmcT5wGM8g2YaGY2YMSZHiFLaO4l5Ui0dV0rYsvts5Qme8/ +j5PM4gURy5CB2c5PYkXiwktfcFEXpsM+R6Ane43nKKbkK0IZd/KysWUyzBHP0WKcXXx X1oXGaDw2SoMSWPPtrHckMoqT/ovMMDXRxEsTFjHnuPrlJ71g/Bs2IfIq3BP5evnVJMB QqoH2nMEyi5F4SGk06K6NDl+lbm3pzEotc7267SldJ52o4CLakm7sMFb9GETbGjhASpU VHuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=osq21oo/pRLHDf/4dr8pVAgwlLU2iHtgI72VbG/Kutk=; b=zpArW+ayPNex+fu67r+o8Jfa97psIktnMD+7kaAAjXtXiWsAYE5L1V3x2eAxOTYYIo xKQjufQEQsoFMA7JRrCpI0mUdABMIYNEUhVZfq1v0jida4xrFqgTq8YDwmfLRpuG41Rt nJokYgLwOXKf6nx9bKiVzlaM6zyR8SXme62HV11PxhgdmpdCOfpwauD6jNxi5kYLB60I jCjVIlciqmHl3XU9BdC9fhjxq9MG98C3+P6XLMaFpDMlgdiU9LWz7QMJCqAtaJNbF6yC nBWiuv3M4qp0Eej/s6fSbqqqVYH8hRsmmKXiVTtdswliG5Q2j+9saOO//2wuXUz+w4G3 K3sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ExOg7CDV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s4si14262707ilv.29.2021.05.09.02.43.34; Sun, 09 May 2021 02:43:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ExOg7CDV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229593AbhEIJn3 (ORCPT + 99 others); Sun, 9 May 2021 05:43:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229555AbhEIJn2 (ORCPT ); Sun, 9 May 2021 05:43:28 -0400 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3666C061573; Sun, 9 May 2021 02:42:25 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id z18so4131536plg.8; Sun, 09 May 2021 02:42:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=osq21oo/pRLHDf/4dr8pVAgwlLU2iHtgI72VbG/Kutk=; b=ExOg7CDVTtLE34McWFTFmZ2xnh6oSX4bL86dD3qd0hx6y57SY6pN/QQEcz3o01Fjl5 9MPS3LgSaMrU2mfXflKK76Rfi1XhqmrcrBs6X7q1OhPlDHrRMzzskN1JsQBV3Vi7QpIl bcpk+esswKbQ3r6XZyZQpGlVrcwPU8seg/YaJL8YBwC3QTPnPhcq9c8iOUJqXb56tkq1 rWViAwa/b7hnCDeG+XlGodYmUUx3E3LzQkkaen+OxfvpDhtm7eeW2DweeFke17iLMoEu 5aa+0Kwm194+b2B72gUZnnb+PbLFtz9CW0NgOcvFmfLrYOrVuVCWxJgKrFIDYLXSztgc cRrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=osq21oo/pRLHDf/4dr8pVAgwlLU2iHtgI72VbG/Kutk=; b=JBQfAFGDT3Tnapfmfu/lIUpV8jPTMfX+KApROcEpz4t+NUeM+ZSQELb1lNwHmnF8zG AP7h4ed/C9r6TYfI67qX8Z0J9MqyzvwTeouMRB3p8uoqPqZF59D1vvsSFF8UH9iwMKqD TFlxELUTzITvpZyHnXAhjcUd/dtZvjLfNRz3hrMan4Ji/2RSJiywe6nzcF+OcXoNclr0 Ja47+wRF0hqc4iQPH3hltg6J1dDI5400lF/Y5CgXX8nOVc246DD1AQR+rtYQHmUWZS00 mc062/sZKKXltpj2hfVyWB1Xuw2yaMtXizFpLwQAsUi1JAUauHLW3W4KlejMXFD8OGEI f4OA== X-Gm-Message-State: AOAM530uchFc/VJQ9T4ME5EIn97niLxYUG6reS/gVMYRtoJe7YKDFAU5 4XS9LPMj/fLdlJBr6XheR4v3Azzh3QaQ1B3QPJA= X-Received: by 2002:a17:90a:17ad:: with SMTP id q42mr3914834pja.181.1620553344888; Sun, 09 May 2021 02:42:24 -0700 (PDT) MIME-Version: 1.0 References: <20210508085738.6296-1-rocco.yue@mediatek.com> In-Reply-To: <20210508085738.6296-1-rocco.yue@mediatek.com> From: Andy Shevchenko Date: Sun, 9 May 2021 12:42:08 +0300 Message-ID: Subject: Re: [PATCH][v2] rtnetlink: add rtnl_lock debug log To: Rocco Yue Cc: "David S . Miller" , Jakub Kicinski , Matthias Brugger , Andrew Morton , Masahiro Yamada , Nick Desaulniers , Andy Shevchenko , "Peter Zijlstra (Intel)" , Tetsuo Handa , Peter Enderborg , Thomas Gleixner , Anshuman Khandual , Vitor Massaru Iha , Sedat Dilek , Wei Yang , Cong Wang , Di Zhu , Stephen Hemminger , Francis Laniel , Roopa Prabhu , Andrii Nakryiko , Linux Kernel Mailing List , netdev , linux-arm Mailing List , "moderated list:ARM/Mediatek SoC support" , wsd_upsream@mediatek.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, May 8, 2021 at 12:11 PM Rocco Yue wrote: > > We often encounter system hangs caused by certain process > holding rtnl_lock for a long time. Even if there is a lock > detection mechanism in Linux, it is a bit troublesome and > affects the system performance. We hope to add a lightweight > debugging mechanism for detecting rtnl_lock. > > Up to now, we have discovered and solved some potential bugs > through this lightweight rtnl_lock debugging mechanism, which > is helpful for us. > > When you say Y for RTNL_LOCK_DEBUG, then the kernel will detect > if any function hold rtnl_lock too long and some key information > will be printed out to help locate the problem. > > i.e: from the following logs, we can clearly know that the pid=2206 > RfxSender_4 process holds rtnl_lock for a long time, causing the > system to hang. And we can also speculate that the delay operation > may be performed in devinet_ioctl(), resulting in rtnl_lock was > not released in time. > > <6>[ 40.191481][ C6] rtnetlink: -- rtnl_print_btrace start -- You don't seem to get it. It's a quite long trace for the commit message. Do you need all those lines below? Why? > <6>[ 40.191494][ C6] rtnetlink: RfxSender_4[2206][R] hold rtnl_lock > more than 2 sec, start time: 38181400013 > <4>[ 40.191510][ C6] devinet_ioctl+0x1fc/0x75c > <4>[ 40.191517][ C6] inet_ioctl+0xb8/0x1f8 > <4>[ 40.191527][ C6] sock_do_ioctl+0x70/0x2ac > <4>[ 40.191533][ C6] sock_ioctl+0x5dc/0xa74 > <4>[ 40.191541][ C6] __arm64_sys_ioctl+0x178/0x1fc > <4>[ 40.191548][ C6] el0_svc_common+0xc0/0x24c > <4>[ 40.191555][ C6] el0_svc+0x28/0x88 > <4>[ 40.191560][ C6] el0_sync_handler+0x8c/0xf0 > <4>[ 40.191566][ C6] el0_sync+0x198/0x1c0 > <6>[ 40.191571][ C6] Call trace: > <6>[ 40.191586][ C6] rtnl_print_btrace+0xf0/0x124 > <6>[ 40.191595][ C6] call_timer_fn+0x5c/0x3b4 > <6>[ 40.191602][ C6] expire_timers+0xe0/0x49c > <6>[ 40.191609][ C6] __run_timers+0x34c/0x48c > <6>[ 40.191616][ C6] run_timer_softirq+0x28/0x58 > <6>[ 40.191621][ C6] efi_header_end+0x168/0x690 > <6>[ 40.191628][ C6] __irq_exit_rcu+0x108/0x124 > <6>[ 40.191635][ C6] __handle_domain_irq+0x130/0x1b4 > <6>[ 40.191643][ C6] gic_handle_irq.29882+0x6c/0x2d8 > <6>[ 40.191648][ C6] el1_irq+0xdc/0x1c0 > <6>[ 40.191656][ C6] __delay+0xc0/0x180 > <6>[ 40.191663][ C6] devinet_ioctl+0x21c/0x75c > <6>[ 40.191668][ C6] inet_ioctl+0xb8/0x1f8 > <6>[ 40.191675][ C6] sock_do_ioctl+0x70/0x2ac > <6>[ 40.191682][ C6] sock_ioctl+0x5dc/0xa74 > <6>[ 40.191688][ C6] __arm64_sys_ioctl+0x178/0x1fc > <6>[ 40.191694][ C6] el0_svc_common+0xc0/0x24c > <6>[ 40.191699][ C6] el0_svc+0x28/0x88 > <6>[ 40.191705][ C6] el0_sync_handler+0x8c/0xf0 > <6>[ 40.191710][ C6] el0_sync+0x198/0x1c0 > <6>[ 40.191715][ C6] rtnetlink: -- rtnl_print_btrace end -- > > <6>[ 42.181879][ T2206] rtnetlink: rtnl_lock is held by [2206] from > [38181400013] to [42181875177] -- With Best Regards, Andy Shevchenko