@@ -1384,10 +1384,8 @@ alloc_and_copy_ftrace_hash(int size_bits, struct ftrace_hash *hash)
1384
1384
return NULL ;
1385
1385
}
1386
1386
1387
- static void
1388
- ftrace_hash_rec_disable_modify (struct ftrace_ops * ops , int filter_hash );
1389
- static void
1390
- ftrace_hash_rec_enable_modify (struct ftrace_ops * ops , int filter_hash );
1387
+ static void ftrace_hash_rec_disable_modify (struct ftrace_ops * ops );
1388
+ static void ftrace_hash_rec_enable_modify (struct ftrace_ops * ops );
1391
1389
1392
1390
static int ftrace_hash_ipmodify_update (struct ftrace_ops * ops ,
1393
1391
struct ftrace_hash * new_hash );
@@ -1475,11 +1473,11 @@ ftrace_hash_move(struct ftrace_ops *ops, int enable,
1475
1473
* Remove the current set, update the hash and add
1476
1474
* them back.
1477
1475
*/
1478
- ftrace_hash_rec_disable_modify (ops , enable );
1476
+ ftrace_hash_rec_disable_modify (ops );
1479
1477
1480
1478
rcu_assign_pointer (* dst , new_hash );
1481
1479
1482
- ftrace_hash_rec_enable_modify (ops , enable );
1480
+ ftrace_hash_rec_enable_modify (ops );
1483
1481
1484
1482
return 0 ;
1485
1483
}
@@ -1702,12 +1700,21 @@ static bool skip_record(struct dyn_ftrace *rec)
1702
1700
!(rec -> flags & FTRACE_FL_ENABLED );
1703
1701
}
1704
1702
1703
+ /*
1704
+ * This is the main engine to the ftrace updates to the dyn_ftrace records.
1705
+ *
1706
+ * It will iterate through all the available ftrace functions
1707
+ * (the ones that ftrace can have callbacks to) and set the flags
1708
+ * in the associated dyn_ftrace records.
1709
+ *
1710
+ * @inc: If true, the functions associated to @ops are added to
1711
+ * the dyn_ftrace records, otherwise they are removed.
1712
+ */
1705
1713
static bool __ftrace_hash_rec_update (struct ftrace_ops * ops ,
1706
- int filter_hash ,
1707
1714
bool inc )
1708
1715
{
1709
1716
struct ftrace_hash * hash ;
1710
- struct ftrace_hash * other_hash ;
1717
+ struct ftrace_hash * notrace_hash ;
1711
1718
struct ftrace_page * pg ;
1712
1719
struct dyn_ftrace * rec ;
1713
1720
bool update = false;
@@ -1719,35 +1726,16 @@ static bool __ftrace_hash_rec_update(struct ftrace_ops *ops,
1719
1726
return false;
1720
1727
1721
1728
/*
1722
- * In the filter_hash case:
1723
1729
* If the count is zero, we update all records.
1724
1730
* Otherwise we just update the items in the hash.
1725
- *
1726
- * In the notrace_hash case:
1727
- * We enable the update in the hash.
1728
- * As disabling notrace means enabling the tracing,
1729
- * and enabling notrace means disabling, the inc variable
1730
- * gets inversed.
1731
1731
*/
1732
- if (filter_hash ) {
1733
- hash = ops -> func_hash -> filter_hash ;
1734
- other_hash = ops -> func_hash -> notrace_hash ;
1735
- if (ftrace_hash_empty (hash ))
1736
- all = true;
1737
- } else {
1738
- inc = !inc ;
1739
- hash = ops -> func_hash -> notrace_hash ;
1740
- other_hash = ops -> func_hash -> filter_hash ;
1741
- /*
1742
- * If the notrace hash has no items,
1743
- * then there's nothing to do.
1744
- */
1745
- if (ftrace_hash_empty (hash ))
1746
- return false;
1747
- }
1732
+ hash = ops -> func_hash -> filter_hash ;
1733
+ notrace_hash = ops -> func_hash -> notrace_hash ;
1734
+ if (ftrace_hash_empty (hash ))
1735
+ all = true;
1748
1736
1749
1737
do_for_each_ftrace_rec (pg , rec ) {
1750
- int in_other_hash = 0 ;
1738
+ int in_notrace_hash = 0 ;
1751
1739
int in_hash = 0 ;
1752
1740
int match = 0 ;
1753
1741
@@ -1759,26 +1747,17 @@ static bool __ftrace_hash_rec_update(struct ftrace_ops *ops,
1759
1747
* Only the filter_hash affects all records.
1760
1748
* Update if the record is not in the notrace hash.
1761
1749
*/
1762
- if (!other_hash || !ftrace_lookup_ip (other_hash , rec -> ip ))
1750
+ if (!notrace_hash || !ftrace_lookup_ip (notrace_hash , rec -> ip ))
1763
1751
match = 1 ;
1764
1752
} else {
1765
1753
in_hash = !!ftrace_lookup_ip (hash , rec -> ip );
1766
- in_other_hash = !!ftrace_lookup_ip (other_hash , rec -> ip );
1754
+ in_notrace_hash = !!ftrace_lookup_ip (notrace_hash , rec -> ip );
1767
1755
1768
1756
/*
1769
- * If filter_hash is set, we want to match all functions
1770
- * that are in the hash but not in the other hash.
1771
- *
1772
- * If filter_hash is not set, then we are decrementing.
1773
- * That means we match anything that is in the hash
1774
- * and also in the other_hash. That is, we need to turn
1775
- * off functions in the other hash because they are disabled
1776
- * by this hash.
1757
+ * We want to match all functions that are in the hash but
1758
+ * not in the other hash.
1777
1759
*/
1778
- if (filter_hash && in_hash && !in_other_hash )
1779
- match = 1 ;
1780
- else if (!filter_hash && in_hash &&
1781
- (in_other_hash || ftrace_hash_empty (other_hash )))
1760
+ if (in_hash && !in_notrace_hash )
1782
1761
match = 1 ;
1783
1762
}
1784
1763
if (!match )
@@ -1884,24 +1863,21 @@ static bool __ftrace_hash_rec_update(struct ftrace_ops *ops,
1884
1863
return update ;
1885
1864
}
1886
1865
1887
- static bool ftrace_hash_rec_disable (struct ftrace_ops * ops ,
1888
- int filter_hash )
1866
+ static bool ftrace_hash_rec_disable (struct ftrace_ops * ops )
1889
1867
{
1890
- return __ftrace_hash_rec_update (ops , filter_hash , 0 );
1868
+ return __ftrace_hash_rec_update (ops , 0 );
1891
1869
}
1892
1870
1893
- static bool ftrace_hash_rec_enable (struct ftrace_ops * ops ,
1894
- int filter_hash )
1871
+ static bool ftrace_hash_rec_enable (struct ftrace_ops * ops )
1895
1872
{
1896
- return __ftrace_hash_rec_update (ops , filter_hash , 1 );
1873
+ return __ftrace_hash_rec_update (ops , 1 );
1897
1874
}
1898
1875
1899
- static void ftrace_hash_rec_update_modify (struct ftrace_ops * ops ,
1900
- int filter_hash , int inc )
1876
+ static void ftrace_hash_rec_update_modify (struct ftrace_ops * ops , int inc )
1901
1877
{
1902
1878
struct ftrace_ops * op ;
1903
1879
1904
- __ftrace_hash_rec_update (ops , filter_hash , inc );
1880
+ __ftrace_hash_rec_update (ops , inc );
1905
1881
1906
1882
if (ops -> func_hash != & global_ops .local_hash )
1907
1883
return ;
@@ -1915,20 +1891,18 @@ static void ftrace_hash_rec_update_modify(struct ftrace_ops *ops,
1915
1891
if (op == ops )
1916
1892
continue ;
1917
1893
if (op -> func_hash == & global_ops .local_hash )
1918
- __ftrace_hash_rec_update (op , filter_hash , inc );
1894
+ __ftrace_hash_rec_update (op , inc );
1919
1895
} while_for_each_ftrace_op (op );
1920
1896
}
1921
1897
1922
- static void ftrace_hash_rec_disable_modify (struct ftrace_ops * ops ,
1923
- int filter_hash )
1898
+ static void ftrace_hash_rec_disable_modify (struct ftrace_ops * ops )
1924
1899
{
1925
- ftrace_hash_rec_update_modify (ops , filter_hash , 0 );
1900
+ ftrace_hash_rec_update_modify (ops , 0 );
1926
1901
}
1927
1902
1928
- static void ftrace_hash_rec_enable_modify (struct ftrace_ops * ops ,
1929
- int filter_hash )
1903
+ static void ftrace_hash_rec_enable_modify (struct ftrace_ops * ops )
1930
1904
{
1931
- ftrace_hash_rec_update_modify (ops , filter_hash , 1 );
1905
+ ftrace_hash_rec_update_modify (ops , 1 );
1932
1906
}
1933
1907
1934
1908
/*
@@ -3051,7 +3025,7 @@ int ftrace_startup(struct ftrace_ops *ops, int command)
3051
3025
return ret ;
3052
3026
}
3053
3027
3054
- if (ftrace_hash_rec_enable (ops , 1 ))
3028
+ if (ftrace_hash_rec_enable (ops ))
3055
3029
command |= FTRACE_UPDATE_CALLS ;
3056
3030
3057
3031
ftrace_startup_enable (command );
@@ -3093,7 +3067,7 @@ int ftrace_shutdown(struct ftrace_ops *ops, int command)
3093
3067
/* Disabling ipmodify never fails */
3094
3068
ftrace_hash_ipmodify_disable (ops );
3095
3069
3096
- if (ftrace_hash_rec_disable (ops , 1 ))
3070
+ if (ftrace_hash_rec_disable (ops ))
3097
3071
command |= FTRACE_UPDATE_CALLS ;
3098
3072
3099
3073
ops -> flags &= ~FTRACE_OPS_FL_ENABLED ;
0 commit comments