Take non-incremental network stats from bpf maps
Use two maps to record the details of network stats. Swap and clean up
after system server pulls the stats. The TAG_STATS_MAP is removed since
we don't need to worry about losing the stats for each uid if the eBPF map
is full. All the stats can be stored in the same map now and it is very
unlikely to overflow the map before system server scrapes the stats and
clean it up. Add a benchmark test to measure the performance of creating
and closing pf_key socket. A typical result is:
------------------------------------------------------------------------
Benchmark Time CPU Iterations
------------------------------------------------------------------------
BpfBenchMark/WaitForRcu/1 86615 ns 54858 ns 20209
Bug: 79171384
Test: dumpsys netd trafficcontroller
NetworkUsageStatsTest
Change-Id: Ic79e382f51bf21eee78c4cac5a8a97edaf3654cd
diff --git a/server/TrafficControllerTest.cpp b/server/TrafficControllerTest.cpp
index 61622d8..2bc374c 100644
--- a/server/TrafficControllerTest.cpp
+++ b/server/TrafficControllerTest.cpp
@@ -115,8 +115,8 @@
mTc.mCookieTagMap.reset(mFakeCookieTagMap.getMap());
mTc.mUidCounterSetMap.reset(mFakeUidCounterSetMap.getMap());
mTc.mAppUidStatsMap.reset(mFakeAppUidStatsMap.getMap());
- mTc.mUidStatsMap.reset(mFakeUidStatsMap.getMap());
- mTc.mTagStatsMap.reset(mFakeTagStatsMap.getMap());
+ mTc.mStatsMapA.reset(mFakeUidStatsMap.getMap());
+ mTc.mStatsMapB.reset(mFakeTagStatsMap.getMap());
mTc.mConfigurationMap.reset(mFakeConfigurationMap.getMap());
mTc.mUidOwnerMap.reset(mFakeUidOwnerMap.getMap());
}