Page MenuHomeFreeBSD

Remove LLE read lock from IPv4 fast path.
ClosedPublic

Authored by melifaro on Sep 17 2015, 2:24 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, May 1, 7:30 PM
Unknown Object (File)
Wed, May 1, 7:30 PM
Unknown Object (File)
Wed, May 1, 7:30 PM
Unknown Object (File)
Wed, May 1, 7:30 PM
Unknown Object (File)
Wed, May 1, 7:30 PM
Unknown Object (File)
Wed, May 1, 7:30 PM
Unknown Object (File)
Wed, May 1, 7:30 PM
Unknown Object (File)
Wed, May 1, 7:13 PM
Subscribers

Details

Summary

Since r286722, IPv4 LLE address field is updated while holding AFDATA WLOCK.

In order to remove LLE read lock we need to do a couple of other things.
First, some sort of flags (which can be safely used w/o lle lock) needs to be added to check if we really can use given address data
Second, we need to provide some sort of feedback if the entry is really used when expiration time is approaching. If we skip doing this
we will end up either infinitely keeping all lle records or expiring them even they are used atm.

First is easily solved by adding another flag field updated under AFDATA WLOCK along with mac address.
Second one is more tricky.
Currently, when packet is sent using given lle and its expiration time is within lle->la_preempt = V_arp_maxtries = 5 seconds, we decrease la_preempt under lle RLOCK and send arprequest towards dst. If traffic flow continues (and int case of no reply) we will send up to V_arp_maxtries (one each second) before expiring entry.
New behavior:
We Introduce a simple state machine (incomplete->reachable<->verify->deleted). arptimer is scheduled V_arp_maxtries seconds ealier. On first timer call in "reachable" state code sets special r_skip_req field to 1, sets state to "verify" and reschedule itself V_arpt_rexmit = 1 second forward. While looking up lle fast path checks if given r_skip_req field is nonzero and sets it to zero under new lle req mutex (which should be very rare). On subsequent calls in arptimer we check if r_skip_req was changed (and issue arprequest if yes) and reschedule until expire (if valid reply was received, set state back to "reachable" and reschedule arptimer according to V_arpt_keep value.

Given that, introduce 2 new fields:

  • r_flags, containing flags used by fast path code. New flags are: RLLE_VALID (pre-compiled yes/no flag if we can use the entry) RLLE_IFADDR (to be able to pass given flag as hint to ether_output)
  • r_skip_req, used for fast path feedback.

The new 'req_mtx' mutex is introduced to guarantee very short and deterministic lock/unlock period (lle locks _can_ be holded much longer like in in_lltable_dump_entry) which is crucial to switching lltable lock to rmlock.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

melifaro retitled this revision from to Remove LLE read lock from IPv4 fast path..
melifaro updated this object.
melifaro edited the test plan for this revision. (Show Details)
melifaro added reviewers: network, ae.
sys/netinet/if_ether.c
1131 ↗(On Diff #8817)

Seems you missed 'wtime =' here.

sys/netinet/in.c
1279 ↗(On Diff #8817)

I think LLE_UNLOCKED and LLE_EXCLUSIVE are mutually exclusive. Please, add KASSERT to check this.

Fix wtime line and add KASSERT.

Address comments

sys/netinet/if_ether.c
228 ↗(On Diff #8827)

r_kick variable is used to determine should we do arprequest() again or just expire this lle. Maybe skip_verify will be better name for it?

  • Rename r_kick / r_kickmtx fields.
  • Moved zeroing r_skip_req out of arp_update_lle.

How has this patch been tested?

I did some patch-specific checks like lowering net.link.ether.inet.max_age to small values and checking if arprequest was properly triggered by arptimer code.
I also did some stability checks like installing 254 /32 interface routes, putting ~300kpps traffic via traffic generator (with 8 queues active on NIC). max_age was lowered to 10 seconds, the other system randomly answered to some of these arp requests.
I also got one of my development VMs running with this patch.

gnn added a reviewer: gnn.

Thanks for updating us on the testing. Anything from that that can be automated ought to be passed along or checked in somewhere.

This revision is now accepted and ready to land.Sep 20 2015, 6:54 PM
melifaro edited edge metadata.

Do pre-commit sync.

This revision now requires review to proceed.Dec 5 2015, 9:22 AM
melifaro edited edge metadata.

Remove sbin/ifconfig debug.

This revision was automatically updated to reflect the committed changes.