History

memcg: localize memcg_kmem_enabled() check

Move the memcg_kmem_enabled() checks into memcg kmem charge/uncharge functions, so, the users don't have to explicitly check that condition. This is purely code cleanup patch without any functional change. Only the order of checks in memcg_charge_slab() can potentially be changed but the functionally it will be same. This should not matter as memcg_charge_slab() is not in the hot path.

Shakeel Butt committed 7 years ago

Commit 60cd4bc1 parent 9234bae5 files · +44 −20Browse files

Showing the changes to include/linux (1 of 5 files). Show all

Unified · Split

include/linux/memcontrol.h+33−4
@@ -1273,12 +1273,12 @@ static inline bool mem_cgroup_under_socket_pressure(struct mem_cgroup *memcg) · 1272 unmodified lines
12731273
12741274 struct kmem_cache *memcg_kmem_get_cache(struct kmem_cache *cachep);
12751275 void memcg_kmem_put_cache(struct kmem_cache *cachep);
1276−int memcg_kmem_charge_memcg(struct page *page, gfp_t gfp, int order,
1277− struct mem_cgroup *memcg);
12781276
12791277 #ifdef CONFIG_MEMCG_KMEM
1280−int memcg_kmem_charge(struct page *page, gfp_t gfp, int order);
1281−void memcg_kmem_uncharge(struct page *page, int order);
1278+int __memcg_kmem_charge(struct page *page, gfp_t gfp, int order);
1279+void __memcg_kmem_uncharge(struct page *page, int order);
1280+int __memcg_kmem_charge_memcg(struct page *page, gfp_t gfp, int order,
1281+ struct mem_cgroup *memcg);
12821282
12831283 extern struct static_key_false memcg_kmem_enabled_key;
12841284 extern struct workqueue_struct *memcg_kmem_cache_wq;
@@ -1300,6 +1300,26 @@ static inline bool memcg_kmem_enabled(void) · 15 unmodified lines
13001300 return static_branch_unlikely(&memcg_kmem_enabled_key);
13011301 }
13021302
1303+static inline int memcg_kmem_charge(struct page *page, gfp_t gfp, int order)
1304+{
1305+ if (memcg_kmem_enabled())
1306+ return __memcg_kmem_charge(page, gfp, order);
1307+ return 0;
1308+}
1309+
1310+static inline void memcg_kmem_uncharge(struct page *page, int order)
1311+{
1312+ if (memcg_kmem_enabled())
1313+ __memcg_kmem_uncharge(page, order);
1314+}
1315+
1316+static inline int memcg_kmem_charge_memcg(struct page *page, gfp_t gfp,
1317+ int order, struct mem_cgroup *memcg)
1318+{
1319+ if (memcg_kmem_enabled())
1320+ return __memcg_kmem_charge_memcg(page, gfp, order, memcg);
1321+ return 0;
1322+}
13031323 /*
13041324 * helper for accessing a memcg's index. It will be used as an index in the
13051325 * child cache array in kmem_cache, and also to derive its name. This function
@@ -1325,6 +1345,15 @@ static inline void memcg_kmem_uncharge(struct page *page, int order) · 19 unmodified lines
13251345 {
13261346 }
13271347
1348+static inline int __memcg_kmem_charge(struct page *page, gfp_t gfp, int order)
1349+{
1350+ return 0;
1351+}
1352+
1353+static inline void __memcg_kmem_uncharge(struct page *page, int order)
1354+{
1355+}
1356+
13281357 #define for_each_memcg_cache_index(_idx) \
13291358 for (; NULL; )
13301359

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t