All of lore.kernel.org
 help / color / mirror / Atom feed
* Way to Know When cleanup_net() Calls Are Done
@ 2017-07-02  5:50 Leon Yang
  2017-07-05 23:14 ` Cong Wang
  0 siblings, 1 reply; 3+ messages in thread
From: Leon Yang @ 2017-07-02  5:50 UTC (permalink / raw)
  To: netdev; +Cc: davem

Hi,

I am measuring the time cost of parallel creation and destruction of
net namespaces.

As cleanup_net() is invoked from workqueue, the exit of a net
namespace does not mean the cleanup is completed. Therefore I use
ftrace to count the number of net_drop_ns() are called. But I found
that the number of namespaces created does not match with the number
of net_drop_ns() calls even after a long wait.

Can you give some hints on why this is happening? and what would be
the correct way to know when the last cleanup_net() is done?

Thanks,

Leon

*psudo code of my program:

n = 0;
while (1) {
        pid = fork();
        if (pid == 0) {
                unshare(CLONE_NEWNET);
                exit(0);
        } else if (/* run out of PID */) {
                /* wait for all the children */
                /* get total time for n creations+destructions */
                n = 0;
        } else { /* do nothing */ }
        n++;
}

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Way to Know When cleanup_net() Calls Are Done
  2017-07-02  5:50 Way to Know When cleanup_net() Calls Are Done Leon Yang
@ 2017-07-05 23:14 ` Cong Wang
  2017-07-05 23:29   ` Leon Yang
  0 siblings, 1 reply; 3+ messages in thread
From: Cong Wang @ 2017-07-05 23:14 UTC (permalink / raw)
  To: Leon Yang; +Cc: Linux Kernel Network Developers, David Miller

On Sat, Jul 1, 2017 at 10:50 PM, Leon Yang <leon.gh.yang@gmail.com> wrote:
> Hi,
>
> I am measuring the time cost of parallel creation and destruction of
> net namespaces.
>
> As cleanup_net() is invoked from workqueue, the exit of a net
> namespace does not mean the cleanup is completed. Therefore I use
> ftrace to count the number of net_drop_ns() are called. But I found
> that the number of namespaces created does not match with the number
> of net_drop_ns() calls even after a long wait.
>
> Can you give some hints on why this is happening? and what would be
> the correct way to know when the last cleanup_net() is done?

Probably no way to know this in user-space, netns is refcount'ed,
we don't know which is the last one releasing it.

There is a per-userns counter for netns, but I don't see it is ever
exposed to user-space.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Way to Know When cleanup_net() Calls Are Done
  2017-07-05 23:14 ` Cong Wang
@ 2017-07-05 23:29   ` Leon Yang
  0 siblings, 0 replies; 3+ messages in thread
From: Leon Yang @ 2017-07-05 23:29 UTC (permalink / raw)
  To: Cong Wang; +Cc: Linux Kernel Network Developers, David Miller

In my case, as I know the number of unshare(2) calls (say 10000), I
think there should be same number of net_drop_ns() calls regardless of
the userns counter. So the 10000th call to net_drop_ns() should be the
last one.

After some investigation I figure out my problem. When I was running
the program, I read the debug/tracing/trace file for a couple times to
check if ftrace was working. This read seems to prevent the ftrace
ring buffer from being written so that some entries are missing from
the ftrace results.

Therefore the problem is completely unrelated to net namespace. Sorry
for the confusion.

On Wed, Jul 5, 2017 at 6:14 PM, Cong Wang <xiyou.wangcong@gmail.com> wrote:
> On Sat, Jul 1, 2017 at 10:50 PM, Leon Yang <leon.gh.yang@gmail.com> wrote:
>> Hi,
>>
>> I am measuring the time cost of parallel creation and destruction of
>> net namespaces.
>>
>> As cleanup_net() is invoked from workqueue, the exit of a net
>> namespace does not mean the cleanup is completed. Therefore I use
>> ftrace to count the number of net_drop_ns() are called. But I found
>> that the number of namespaces created does not match with the number
>> of net_drop_ns() calls even after a long wait.
>>
>> Can you give some hints on why this is happening? and what would be
>> the correct way to know when the last cleanup_net() is done?
>
> Probably no way to know this in user-space, netns is refcount'ed,
> we don't know which is the last one releasing it.
>
> There is a per-userns counter for netns, but I don't see it is ever
> exposed to user-space.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-07-05 23:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-02  5:50 Way to Know When cleanup_net() Calls Are Done Leon Yang
2017-07-05 23:14 ` Cong Wang
2017-07-05 23:29   ` Leon Yang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.