netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Ahern <dsahern@gmail.com>
To: David Ahern <dsahern@gmail.com>,
	Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>,
	Eric Dumazet <eric.dumazet@gmail.com>,
	"David S. Miller" <davem@davemloft.net>
Cc: Julian Anastasov <ja@ssi.bg>,
	Cong Wang <xiyou.wangcong@gmail.com>,
	syzbot <syzbot+30209ea299c09d8785c9@syzkaller.appspotmail.com>,
	ddstreet@ieee.org, dvyukov@google.com,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	syzkaller-bugs@googlegroups.com
Subject: Re: unregister_netdevice: waiting for DEV to become free (2)
Date: Mon, 29 Apr 2019 12:43:14 -0600	[thread overview]
Message-ID: <d56b7989-8ac6-36be-0d0b-43251e1a2907@gmail.com> (raw)
In-Reply-To: <f71dd5cd-c040-c8d6-ab4b-df97dea23341@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1624 bytes --]

On 4/29/19 12:34 PM, David Ahern wrote:
> On 4/27/19 10:22 PM, Tetsuo Handa wrote:
>> On 2019/04/28 8:52, Eric Dumazet wrote:
>>> On 4/27/19 3:33 PM, Tetsuo Handa wrote:
>>>>
>>>> I'm waiting for davem why it is safe to move the dst entry from
>>>> "a device to unregister" to "a loopback device in that namespace".
>>>> I'm waiting for an explanation how the dst entry which was moved to
>>>> "a loopback device in that namespace" is released (i.e. what the
>>>> expected shutdown sequence is).
>>>
>>> The most probable explanation is that we make sure the loopback device
>>> is the last one to be dismantled at netns deletion,
>>> and this would obviously happen after all dst have been released.
>>>
>>
>> rt_flush_dev() becomes a no-op if "dev" == "a loopback device in that
>> namespace". And according to debug printk(), rt_flush_dev() is called
>> on "a loopback device in that namespace" itself.
>>
>> If "a loopback device in that namespace" is the last "one" (== "a network
>> device in that namespace" ?), which shutdown sequence should have called
>> dev_put("a loopback device in that namespace") before unregistration of
>> "a loopback device in that namespace" starts?
>>
>> Since I'm not a netdev person, I appreciate if you can explain
>> that shutdown sequence using a flow chart.
>>
> 
> The attached patch adds a tracepoint to notifier_call_chain. If you have
> KALLSYMS enabled it will show the order of the function handlers:
> 
> perf record -e notifier:* -a -g &
> 
> ip netns del <NAME>
> <wait a few seconds>
> 
> fg
> <ctrl-c on perf-record>
> 
> perf script
> 

with the header file this time.

[-- Attachment #2: 0001-notifier-add-tracepoint-to-notifier_call_chain.patch --]
[-- Type: text/plain, Size: 2436 bytes --]

From de8bfae0606d748908a70a435fee9d9ce57b13ea Mon Sep 17 00:00:00 2001
From: David Ahern <dsahern@gmail.com>
Date: Mon, 29 Apr 2019 11:38:49 -0700
Subject: [PATCH] notifier: add tracepoint to notifier_call_chain

Signed-off-by: David Ahern <dsahern@gmail.com>
---
 include/trace/events/notifier.h | 49 +++++++++++++++++++++++++++++++++++++++++
 kernel/notifier.c               |  3 +++
 2 files changed, 52 insertions(+)
 create mode 100644 include/trace/events/notifier.h

diff --git a/include/trace/events/notifier.h b/include/trace/events/notifier.h
new file mode 100644
index 000000000000..7c531a1135cb
--- /dev/null
+++ b/include/trace/events/notifier.h
@@ -0,0 +1,49 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM notifier
+
+#if !defined(_TRACE_NOTIFIER_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_NOTIFIER_H
+
+#include <linux/notifier.h>
+#include <linux/kallsyms.h>
+#include <linux/tracepoint.h>
+
+TRACE_EVENT(notifier_call_chain,
+
+	TP_PROTO(struct notifier_block *nb, unsigned long val),
+
+	TP_ARGS(nb, val),
+
+	TP_STRUCT__entry(
+		__field(	u64,	val	)
+		__field(	u64,	fcn	)
+		__dynamic_array(char,  fcnstr,   KSYM_SYMBOL_LEN)
+	),
+
+	TP_fast_assign(
+		void *p = nb->notifier_call;
+		char sym[KSYM_SYMBOL_LEN];
+
+		__entry->val = val;
+		__entry->fcn = (u64) p;
+
+		p = dereference_symbol_descriptor(p);
+#ifdef CONFIG_KALLSYMS
+		sprint_symbol_no_offset(sym, __entry->fcn);
+		/* avoid a bogus warning:
+		 * "the address of sym will always evaluate as true"
+		 * by using &sym[0]
+		 */
+		__assign_str(fcnstr, &sym[0]);
+#else
+		__entry->fcnstr[0] = '\0';
+#endif
+	),
+
+	TP_printk("val %lld fcn %llx name %s", __entry->val, __entry->fcn, __get_str(fcnstr))
+);
+#endif /* _TRACE_NOTIFIER_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
diff --git a/kernel/notifier.c b/kernel/notifier.c
index 6196af8a8223..9b65a9c56fd7 100644
--- a/kernel/notifier.c
+++ b/kernel/notifier.c
@@ -5,6 +5,8 @@
 #include <linux/rcupdate.h>
 #include <linux/vmalloc.h>
 #include <linux/reboot.h>
+#define CREATE_TRACE_POINTS
+#include <trace/events/notifier.h>
 
 /*
  *	Notifier list for kernel code which wants to be called
@@ -90,6 +92,7 @@ static int notifier_call_chain(struct notifier_block **nl,
 			continue;
 		}
 #endif
+		trace_notifier_call_chain(nb, val);
 		ret = nb->notifier_call(nb, val, v);
 
 		if (nr_calls)
-- 
2.11.0


  reply	other threads:[~2019-04-29 18:43 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <00000000000056268e05737dcb95@google.com>
     [not found] ` <000000000000c5b63005737f290d@google.com>
2018-08-15 20:41   ` unregister_netdevice: waiting for DEV to become free (2) Dmitry Vyukov
2018-08-20  4:31 ` syzbot
2018-08-20 12:55   ` Julian Anastasov
2018-08-21  5:40     ` Cong Wang
2018-08-22  4:11       ` Julian Anastasov
2019-04-15 13:36     ` Tetsuo Handa
2019-04-15 15:35       ` David Ahern
2019-04-21 20:41         ` Stephen Suryaputra
2019-04-22 14:58           ` David Ahern
2019-04-22 16:04             ` Eric Dumazet
2019-04-22 16:09               ` Eric Dumazet
2019-04-16 14:00       ` Tetsuo Handa
2019-04-26 13:43         ` Tetsuo Handa
2019-04-27 17:16           ` David Ahern
2019-04-27 22:33             ` Tetsuo Handa
2019-04-27 23:52               ` Eric Dumazet
2019-04-28  4:22                 ` Tetsuo Handa
2019-04-28 15:04                   ` Eric Dumazet
2019-04-29 18:34                   ` David Ahern
2019-04-29 18:43                     ` David Ahern [this message]
2019-05-01 13:38                       ` Tetsuo Handa
2019-05-01 14:52                         ` David Ahern
2019-05-01 16:16                           ` Tetsuo Handa
2019-05-04 14:52                             ` [PATCH] ipv4: Delete uncached routes upon unregistration of loopback device Tetsuo Handa
2019-05-04 15:56                               ` Eric Dumazet
2019-05-04 17:09                                 ` Tetsuo Handa
2019-05-04 17:24                                   ` Eric Dumazet
2019-05-04 20:13                               ` Julian Anastasov
2019-11-28  9:56     ` unregister_netdevice: waiting for DEV to become free (2) Tetsuo Handa
2019-11-29  5:54       ` Lukas Bulwahn
2019-11-29  6:51       ` Jouni Högander
2019-12-05 10:00       ` Jouni Högander
2019-12-05 11:00         ` Tetsuo Handa
2019-12-16 11:12           ` Tetsuo Handa
2019-12-17  7:08             ` Jouni Högander
2019-10-11 10:14   ` Tetsuo Handa
2019-10-11 15:12     ` Alexei Starovoitov
2019-10-16 10:34       ` Toke Høiland-Jørgensen
2019-11-15  9:43         ` Tetsuo Handa
2019-11-21 11:36           ` Toke Høiland-Jørgensen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d56b7989-8ac6-36be-0d0b-43251e1a2907@gmail.com \
    --to=dsahern@gmail.com \
    --cc=davem@davemloft.net \
    --cc=ddstreet@ieee.org \
    --cc=dvyukov@google.com \
    --cc=eric.dumazet@gmail.com \
    --cc=ja@ssi.bg \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    --cc=syzbot+30209ea299c09d8785c9@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    --cc=xiyou.wangcong@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).