@@ -1873,6 +1873,30 @@ static inline enum node_stat_item cache_vmstat_idx(struct kmem_cache *s)
1873
1873
1874
1874
#ifdef CONFIG_SLAB_OBJ_EXT
1875
1875
1876
+ #ifdef CONFIG_MEM_ALLOC_PROFILING_DEBUG
1877
+
1878
+ static inline void mark_objexts_empty (struct slabobj_ext * obj_exts )
1879
+ {
1880
+ struct slabobj_ext * slab_exts ;
1881
+ struct slab * obj_exts_slab ;
1882
+
1883
+ obj_exts_slab = virt_to_slab (obj_exts );
1884
+ slab_exts = slab_obj_exts (obj_exts_slab );
1885
+ if (slab_exts ) {
1886
+ unsigned int offs = obj_to_index (obj_exts_slab -> slab_cache ,
1887
+ obj_exts_slab , obj_exts );
1888
+ /* codetag should be NULL */
1889
+ WARN_ON (slab_exts [offs ].ref .ct );
1890
+ set_codetag_empty (& slab_exts [offs ].ref );
1891
+ }
1892
+ }
1893
+
1894
+ #else /* CONFIG_MEM_ALLOC_PROFILING_DEBUG */
1895
+
1896
+ static inline void mark_objexts_empty (struct slabobj_ext * obj_exts ) {}
1897
+
1898
+ #endif /* CONFIG_MEM_ALLOC_PROFILING_DEBUG */
1899
+
1876
1900
/*
1877
1901
* The allocated objcg pointers array is not accounted directly.
1878
1902
* Moreover, it should not come from DMA buffer and is not readily
@@ -1913,6 +1937,7 @@ static int alloc_slab_obj_exts(struct slab *slab, struct kmem_cache *s,
1913
1937
* assign slabobj_exts in parallel. In this case the existing
1914
1938
* objcg vector should be reused.
1915
1939
*/
1940
+ mark_objexts_empty (vec );
1916
1941
kfree (vec );
1917
1942
return 0 ;
1918
1943
}
@@ -1929,6 +1954,14 @@ static inline void free_slab_obj_exts(struct slab *slab)
1929
1954
if (!obj_exts )
1930
1955
return ;
1931
1956
1957
+ /*
1958
+ * obj_exts was created with __GFP_NO_OBJ_EXT flag, therefore its
1959
+ * corresponding extension will be NULL. alloc_tag_sub() will throw a
1960
+ * warning if slab has extensions but the extension of an object is
1961
+ * NULL, therefore replace NULL with CODETAG_EMPTY to indicate that
1962
+ * the extension for obj_exts is expected to be NULL.
1963
+ */
1964
+ mark_objexts_empty (obj_exts );
1932
1965
kfree (obj_exts );
1933
1966
slab -> obj_exts = 0 ;
1934
1967
}
0 commit comments