Skip to content

Commit

Permalink
mm: remove swap token code
Browse files Browse the repository at this point in the history
The swap token code no longer fits in with the current VM model.  It
does not play well with cgroups or the better NUMA placement code in
development, since we have only one swap token globally.

It also has the potential to mess with scalability of the system, by
increasing the number of non-reclaimable pages on the active and
inactive anon LRU lists.

Last but not least, the swap token code has been broken for a year
without complaints, as reported by Konstantin Khlebnikov.  This suggests
we no longer have much use for it.

The days of sub-1G memory systems with heavy use of swap are over.  If
we ever need thrashing reducing code in the future, we will have to
implement something that does scale.

Signed-off-by: Rik van Riel <riel@redhat.com>
Cc: Konstantin Khlebnikov <khlebnikov@openvz.org>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: Mel Gorman <mel@csn.ul.ie>
Cc: Hugh Dickins <hughd@google.com>
Acked-by: Bob Picco <bpicco@meloft.net>
Acked-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Rik van Riel authored and Linus Torvalds committed May 29, 2012
1 parent edad9d2 commit e709ffd
Show file tree
Hide file tree
Showing 10 changed files with 2 additions and 307 deletions.
11 changes: 0 additions & 11 deletions include/linux/mm_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -345,17 +345,6 @@ struct mm_struct {
/* Architecture-specific MM context */
mm_context_t context;

/* Swap token stuff */
/*
* Last value of global fault stamp as seen by this process.
* In other words, this value gives an indication of how long
* it has been since this task got the token.
* Look at mm/thrash.c
*/
unsigned int faultstamp;
unsigned int token_priority;
unsigned int last_interval;

unsigned long flags; /* Must use atomic bitops to access the bits */

struct core_state *core_state; /* coredumping support */
Expand Down
35 changes: 0 additions & 35 deletions include/linux/swap.h
Original file line number Diff line number Diff line change
Expand Up @@ -355,23 +355,6 @@ extern int reuse_swap_page(struct page *);
extern int try_to_free_swap(struct page *);
struct backing_dev_info;

/* linux/mm/thrash.c */
extern struct mm_struct *swap_token_mm;
extern void grab_swap_token(struct mm_struct *);
extern void __put_swap_token(struct mm_struct *);
extern void disable_swap_token(struct mem_cgroup *memcg);

static inline int has_swap_token(struct mm_struct *mm)
{
return (mm == swap_token_mm);
}

static inline void put_swap_token(struct mm_struct *mm)
{
if (has_swap_token(mm))
__put_swap_token(mm);
}

#ifdef CONFIG_CGROUP_MEM_RES_CTLR
extern void
mem_cgroup_uncharge_swapcache(struct page *page, swp_entry_t ent, bool swapout);
Expand Down Expand Up @@ -476,24 +459,6 @@ static inline swp_entry_t get_swap_page(void)
return entry;
}

/* linux/mm/thrash.c */
static inline void put_swap_token(struct mm_struct *mm)
{
}

static inline void grab_swap_token(struct mm_struct *mm)
{
}

static inline int has_swap_token(struct mm_struct *mm)
{
return 0;
}

static inline void disable_swap_token(struct mem_cgroup *memcg)
{
}

static inline void
mem_cgroup_uncharge_swapcache(struct page *page, swp_entry_t ent)
{
Expand Down
82 changes: 0 additions & 82 deletions include/trace/events/vmscan.h
Original file line number Diff line number Diff line change
Expand Up @@ -395,88 +395,6 @@ TRACE_EVENT(mm_vmscan_lru_shrink_inactive,
show_reclaim_flags(__entry->reclaim_flags))
);

TRACE_EVENT(replace_swap_token,
TP_PROTO(struct mm_struct *old_mm,
struct mm_struct *new_mm),

TP_ARGS(old_mm, new_mm),

TP_STRUCT__entry(
__field(struct mm_struct*, old_mm)
__field(unsigned int, old_prio)
__field(struct mm_struct*, new_mm)
__field(unsigned int, new_prio)
),

TP_fast_assign(
__entry->old_mm = old_mm;
__entry->old_prio = old_mm ? old_mm->token_priority : 0;
__entry->new_mm = new_mm;
__entry->new_prio = new_mm->token_priority;
),

TP_printk("old_token_mm=%p old_prio=%u new_token_mm=%p new_prio=%u",
__entry->old_mm, __entry->old_prio,
__entry->new_mm, __entry->new_prio)
);

DECLARE_EVENT_CLASS(put_swap_token_template,
TP_PROTO(struct mm_struct *swap_token_mm),

TP_ARGS(swap_token_mm),

TP_STRUCT__entry(
__field(struct mm_struct*, swap_token_mm)
),

TP_fast_assign(
__entry->swap_token_mm = swap_token_mm;
),

TP_printk("token_mm=%p", __entry->swap_token_mm)
);

DEFINE_EVENT(put_swap_token_template, put_swap_token,
TP_PROTO(struct mm_struct *swap_token_mm),
TP_ARGS(swap_token_mm)
);

