In order to understand kernel route LC-Trie,
summary the basic functions here.
debug kernel with jprobe
how to use git bisect
usage:
In version management, we often meet this case:
1 | When a line/file is deleted for git repo? |
In this case, we need git bisect
.
git bisect start
git bisect good commit_id1
git bisect bad commit_id2
git bisect bad/good
repeat to step 4, until finish.
more auto method for step4 is run with git bisect run command
.
by the way git blame
is used to check the added line/file.
Where is IPv6 route cache
Q: Does kernel IPv6 route support route cache ?
yes. but it is very different with IPv4.
It should be ‘clone’ strictly speaking.
For simple let us only focus on ip6_pol_route
, and variable struct rt6_info *nrt
.
When a route is matched, a
nrt
will be created byrt6_alloc_cow
orrt6_alloc_clone
.the
nrt
will be set with flagRTF_CACHE;
ip6_ins_rt
insert the newnrt
to fib tree.kernel starts fib6 gc for
nrt
.
so there will be a new cache
route, and after a period it will disappear.
callback notify when add a IPv4 add
##summary
IP4 route register a call back notify in IPv4 address.
When a address is added, fib_inetaddr_event
will be called.
and then 4 route entry maybe added in fib_add_ifaddr
how kernel add a IPv4 address
##summary
There is a struct in_device __rcu *ip_ptr
under every net_device.
which stores all the IPv4 related information for this device.
Each IPv4 address is stored a struct in_ifaddr
,
all the IPv4 address of a net device are stored into a list(netdev->ip_ptr->ifa_list).
unregister a net device
unregister_netdev
is used to delete a net device. In fact, it equals:
1 | rtnl_lock(); |
a temporary list stores a single net device, which is to be deleted.net_todo_list
stores all the net devices are being deleted.
The core function is rollback_registered_many
, which efficiently deletes many devices in a list.
But here, in this case, one a single netdevice in the list.
draft: how to select a realtime task when schedule
##summary
There is a struct rt_rq
in struct rq
. struct rt_rq
is used to store all
the realtime task in current struct rq
. which has a struct rt_prio_array active
.
draft: how to pick next task
summary
There are four sched_class
,stop_sched_class --> rt_sched_class --> fair_sched_class --> idle_sched_class
They are linked one by one staticly by struct sched_class->next
by their defination.
Each sched_class
has method pick_next_task
, which is used to select
a perfect process to run from each sched_class
‘s runqueue.
When we need schedule, the four pick_next_task
will be called one by one.
As a optimization, most time there is no rt task in running state,
in this case we can directly call fair_sched_class
.
draft: struct rq
##summary:
- struct rq is basic data structure.
- there is a realtime process(es) and normal process(es) are stored in
different sub-runqueue*_rq
of rq?1
2426 struct cfs_rq cfs;
427 struct rt_rq rt;