Skip to content

Commit f0e45fb

Browse files
hnaztorvalds
authored andcommitted
mm: memcontrol: drop unused try/commit/cancel charge API
There are no more users. RIP in peace. [[email protected]: fix an unused-function warning] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Johannes Weiner <[email protected]> Signed-off-by: Arnd Bergmann <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Reviewed-by: Joonsoo Kim <[email protected]> Cc: Alex Shi <[email protected]> Cc: Hugh Dickins <[email protected]> Cc: "Kirill A. Shutemov" <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Roman Gushchin <[email protected]> Cc: Shakeel Butt <[email protected]> Cc: Balbir Singh <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Linus Torvalds <[email protected]>
1 parent 9d82c69 commit f0e45fb

File tree

2 files changed

+17
-147
lines changed

2 files changed

+17
-147
lines changed

include/linux/memcontrol.h

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -355,14 +355,6 @@ static inline unsigned long mem_cgroup_protection(struct mem_cgroup *memcg,
355355
enum mem_cgroup_protection mem_cgroup_protected(struct mem_cgroup *root,
356356
struct mem_cgroup *memcg);
357357

358-
int mem_cgroup_try_charge(struct page *page, struct mm_struct *mm,
359-
gfp_t gfp_mask, struct mem_cgroup **memcgp);
360-
int mem_cgroup_try_charge_delay(struct page *page, struct mm_struct *mm,
361-
gfp_t gfp_mask, struct mem_cgroup **memcgp);
362-
void mem_cgroup_commit_charge(struct page *page, struct mem_cgroup *memcg,
363-
bool lrucare);
364-
void mem_cgroup_cancel_charge(struct page *page, struct mem_cgroup *memcg);
365-
366358
int mem_cgroup_charge(struct page *page, struct mm_struct *mm, gfp_t gfp_mask,
367359
bool lrucare);
368360

@@ -846,34 +838,6 @@ static inline enum mem_cgroup_protection mem_cgroup_protected(
846838
return MEMCG_PROT_NONE;
847839
}
848840

849-
static inline int mem_cgroup_try_charge(struct page *page, struct mm_struct *mm,
850-
gfp_t gfp_mask,
851-
struct mem_cgroup **memcgp)
852-
{
853-
*memcgp = NULL;
854-
return 0;
855-
}
856-
857-
static inline int mem_cgroup_try_charge_delay(struct page *page,
858-
struct mm_struct *mm,
859-
gfp_t gfp_mask,
860-
struct mem_cgroup **memcgp)
861-
{
862-
*memcgp = NULL;
863-
return 0;
864-
}
865-
866-
static inline void mem_cgroup_commit_charge(struct page *page,
867-
struct mem_cgroup *memcg,
868-
bool lrucare)
869-
{
870-
}
871-
872-
static inline void mem_cgroup_cancel_charge(struct page *page,
873-
struct mem_cgroup *memcg)
874-
{
875-
}
876-
877841
static inline int mem_cgroup_charge(struct page *page, struct mm_struct *mm,
878842
gfp_t gfp_mask, bool lrucare)
879843
{

mm/memcontrol.c

Lines changed: 17 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -2641,6 +2641,7 @@ static int try_charge(struct mem_cgroup *memcg, gfp_t gfp_mask,
26412641
return 0;
26422642
}
26432643

2644+
#if defined(CONFIG_MEMCG_KMEM) || defined(CONFIG_MMU)
26442645
static void cancel_charge(struct mem_cgroup *memcg, unsigned int nr_pages)
26452646
{
26462647
if (mem_cgroup_is_root(memcg))
@@ -2652,6 +2653,7 @@ static void cancel_charge(struct mem_cgroup *memcg, unsigned int nr_pages)
26522653

26532654
css_put_many(&memcg->css, nr_pages);
26542655
}
2656+
#endif
26552657

26562658
static void lock_page_lru(struct page *page, int *isolated)
26572659
{
@@ -6499,29 +6501,26 @@ enum mem_cgroup_protection mem_cgroup_protected(struct mem_cgroup *root,
64996501
}
65006502

65016503
/**
6502-
* mem_cgroup_try_charge - try charging a page
6504+
* mem_cgroup_charge - charge a newly allocated page to a cgroup
65036505
* @page: page to charge
65046506
* @mm: mm context of the victim
65056507
* @gfp_mask: reclaim mode
6506-
* @memcgp: charged memcg return
6508+
* @lrucare: page might be on the LRU already
65076509
*
65086510
* Try to charge @page to the memcg that @mm belongs to, reclaiming
65096511
* pages according to @gfp_mask if necessary.
65106512
*
6511-
* Returns 0 on success, with *@memcgp pointing to the charged memcg.
6512-
* Otherwise, an error code is returned.
6513-
*
6514-
* After page->mapping has been set up, the caller must finalize the
6515-
* charge with mem_cgroup_commit_charge(). Or abort the transaction
6516-
* with mem_cgroup_cancel_charge() in case page instantiation fails.
6513+
* Returns 0 on success. Otherwise, an error code is returned.
65176514
*/
6518-
int mem_cgroup_try_charge(struct page *page, struct mm_struct *mm,
6519-
gfp_t gfp_mask, struct mem_cgroup **memcgp)
6515+
int mem_cgroup_charge(struct page *page, struct mm_struct *mm, gfp_t gfp_mask,
6516+
bool lrucare)
65206517
{
65216518
unsigned int nr_pages = hpage_nr_pages(page);
65226519
struct mem_cgroup *memcg = NULL;
65236520
int ret = 0;
65246521

6522+
VM_BUG_ON_PAGE(PageLRU(page) && !lrucare, page);
6523+
65256524
if (mem_cgroup_disabled())
65266525
goto out;
65276526

@@ -6553,56 +6552,8 @@ int mem_cgroup_try_charge(struct page *page, struct mm_struct *mm,
65536552
memcg = get_mem_cgroup_from_mm(mm);
65546553

65556554
ret = try_charge(memcg, gfp_mask, nr_pages);
6556-
6557-
css_put(&memcg->css);
6558-
out:
6559-
*memcgp = memcg;
6560-
return ret;
6561-
}
6562-
6563-
int mem_cgroup_try_charge_delay(struct page *page, struct mm_struct *mm,
6564-
gfp_t gfp_mask, struct mem_cgroup **memcgp)
6565-
{
6566-
int ret;
6567-
6568-
ret = mem_cgroup_try_charge(page, mm, gfp_mask, memcgp);
6569-
if (*memcgp)
6570-
cgroup_throttle_swaprate(page, gfp_mask);
6571-
return ret;
6572-
}
6573-
6574-
/**
6575-
* mem_cgroup_commit_charge - commit a page charge
6576-
* @page: page to charge
6577-
* @memcg: memcg to charge the page to
6578-
* @lrucare: page might be on LRU already
6579-
*
6580-
* Finalize a charge transaction started by mem_cgroup_try_charge(),
6581-
* after page->mapping has been set up. This must happen atomically
6582-
* as part of the page instantiation, i.e. under the page table lock
6583-
* for anonymous pages, under the page lock for page and swap cache.
6584-
*
6585-
* In addition, the page must not be on the LRU during the commit, to
6586-
* prevent racing with task migration. If it might be, use @lrucare.
6587-
*
6588-
* Use mem_cgroup_cancel_charge() to cancel the transaction instead.
6589-
*/
6590-
void mem_cgroup_commit_charge(struct page *page, struct mem_cgroup *memcg,
6591-
bool lrucare)
6592-
{
6593-
unsigned int nr_pages = hpage_nr_pages(page);
6594-
6595-
VM_BUG_ON_PAGE(PageLRU(page) && !lrucare, page);
6596-
6597-
if (mem_cgroup_disabled())
6598-
return;
6599-
/*
6600-
* Swap faults will attempt to charge the same page multiple
6601-
* times. But reuse_swap_page() might have removed the page
6602-
* from swapcache already, so we can't check PageSwapCache().
6603-
*/
6604-
if (!memcg)
6605-
return;
6555+
if (ret)
6556+
goto out_put;
66066557

66076558
commit_charge(page, memcg, lrucare);
66086559

@@ -6620,55 +6571,11 @@ void mem_cgroup_commit_charge(struct page *page, struct mem_cgroup *memcg,
66206571
*/
66216572
mem_cgroup_uncharge_swap(entry, nr_pages);
66226573
}
6623-
}
66246574

6625-
/**
6626-
* mem_cgroup_cancel_charge - cancel a page charge
6627-
* @page: page to charge
6628-
* @memcg: memcg to charge the page to
6629-
*
6630-
* Cancel a charge transaction started by mem_cgroup_try_charge().
6631-
*/
6632-
void mem_cgroup_cancel_charge(struct page *page, struct mem_cgroup *memcg)
6633-
{
6634-
unsigned int nr_pages = hpage_nr_pages(page);
6635-
6636-
if (mem_cgroup_disabled())
6637-
return;
6638-
/*
6639-
* Swap faults will attempt to charge the same page multiple
6640-
* times. But reuse_swap_page() might have removed the page
6641-
* from swapcache already, so we can't check PageSwapCache().
6642-
*/
6643-
if (!memcg)
6644-
return;
6645-
6646-
cancel_charge(memcg, nr_pages);
6647-
}
6648-
6649-
/**
6650-
* mem_cgroup_charge - charge a newly allocated page to a cgroup
6651-
* @page: page to charge
6652-
* @mm: mm context of the victim
6653-
* @gfp_mask: reclaim mode
6654-
* @lrucare: page might be on the LRU already
6655-
*
6656-
* Try to charge @page to the memcg that @mm belongs to, reclaiming
6657-
* pages according to @gfp_mask if necessary.
6658-
*
6659-
* Returns 0 on success. Otherwise, an error code is returned.
6660-
*/
6661-
int mem_cgroup_charge(struct page *page, struct mm_struct *mm, gfp_t gfp_mask,
6662-
bool lrucare)
6663-
{
6664-
struct mem_cgroup *memcg;
6665-
int ret;
6666-
6667-
ret = mem_cgroup_try_charge(page, mm, gfp_mask, &memcg);
6668-
if (ret)
6669-
return ret;
6670-
mem_cgroup_commit_charge(page, memcg, lrucare);
6671-
return 0;
6575+
out_put:
6576+
css_put(&memcg->css);
6577+
out:
6578+
return ret;
66726579
}
66736580

66746581
struct uncharge_gather {
@@ -6773,8 +6680,7 @@ static void uncharge_list(struct list_head *page_list)
67736680
* mem_cgroup_uncharge - uncharge a page
67746681
* @page: page to uncharge
67756682
*
6776-
* Uncharge a page previously charged with mem_cgroup_try_charge() and
6777-
* mem_cgroup_commit_charge().
6683+
* Uncharge a page previously charged with mem_cgroup_charge().
67786684
*/
67796685
void mem_cgroup_uncharge(struct page *page)
67806686
{
@@ -6797,7 +6703,7 @@ void mem_cgroup_uncharge(struct page *page)
67976703
* @page_list: list of pages to uncharge
67986704
*
67996705
* Uncharge a list of pages previously charged with
6800-
* mem_cgroup_try_charge() and mem_cgroup_commit_charge().
6706+
* mem_cgroup_charge().
68016707
*/
68026708
void mem_cgroup_uncharge_list(struct list_head *page_list)
68036709
{

0 commit comments

Comments
 (0)