netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Martin Zaharinov <micron10@gmail.com>
To: Eric Dumazet <edumazet@google.com>
Cc: Ido Schimmel <idosch@idosch.org>, netdev <netdev@vger.kernel.org>
Subject: Re: Very slow remove interface from kernel
Date: Tue, 9 May 2023 21:50:18 +0300	[thread overview]
Message-ID: <FE7CE62C-DBEB-4FE1-8ACB-C8B7DAF15710@gmail.com> (raw)
In-Reply-To: <CANn89iKOm2WPoemiqCsWaMXMyGf9C5xXH=NaSidPSNCpKxf_jQ@mail.gmail.com>

Hi Eric

i try on kernel 6.3.1 


time for i in $(seq 2 4094); do ip link del link eth1 name vlan$i type vlan id $i; done

real	4m51.633s  —— here i stop with Ctrl + C  -  and rerun  and second part finish after 3 min
user	0m7.479s
sys	0m0.367s


Config is very clean i remove big part of CONFIG options .

is there options to debug what is happen.

m


> On 9 May 2023, at 15:36, Eric Dumazet <edumazet@google.com> wrote:
> 
> On Tue, May 9, 2023 at 1:10 PM Martin Zaharinov <micron10@gmail.com> wrote:
>> 
>> Hi
>> 
>> in short, there is no way to make the kernel do it faster.
> 
> Make sure your kernel does not include options you do not need.
> 
>> 
>> Before time with old kernel unregister device make more faster .
>> 
>> with latest kernel >6.x this make very slow .
>> 
> 
> Yup, I feel your pain.
> 
> Maybe you should start a bisection then...
> 
> You might find that you have some CONFIG_ option that makes this
> operation very slow.
> 
> Some layers (like hamradio and others) lack batch operations in their
> netdev removal handlers.
> 
> For instance, on one machine I have access to and with my standard
> .config, your benchmark gives a not too bad result with pristine
> linux-6.3
> 
> modprobe dummy
> ip link set dev dummy0 up
> for i in $(seq 2 4094); do ip link add link dummy0 name vlan$i type
> vlan id $i; done
> for i in $(seq 2 4094); do ip link set dev vlan$i up; done
> time for i in $(seq 2 4094); do ip link del link eth1 name vlan$i type
> vlan id $i; done
> real 0m55.808s
> user 0m0.788s
> sys 0m6.868s
> 
> Without batching, I think one netdev removal needs three synchronize_net() calls
> 
> I am reasonably certain numbers would not look so good if I booted a
> "make allyesconfig" kernel.
> 
> 
> 
> 
> 
> 
> 
> 
>> 
>> is there any chance to try to make this more fast.
>> 
>> 
>> m.
>> 
>> 
>>> On 9 May 2023, at 13:32, Eric Dumazet <edumazet@google.com> wrote:
>>> 
>>> On Tue, May 9, 2023 at 12:20 PM Ido Schimmel <idosch@idosch.org> wrote:
>>>> 
>>>> On Tue, May 09, 2023 at 11:22:13AM +0300, Martin Zaharinov wrote:
>>>>> add vlans :
>>>>> for i in $(seq 2 4094); do ip link add link eth1 name vlan$i type vlan id $i; done
>>>>> for i in $(seq 2 4094); do ip link set dev vlan$i up; done
>>>>> 
>>>>> 
>>>>> and after that run :
>>>>> 
>>>>> for i in $(seq 2 4094); do ip link del link eth1 name vlan$i type vlan id $i; done
>>>>> 
>>>>> 
>>>>> time for remove for this 4093 vlans is 5-10 min .
>>>>> 
>>>>> Is there options to make fast this ?
>>>> 
>>>> If you know you are going to delete all of them together, then you can
>>>> add them to the same group during creation:
>>>> 
>>>> for i in $(seq 2 4094); do ip link add link eth1 name vlan$i up group 10 type vlan id $i; done
>>>> 
>>>> Then delete the group:
>>>> 
>>>> ip link del group 10
>>>> 
>>> 
>>> Another way is to create a netns for retiring devices,
>>> move devices to the 'retirens' when they need to go away.
>>> 
>>> Then once per minute, delete the retirens and create a new one.
>>> 
>>> -> This batches netdev deletions.
>>> 
>>> 
>>>> IIRC, in the past there was a patchset to allow passing a list of
>>>> ifindexes instead of a group number, but it never made its way upstream.
>> 
>> 


  reply	other threads:[~2023-05-09 18:50 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-09  8:22 Very slow remove interface from kernel Martin Zaharinov
2023-05-09 10:20 ` Ido Schimmel
2023-05-09 10:32   ` Eric Dumazet
2023-05-09 11:10     ` Martin Zaharinov
2023-05-09 12:36       ` Eric Dumazet
2023-05-09 18:50         ` Martin Zaharinov [this message]
2023-05-09 20:08           ` Ido Schimmel
2023-05-09 20:16             ` Martin Zaharinov
2023-05-10  5:31             ` Martin Zaharinov
2023-05-10  6:06             ` Martin Zaharinov
2023-05-10  9:40               ` Eric Dumazet
2023-05-10 13:15                 ` Martin Zaharinov
2023-05-25  7:50                 ` Martin Zaharinov
2023-05-10  9:16             ` Martin Zaharinov
2023-05-10  9:22               ` Eric Dumazet
2023-05-09 20:08         ` Martin Zaharinov

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=FE7CE62C-DBEB-4FE1-8ACB-C8B7DAF15710@gmail.com \
    --to=micron10@gmail.com \
    --cc=edumazet@google.com \
    --cc=idosch@idosch.org \
    --cc=netdev@vger.kernel.org \
    /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).