mbox series

[net-next,v2,0/7] mld: change context from atomic to sleepable

Message ID 20210213175038.28171-1-ap420073@gmail.com (mailing list archive)
Headers show
Series mld: change context from atomic to sleepable | expand

Message

Taehee Yoo Feb. 13, 2021, 5:50 p.m. UTC
This patchset changes the context of MLD module.
Before this patchset, MLD functions are atomic context so it couldn't use
sleepable functions and flags.

There are several reasons why MLD functions are under atomic context.
1. It uses timer API.
Timer expiration functions are executed in the atomic context.
2. atomic locks
MLD functions use rwlock and spinlock to protect their own resources.

So, in order to switch context, this patchset converts resources to use
RCU and removes atomic locks and timer API.
1. The first patch convert from the timer API to delayed work.
Timer API is used for delaying some works.
MLD protocol has a delay mechanism, which is used for replying to a query.
If a listener receives a query from a router, it should send a response
after some delay. But because of timer expire function is executed in
the atomic context, this patch convert from timer API to the delayed work.

2. The second patch separate flags from ifmcaddr6->mca_flags.
The context of mca_flags is atomic context and it can't be changed.
This flag includes 5 flags totally, and two of them don't need to be
protected by atomic context, which is MAF_LOADED and MAF_NOREPORT.
In order to reduce atomic context, this patch separates those flags
from mca_flags.
After this patch, mca_flags are still protected by mca_work and the
new variables are protected by RTNL.

3. The third patch adds new delayed work.
The purpose of mld_clear_delrec() function is to delete records.
But this function can be executed in the datapath.
So, resources, which are used by this function can't be protected by RTNL.
This function uses the ifmcaddr6 struct but this struct must be protected
by RTNL in order to change context. So, this patch adds a new delayed_work,
which executes the mld_clear_delrec() function so this function will be
executed in the sleepable context.

4. The fourth patch deletes inet6_dev->mc_lock.
The mc_lock has protected inet6_dev->mc_tomb pointer.
But this pointer is already protected by RTNL and it isn't be used by
datapath. So, it isn't be needed and because of this, many atomic context
critical sections are deleted.

5. The fifth patch convert ip6_sf_socklist to RCU.
ip6_sf_socklist has been protected by ipv6_mc_socklist->sflock(rwlock).
But this is already protected by RTNL So if it is converted to use RCU
in order to be used in the datapath, the sflock is no more needed.
So, its control path context can be switched to sleepable.

6. The sixth patch convert ip6_sf_list to RCU.
The reason for this patch is the same as the previous patch.

7. The seventh patch convert ifmcaddr6 to RCU.
The reason for this patch is the same as the previous patch.
And because of this conversion, all resources in the MLD modules are
finished to be converted to use RCU.
So, the locking scenario is changed to the following.
1. ifmcaddr6->mca_lock only protects following resources.
   a) ifmcaddr6->mca_flags
   b) ifmcaddr6->mca_work.
   c) ifmcaddr6->mca_sources->sf_gsresp
2. inet6_dev->lock only protects following resources.
   a) inet6_dev->mc_gq_running
   b) inet6_dev->mc_gq_work
   c) inet6_dev->mc_ifc_count
   d) inet6_dev->mc_ifc_work
   e) inet6_dev->mc_delerec_work
3. Other resources are protected by RTNL and RCU.

Changelog:
v1 -> v2:
1. Withdraw unnecessary refactoring patches.
(by Cong Wang, Eric Dumazet, David Ahern)
    a) convert from array to list.
    b) function rename.
2. Separate big one patch into small several patches.
3. Do not rename 'ifmcaddr6->mca_lock'.
In the v1 patch, this variable was changed to 'ifmcaddr6->mca_work_lock'.
But this is actually not needed.
4. Do not use atomic_t for 'ifmcaddr6->mca_sfcount' and
'ipv6_mc_socklist'->sf_count'.
5. Do not add mld_check_leave_group() function.
6. Do not add ip6_mc_del_src_bulk() function.
7. Do not add ip6_mc_add_src_bulk() function.
8. Do not use rcu_read_lock() in the qeth_l3_add_mcast_rtnl().
(by Julian Wiedmann)

Taehee Yoo (7):
  mld: convert from timer to delayed work
  mld: separate two flags from ifmcaddr6->mca_flags
  mld: add a new delayed_work, mc_delrec_work
  mld: get rid of inet6_dev->mc_lock
  mld: convert ipv6_mc_socklist->sflist to RCU
  mld: convert ip6_sf_list to RCU
  mld: convert ifmcaddr6 to RCU

 drivers/s390/net/qeth_l3_main.c |   6 +-
 include/net/if_inet6.h          |  32 +-
 net/batman-adv/multicast.c      |   6 +-
 net/ipv6/addrconf.c             |   9 +-
 net/ipv6/addrconf_core.c        |   2 +-
 net/ipv6/af_inet6.c             |   2 +-
 net/ipv6/mcast.c                | 755 +++++++++++++++++---------------
 7 files changed, 425 insertions(+), 387 deletions(-)

Comments

David Ahern Feb. 13, 2021, 7:58 p.m. UTC | #1
your patches still show up as 8 individual emails.

Did you use 'git send-email --thread --no-chain-reply-to' as Jakub
suggested? Please read the git-send-email man page for what the options do.
Taehee Yoo Feb. 14, 2021, 11:40 a.m. UTC | #2
On 21. 2. 14. 오전 4:58, David Ahern wrote:
> your patches still show up as 8 individual emails.
> 
> Did you use 'git send-email --thread --no-chain-reply-to' as Jakub
> suggested? Please read the git-send-email man page for what the options do.
> 

I sent all patches individually with these options.
git send-email --thread --no-chain-reply-to 0000.patch
git send-email --thread --no-chain-reply-to 0001.patch
and so on.

So, it didn't work I think.
Then I tested the below command and it works well.
git send-email --thread --no-chain-reply-to 000*

So, the next time, it would work well.
Sorry for this,
Thanks!
David Ahern Feb. 14, 2021, 4:52 p.m. UTC | #3
On 2/14/21 4:40 AM, Taehee Yoo wrote:
> 
> 
> On 21. 2. 14. 오전 4:58, David Ahern wrote:
>> your patches still show up as 8 individual emails.
>>
>> Did you use 'git send-email --thread --no-chain-reply-to' as Jakub
>> suggested? Please read the git-send-email man page for what the
>> options do.
>>
> 
> I sent all patches individually with these options.
> git send-email --thread --no-chain-reply-to 0000.patch
> git send-email --thread --no-chain-reply-to 0001.patch
> and so on.
> 
> So, it didn't work I think.
> Then I tested the below command and it works well.
> git send-email --thread --no-chain-reply-to 000*
> 

yes, you have to send all of the patches in 1 command.