DEFINE_EVENT_CONDITION(put_swap_token_template, disable_swap_token,
TP_PROTO(struct mm_struct *swap_token_mm),
TP_ARGS(swap_token_mm),
TP_CONDITION(swap_token_mm != NULL)
);

TRACE_EVENT_CONDITION(update_swap_token_priority,
TP_PROTO(struct mm_struct *mm,
unsigned int old_prio,
struct mm_struct *swap_token_mm),

TP_ARGS(mm, old_prio, swap_token_mm),

TP_CONDITION(mm->token_priority != old_prio),

TP_STRUCT__entry(
__field(struct mm_struct*, mm)
__field(unsigned int, old_prio)
__field(unsigned int, new_prio)
__field(struct mm_struct*, swap_token_mm)
__field(unsigned int, swap_token_prio)
),

TP_fast_assign(
__entry->mm = mm;
__entry->old_prio = old_prio;
__entry->new_prio = mm->token_priority;
__entry->swap_token_mm = swap_token_mm;
__entry->swap_token_prio = swap_token_mm ? swap_token_mm->token_priority : 0;
),

TP_printk("mm=%p old_prio=%u new_prio=%u swap_token_mm=%p token_prio=%u",
__entry->mm, __entry->old_prio, __entry->new_prio,
__entry->swap_token_mm, __entry->swap_token_prio)
);

#endif /* _TRACE_VMSCAN_H */

/* This part must be outside protection */
Expand Down
9 changes: 0 additions & 9 deletions kernel/fork.c
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,6 @@ void mmput(struct mm_struct *mm)
list_del(&mm->mmlist);
spin_unlock(&mmlist_lock);
}
put_swap_token(mm);
if (mm->binfmt)
module_put(mm->binfmt->module);
mmdrop(mm);
Expand Down Expand Up @@ -831,10 +830,6 @@ struct mm_struct *dup_mm(struct task_struct *tsk)
memcpy(mm, oldmm, sizeof(*mm));
mm_init_cpumask(mm);

/* Initializing for Swap token stuff */
mm->token_priority = 0;
mm->last_interval = 0;

#ifdef CONFIG_TRANSPARENT_HUGEPAGE
mm->pmd_huge_pte = NULL;
#endif
Expand Down Expand Up @@ -913,10 +908,6 @@ static int copy_mm(unsigned long clone_flags, struct task_struct *tsk)
goto fail_nomem;

good_mm:
/* Initializing for Swap token stuff */
mm->token_priority = 0;
mm->last_interval = 0;

tsk->mm = mm;
tsk->active_mm = mm;
return 0;
Expand Down
2 changes: 1 addition & 1 deletion mm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ endif
obj-$(CONFIG_HAVE_MEMBLOCK) += memblock.o

obj-$(CONFIG_BOUNCE) += bounce.o
obj-$(CONFIG_SWAP) += page_io.o swap_state.o swapfile.o thrash.o
obj-$(CONFIG_SWAP) += page_io.o swap_state.o swapfile.o
obj-$(CONFIG_HAS_DMA) += dmapool.o
obj-$(CONFIG_HUGETLBFS) += hugetlb.o
obj-$(CONFIG_NUMA) += mempolicy.o
Expand Down
1 change: 0 additions & 1 deletion mm/memcontrol.c
Original file line number Diff line number Diff line change
Expand Up @@ -5598,7 +5598,6 @@ static void mem_cgroup_move_task(struct cgroup *cont,
if (mm) {
if (mc.to)
mem_cgroup_move_charge(mm);
put_swap_token(mm);
mmput(mm);
}
if (mc.to)
Expand Down
2 changes: 1 addition & 1 deletion mm/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -2908,7 +2908,6 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
delayacct_set_flag(DELAYACCT_PF_SWAPIN);
page = lookup_swap_cache(entry);
if (!page) {
grab_swap_token(mm); /* Contend for token _before_ read-in */
page = swapin_readahead(entry,
GFP_HIGHUSER_MOVABLE, vma, address);
if (!page) {
Expand Down Expand Up @@ -2938,6 +2937,7 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
}

locked = lock_page_or_retry(page, mm, flags);

delayacct_clear_flag(DELAYACCT_PF_SWAPIN);
if (!locked) {
ret |= VM_FAULT_RETRY;
Expand Down
6 changes: 0 additions & 6 deletions mm/rmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -755,12 +755,6 @@ int page_referenced_one(struct page *page, struct vm_area_struct *vma,
pte_unmap_unlock(pte, ptl);
}

/* Pretend the page is referenced if the task has the
swap token and is in the middle of a page fault. */
if (mm != current->mm && has_swap_token(mm) &&
rwsem_is_locked(&mm->mmap_sem))
referenced++;

(*mapcount)--;

if (referenced)
Expand Down
155 changes: 0 additions & 155 deletions mm/thrash.c

This file was deleted.

Loading

0 comments on commit e709ffd

Please sign in to comment.