x86: finish user fault error path with fatal signal
[deliverable/linux.git] / include / linux / memcontrol.h
CommitLineData
8cdea7c0
BS
1/* memcontrol.h - Memory Controller
2 *
3 * Copyright IBM Corporation, 2007
4 * Author Balbir Singh <balbir@linux.vnet.ibm.com>
5 *
78fb7466
PE
6 * Copyright 2007 OpenVZ SWsoft Inc
7 * Author: Pavel Emelianov <xemul@openvz.org>
8 *
8cdea7c0
BS
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 */
19
20#ifndef _LINUX_MEMCONTROL_H
21#define _LINUX_MEMCONTROL_H
f8d66542 22#include <linux/cgroup.h>
456f998e 23#include <linux/vm_event_item.h>
7ae1e1d0 24#include <linux/hardirq.h>
a8964b9b 25#include <linux/jump_label.h>
456f998e 26
78fb7466
PE
27struct mem_cgroup;
28struct page_cgroup;
8697d331
BS
29struct page;
30struct mm_struct;
2633d7a0 31struct kmem_cache;
78fb7466 32
2a7106f2
GT
33/* Stats that can be updated by kernel. */
34enum mem_cgroup_page_stat_item {
35 MEMCG_NR_FILE_MAPPED, /* # of pages charged as file rss */
36};
37
5660048c
JW
38struct mem_cgroup_reclaim_cookie {
39 struct zone *zone;
40 int priority;
41 unsigned int generation;
42};
43
de57780d
MH
44enum mem_cgroup_filter_t {
45 VISIT, /* visit current node */
46 SKIP, /* skip the current node and continue traversal */
47 SKIP_TREE, /* skip the whole subtree and continue traversal */
48};
49
50/*
51 * mem_cgroup_filter_t predicate might instruct mem_cgroup_iter_cond how to
52 * iterate through the hierarchy tree. Each tree element is checked by the
53 * predicate before it is returned by the iterator. If a filter returns
54 * SKIP or SKIP_TREE then the iterator code continues traversal (with the
55 * next node down the hierarchy or the next node that doesn't belong under the
56 * memcg's subtree).
57 */
58typedef enum mem_cgroup_filter_t
59(*mem_cgroup_iter_filter)(struct mem_cgroup *memcg, struct mem_cgroup *root);
60
c255a458 61#ifdef CONFIG_MEMCG
2c26fdd7
KH
62/*
63 * All "charge" functions with gfp_mask should use GFP_KERNEL or
64 * (gfp_mask & GFP_RECLAIM_MASK). In current implementatin, memcg doesn't
65 * alloc memory but reclaims memory from all available zones. So, "where I want
66 * memory from" bits of gfp_mask has no meaning. So any bits of that field is
67 * available but adding a rule is better. charge functions' gfp_mask should
68 * be set to GFP_KERNEL or gfp_mask & GFP_RECLAIM_MASK for avoiding ambiguous
69 * codes.
70 * (Of course, if memcg does memory allocation in future, GFP_KERNEL is sane.)
71 */
78fb7466 72
7a81b88c 73extern int mem_cgroup_newpage_charge(struct page *page, struct mm_struct *mm,
e1a1cd59 74 gfp_t gfp_mask);
7a81b88c 75/* for swap handling */
8c7c6e34 76extern int mem_cgroup_try_charge_swapin(struct mm_struct *mm,
72835c86 77 struct page *page, gfp_t mask, struct mem_cgroup **memcgp);
7a81b88c 78extern void mem_cgroup_commit_charge_swapin(struct page *page,
72835c86
JW
79 struct mem_cgroup *memcg);
80extern void mem_cgroup_cancel_charge_swapin(struct mem_cgroup *memcg);
7a81b88c 81
8289546e
HD
82extern int mem_cgroup_cache_charge(struct page *page, struct mm_struct *mm,
83 gfp_t gfp_mask);
925b7673
JW
84
85struct lruvec *mem_cgroup_zone_lruvec(struct zone *, struct mem_cgroup *);
fa9add64 86struct lruvec *mem_cgroup_page_lruvec(struct page *, struct zone *);
569b846d
KH
87
88/* For coalescing uncharge for reducing memcg' overhead*/
89extern void mem_cgroup_uncharge_start(void);
90extern void mem_cgroup_uncharge_end(void);
91
3c541e14 92extern void mem_cgroup_uncharge_page(struct page *page);
69029cd5 93extern void mem_cgroup_uncharge_cache_page(struct page *page);
c9b0ed51 94
c3ac9a8a
JW
95bool __mem_cgroup_same_or_subtree(const struct mem_cgroup *root_memcg,
96 struct mem_cgroup *memcg);
ffbdccf5
DR
97bool task_in_mem_cgroup(struct task_struct *task,
98 const struct mem_cgroup *memcg);
3062fc67 99
e42d9d5d 100extern struct mem_cgroup *try_get_mem_cgroup_from_page(struct page *page);
cf475ad2 101extern struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p);
a433658c 102extern struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm);
cf475ad2 103
e1aab161 104extern struct mem_cgroup *parent_mem_cgroup(struct mem_cgroup *memcg);
182446d0 105extern struct mem_cgroup *mem_cgroup_from_css(struct cgroup_subsys_state *css);
e1aab161 106
2e4d4091 107static inline
587af308 108bool mm_match_cgroup(const struct mm_struct *mm, const struct mem_cgroup *memcg)
2e4d4091 109{
587af308
JW
110 struct mem_cgroup *task_memcg;
111 bool match;
c3ac9a8a 112
2e4d4091 113 rcu_read_lock();
587af308
JW
114 task_memcg = mem_cgroup_from_task(rcu_dereference(mm->owner));
115 match = __mem_cgroup_same_or_subtree(memcg, task_memcg);
2e4d4091 116 rcu_read_unlock();
c3ac9a8a 117 return match;
2e4d4091 118}
8a9f3ccd 119
c0ff4b85 120extern struct cgroup_subsys_state *mem_cgroup_css(struct mem_cgroup *memcg);
d324236b 121
0030f535
JW
122extern void
123mem_cgroup_prepare_migration(struct page *page, struct page *newpage,
124 struct mem_cgroup **memcgp);
c0ff4b85 125extern void mem_cgroup_end_migration(struct mem_cgroup *memcg,
50de1dd9 126 struct page *oldpage, struct page *newpage, bool migration_ok);
ae41be37 127
de57780d
MH
128struct mem_cgroup *mem_cgroup_iter_cond(struct mem_cgroup *root,
129 struct mem_cgroup *prev,
130 struct mem_cgroup_reclaim_cookie *reclaim,
131 mem_cgroup_iter_filter cond);
132
133static inline struct mem_cgroup *mem_cgroup_iter(struct mem_cgroup *root,
134 struct mem_cgroup *prev,
135 struct mem_cgroup_reclaim_cookie *reclaim)
136{
137 return mem_cgroup_iter_cond(root, prev, reclaim, NULL);
138}
139
5660048c
JW
140void mem_cgroup_iter_break(struct mem_cgroup *, struct mem_cgroup *);
141
58ae83db
KH
142/*
143 * For memory reclaim.
144 */
c56d5c7d 145int mem_cgroup_inactive_anon_is_low(struct lruvec *lruvec);
889976db 146int mem_cgroup_select_victim_node(struct mem_cgroup *memcg);
4d7dcca2 147unsigned long mem_cgroup_get_lru_size(struct lruvec *lruvec, enum lru_list);
fa9add64 148void mem_cgroup_update_lru_size(struct lruvec *, enum lru_list, int);
e222432b
BS
149extern void mem_cgroup_print_oom_info(struct mem_cgroup *memcg,
150 struct task_struct *p);
ab936cbc
KH
151extern void mem_cgroup_replace_page_cache(struct page *oldpage,
152 struct page *newpage);
58ae83db 153
c255a458 154#ifdef CONFIG_MEMCG_SWAP
c077719b
KH
155extern int do_swap_account;
156#endif
f8d66542
HT
157
158static inline bool mem_cgroup_disabled(void)
159{
160 if (mem_cgroup_subsys.disabled)
161 return true;
162 return false;
163}
164
89c06bd5
KH
165void __mem_cgroup_begin_update_page_stat(struct page *page, bool *locked,
166 unsigned long *flags);
167
4331f7d3
KH
168extern atomic_t memcg_moving;
169
89c06bd5
KH
170static inline void mem_cgroup_begin_update_page_stat(struct page *page,
171 bool *locked, unsigned long *flags)
172{
173 if (mem_cgroup_disabled())
174 return;
175 rcu_read_lock();
176 *locked = false;
4331f7d3
KH
177 if (atomic_read(&memcg_moving))
178 __mem_cgroup_begin_update_page_stat(page, locked, flags);
89c06bd5
KH
179}
180
181void __mem_cgroup_end_update_page_stat(struct page *page,
182 unsigned long *flags);
183static inline void mem_cgroup_end_update_page_stat(struct page *page,
184 bool *locked, unsigned long *flags)
185{
186 if (mem_cgroup_disabled())
187 return;
188 if (*locked)
189 __mem_cgroup_end_update_page_stat(page, flags);
190 rcu_read_unlock();
191}
192
2a7106f2
GT
193void mem_cgroup_update_page_stat(struct page *page,
194 enum mem_cgroup_page_stat_item idx,
195 int val);
196
197static inline void mem_cgroup_inc_page_stat(struct page *page,
198 enum mem_cgroup_page_stat_item idx)
199{
200 mem_cgroup_update_page_stat(page, idx, 1);
201}
202
203static inline void mem_cgroup_dec_page_stat(struct page *page,
204 enum mem_cgroup_page_stat_item idx)
205{
206 mem_cgroup_update_page_stat(page, idx, -1);
207}
208
de57780d
MH
209enum mem_cgroup_filter_t
210mem_cgroup_soft_reclaim_eligible(struct mem_cgroup *memcg,
a5b7c87f 211 struct mem_cgroup *root);
a63d83f4 212
68ae564b
DR
213void __mem_cgroup_count_vm_event(struct mm_struct *mm, enum vm_event_item idx);
214static inline void mem_cgroup_count_vm_event(struct mm_struct *mm,
215 enum vm_event_item idx)
216{
217 if (mem_cgroup_disabled())
218 return;
219 __mem_cgroup_count_vm_event(mm, idx);
220}
ca3e0214 221#ifdef CONFIG_TRANSPARENT_HUGEPAGE
e94c8a9c 222void mem_cgroup_split_huge_fixup(struct page *head);
ca3e0214
KH
223#endif
224
f212ad7c
DN
225#ifdef CONFIG_DEBUG_VM
226bool mem_cgroup_bad_page_check(struct page *page);
227void mem_cgroup_print_bad_page(struct page *page);
228#endif
c255a458 229#else /* CONFIG_MEMCG */
7a81b88c
KH
230struct mem_cgroup;
231
232static inline int mem_cgroup_newpage_charge(struct page *page,
8289546e 233 struct mm_struct *mm, gfp_t gfp_mask)
8a9f3ccd
BS
234{
235 return 0;
236}
237
8289546e
HD
238static inline int mem_cgroup_cache_charge(struct page *page,
239 struct mm_struct *mm, gfp_t gfp_mask)
8a9f3ccd 240{
8289546e 241 return 0;
8a9f3ccd
BS
242}
243
8c7c6e34 244static inline int mem_cgroup_try_charge_swapin(struct mm_struct *mm,
72835c86 245 struct page *page, gfp_t gfp_mask, struct mem_cgroup **memcgp)
7a81b88c
KH
246{
247 return 0;
248}
249
250static inline void mem_cgroup_commit_charge_swapin(struct page *page,
72835c86 251 struct mem_cgroup *memcg)
7a81b88c
KH
252{
253}
254
72835c86 255static inline void mem_cgroup_cancel_charge_swapin(struct mem_cgroup *memcg)
7a81b88c
KH
256{
257}
258
569b846d
KH
259static inline void mem_cgroup_uncharge_start(void)
260{
261}
262
263static inline void mem_cgroup_uncharge_end(void)
264{
265}
266
8a9f3ccd
BS
267static inline void mem_cgroup_uncharge_page(struct page *page)
268{
269}
270
69029cd5
KH
271static inline void mem_cgroup_uncharge_cache_page(struct page *page)
272{
273}
274
925b7673
JW
275static inline struct lruvec *mem_cgroup_zone_lruvec(struct zone *zone,
276 struct mem_cgroup *memcg)
08e552c6 277{
925b7673 278 return &zone->lruvec;
08e552c6
KH
279}
280
fa9add64
HD
281static inline struct lruvec *mem_cgroup_page_lruvec(struct page *page,
282 struct zone *zone)
66e1707b 283{
925b7673 284 return &zone->lruvec;
66e1707b
BS
285}
286
e42d9d5d
WF
287static inline struct mem_cgroup *try_get_mem_cgroup_from_page(struct page *page)
288{
289 return NULL;
290}
291
a433658c
KM
292static inline struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm)
293{
294 return NULL;
295}
296
587af308 297static inline bool mm_match_cgroup(struct mm_struct *mm,
c0ff4b85 298 struct mem_cgroup *memcg)
bed7161a 299{
587af308 300 return true;
bed7161a
BS
301}
302
ffbdccf5
DR
303static inline bool task_in_mem_cgroup(struct task_struct *task,
304 const struct mem_cgroup *memcg)
4c4a2214 305{
ffbdccf5 306 return true;
4c4a2214
DR
307}
308
c0ff4b85
R
309static inline struct cgroup_subsys_state
310 *mem_cgroup_css(struct mem_cgroup *memcg)
d324236b
WF
311{
312 return NULL;
313}
314
0030f535 315static inline void
ac39cf8c 316mem_cgroup_prepare_migration(struct page *page, struct page *newpage,
0030f535 317 struct mem_cgroup **memcgp)
ae41be37 318{
ae41be37
KH
319}
320
c0ff4b85 321static inline void mem_cgroup_end_migration(struct mem_cgroup *memcg,
50de1dd9 322 struct page *oldpage, struct page *newpage, bool migration_ok)
ae41be37
KH
323{
324}
de57780d
MH
325static inline struct mem_cgroup *
326mem_cgroup_iter_cond(struct mem_cgroup *root,
327 struct mem_cgroup *prev,
328 struct mem_cgroup_reclaim_cookie *reclaim,
329 mem_cgroup_iter_filter cond)
330{
331 /* first call must return non-NULL, second return NULL */
332 return (struct mem_cgroup *)(unsigned long)!prev;
333}
ae41be37 334
5660048c
JW
335static inline struct mem_cgroup *
336mem_cgroup_iter(struct mem_cgroup *root,
337 struct mem_cgroup *prev,
338 struct mem_cgroup_reclaim_cookie *reclaim)
339{
340 return NULL;
341}
342
343static inline void mem_cgroup_iter_break(struct mem_cgroup *root,
344 struct mem_cgroup *prev)
345{
346}
347
f8d66542
HT
348static inline bool mem_cgroup_disabled(void)
349{
350 return true;
351}
a636b327 352
14797e23 353static inline int
c56d5c7d 354mem_cgroup_inactive_anon_is_low(struct lruvec *lruvec)
14797e23
KM
355{
356 return 1;
357}
358
a3d8e054 359static inline unsigned long
4d7dcca2 360mem_cgroup_get_lru_size(struct lruvec *lruvec, enum lru_list lru)
a3d8e054
KM
361{
362 return 0;
363}
364
fa9add64
HD
365static inline void
366mem_cgroup_update_lru_size(struct lruvec *lruvec, enum lru_list lru,
367 int increment)
3e2f41f1 368{
3e2f41f1
KM
369}
370
e222432b
BS
371static inline void
372mem_cgroup_print_oom_info(struct mem_cgroup *memcg, struct task_struct *p)
373{
374}
375
89c06bd5
KH
376static inline void mem_cgroup_begin_update_page_stat(struct page *page,
377 bool *locked, unsigned long *flags)
378{
379}
380
381static inline void mem_cgroup_end_update_page_stat(struct page *page,
382 bool *locked, unsigned long *flags)
383{
384}
385
2a7106f2
GT
386static inline void mem_cgroup_inc_page_stat(struct page *page,
387 enum mem_cgroup_page_stat_item idx)
388{
389}
390
391static inline void mem_cgroup_dec_page_stat(struct page *page,
392 enum mem_cgroup_page_stat_item idx)
d69b042f
BS
393{
394}
395
4e416953 396static inline
de57780d
MH
397enum mem_cgroup_filter_t
398mem_cgroup_soft_reclaim_eligible(struct mem_cgroup *memcg,
a5b7c87f 399 struct mem_cgroup *root)
4e416953 400{
de57780d 401 return VISIT;
4e416953
BS
402}
403
e94c8a9c 404static inline void mem_cgroup_split_huge_fixup(struct page *head)
ca3e0214
KH
405{
406}
407
456f998e
YH
408static inline
409void mem_cgroup_count_vm_event(struct mm_struct *mm, enum vm_event_item idx)
410{
411}
ab936cbc
KH
412static inline void mem_cgroup_replace_page_cache(struct page *oldpage,
413 struct page *newpage)
414{
415}
c255a458 416#endif /* CONFIG_MEMCG */
78fb7466 417
c255a458 418#if !defined(CONFIG_MEMCG) || !defined(CONFIG_DEBUG_VM)
f212ad7c
DN
419static inline bool
420mem_cgroup_bad_page_check(struct page *page)
421{
422 return false;
423}
424
425static inline void
426mem_cgroup_print_bad_page(struct page *page)
427{
428}
429#endif
430
e1aab161
GC
431enum {
432 UNDER_LIMIT,
433 SOFT_LIMIT,
434 OVER_LIMIT,
435};
436
437struct sock;
cd59085a 438#if defined(CONFIG_INET) && defined(CONFIG_MEMCG_KMEM)
e1aab161
GC
439void sock_update_memcg(struct sock *sk);
440void sock_release_memcg(struct sock *sk);
441#else
442static inline void sock_update_memcg(struct sock *sk)
443{
444}
445static inline void sock_release_memcg(struct sock *sk)
446{
447}
cd59085a 448#endif /* CONFIG_INET && CONFIG_MEMCG_KMEM */
7ae1e1d0
GC
449
450#ifdef CONFIG_MEMCG_KMEM
a8964b9b 451extern struct static_key memcg_kmem_enabled_key;
749c5415
GC
452
453extern int memcg_limited_groups_array_size;
ebe945c2
GC
454
455/*
456 * Helper macro to loop through all memcg-specific caches. Callers must still
457 * check if the cache is valid (it is either valid or NULL).
458 * the slab_mutex must be held when looping through those caches
459 */
749c5415 460#define for_each_memcg_cache_index(_idx) \
91c777d8 461 for ((_idx) = 0; (_idx) < memcg_limited_groups_array_size; (_idx)++)
749c5415 462
7ae1e1d0
GC
463static inline bool memcg_kmem_enabled(void)
464{
a8964b9b 465 return static_key_false(&memcg_kmem_enabled_key);
7ae1e1d0
GC
466}
467
468/*
469 * In general, we'll do everything in our power to not incur in any overhead
470 * for non-memcg users for the kmem functions. Not even a function call, if we
471 * can avoid it.
472 *
473 * Therefore, we'll inline all those functions so that in the best case, we'll
474 * see that kmemcg is off for everybody and proceed quickly. If it is on,
475 * we'll still do most of the flag checking inline. We check a lot of
476 * conditions, but because they are pretty simple, they are expected to be
477 * fast.
478 */
479bool __memcg_kmem_newpage_charge(gfp_t gfp, struct mem_cgroup **memcg,
480 int order);
481void __memcg_kmem_commit_charge(struct page *page,
482 struct mem_cgroup *memcg, int order);
483void __memcg_kmem_uncharge_pages(struct page *page, int order);
484
2633d7a0 485int memcg_cache_id(struct mem_cgroup *memcg);
943a451a
GC
486int memcg_register_cache(struct mem_cgroup *memcg, struct kmem_cache *s,
487 struct kmem_cache *root_cache);
2633d7a0
GC
488void memcg_release_cache(struct kmem_cache *cachep);
489void memcg_cache_list_add(struct mem_cgroup *memcg, struct kmem_cache *cachep);
490
55007d84
GC
491int memcg_update_cache_size(struct kmem_cache *s, int num_groups);
492void memcg_update_array_size(int num_groups);
d7f25f8a
GC
493
494struct kmem_cache *
495__memcg_kmem_get_cache(struct kmem_cache *cachep, gfp_t gfp);
496
1f458cbf 497void mem_cgroup_destroy_cache(struct kmem_cache *cachep);
7cf27982 498void kmem_cache_destroy_memcg_children(struct kmem_cache *s);
1f458cbf 499
7ae1e1d0
GC
500/**
501 * memcg_kmem_newpage_charge: verify if a new kmem allocation is allowed.
502 * @gfp: the gfp allocation flags.
503 * @memcg: a pointer to the memcg this was charged against.
504 * @order: allocation order.
505 *
506 * returns true if the memcg where the current task belongs can hold this
507 * allocation.
508 *
509 * We return true automatically if this allocation is not to be accounted to
510 * any memcg.
511 */
512static inline bool
513memcg_kmem_newpage_charge(gfp_t gfp, struct mem_cgroup **memcg, int order)
514{
515 if (!memcg_kmem_enabled())
516 return true;
517
518 /*
519 * __GFP_NOFAIL allocations will move on even if charging is not
520 * possible. Therefore we don't even try, and have this allocation
521 * unaccounted. We could in theory charge it with
522 * res_counter_charge_nofail, but we hope those allocations are rare,
523 * and won't be worth the trouble.
524 */
525 if (!(gfp & __GFP_KMEMCG) || (gfp & __GFP_NOFAIL))
526 return true;
527 if (in_interrupt() || (!current->mm) || (current->flags & PF_KTHREAD))
528 return true;
529
530 /* If the test is dying, just let it go. */
531 if (unlikely(fatal_signal_pending(current)))
532 return true;
533
534 return __memcg_kmem_newpage_charge(gfp, memcg, order);
535}
536
537/**
538 * memcg_kmem_uncharge_pages: uncharge pages from memcg
539 * @page: pointer to struct page being freed
540 * @order: allocation order.
541 *
542 * there is no need to specify memcg here, since it is embedded in page_cgroup
543 */
544static inline void
545memcg_kmem_uncharge_pages(struct page *page, int order)
546{
547 if (memcg_kmem_enabled())
548 __memcg_kmem_uncharge_pages(page, order);
549}
550
551/**
552 * memcg_kmem_commit_charge: embeds correct memcg in a page
553 * @page: pointer to struct page recently allocated
554 * @memcg: the memcg structure we charged against
555 * @order: allocation order.
556 *
557 * Needs to be called after memcg_kmem_newpage_charge, regardless of success or
558 * failure of the allocation. if @page is NULL, this function will revert the
559 * charges. Otherwise, it will commit the memcg given by @memcg to the
560 * corresponding page_cgroup.
561 */
562static inline void
563memcg_kmem_commit_charge(struct page *page, struct mem_cgroup *memcg, int order)
564{
565 if (memcg_kmem_enabled() && memcg)
566 __memcg_kmem_commit_charge(page, memcg, order);
567}
568
d7f25f8a
GC
569/**
570 * memcg_kmem_get_cache: selects the correct per-memcg cache for allocation
571 * @cachep: the original global kmem cache
572 * @gfp: allocation flags.
573 *
574 * This function assumes that the task allocating, which determines the memcg
575 * in the page allocator, belongs to the same cgroup throughout the whole
576 * process. Misacounting can happen if the task calls memcg_kmem_get_cache()
577 * while belonging to a cgroup, and later on changes. This is considered
578 * acceptable, and should only happen upon task migration.
579 *
580 * Before the cache is created by the memcg core, there is also a possible
581 * imbalance: the task belongs to a memcg, but the cache being allocated from
582 * is the global cache, since the child cache is not yet guaranteed to be
583 * ready. This case is also fine, since in this case the GFP_KMEMCG will not be
584 * passed and the page allocator will not attempt any cgroup accounting.
585 */
586static __always_inline struct kmem_cache *
587memcg_kmem_get_cache(struct kmem_cache *cachep, gfp_t gfp)
588{
589 if (!memcg_kmem_enabled())
590 return cachep;
591 if (gfp & __GFP_NOFAIL)
592 return cachep;
593 if (in_interrupt() || (!current->mm) || (current->flags & PF_KTHREAD))
594 return cachep;
595 if (unlikely(fatal_signal_pending(current)))
596 return cachep;
597
598 return __memcg_kmem_get_cache(cachep, gfp);
599}
7ae1e1d0 600#else
749c5415
GC
601#define for_each_memcg_cache_index(_idx) \
602 for (; NULL; )
603
b9ce5ef4
GC
604static inline bool memcg_kmem_enabled(void)
605{
606 return false;
607}
608
7ae1e1d0
GC
609static inline bool
610memcg_kmem_newpage_charge(gfp_t gfp, struct mem_cgroup **memcg, int order)
611{
612 return true;
613}
614
615static inline void memcg_kmem_uncharge_pages(struct page *page, int order)
616{
617}
618
619static inline void
620memcg_kmem_commit_charge(struct page *page, struct mem_cgroup *memcg, int order)
621{
622}
2633d7a0
GC
623
624static inline int memcg_cache_id(struct mem_cgroup *memcg)
625{
626 return -1;
627}
628
943a451a
GC
629static inline int
630memcg_register_cache(struct mem_cgroup *memcg, struct kmem_cache *s,
631 struct kmem_cache *root_cache)
2633d7a0
GC
632{
633 return 0;
634}
635
636static inline void memcg_release_cache(struct kmem_cache *cachep)
637{
638}
639
640static inline void memcg_cache_list_add(struct mem_cgroup *memcg,
641 struct kmem_cache *s)
642{
643}
d7f25f8a
GC
644
645static inline struct kmem_cache *
646memcg_kmem_get_cache(struct kmem_cache *cachep, gfp_t gfp)
647{
648 return cachep;
649}
7cf27982
GC
650
651static inline void kmem_cache_destroy_memcg_children(struct kmem_cache *s)
652{
653}
7ae1e1d0 654#endif /* CONFIG_MEMCG_KMEM */
8cdea7c0
BS
655#endif /* _LINUX_MEMCONTROL_H */
656
This page took 0.659789 seconds and 5 git commands to generate.