Skip to content

Commit

Permalink
SubjectL mm: use the light version __mod_zone_page_state in mlocked_v…
Browse files Browse the repository at this point in the history
…ma_newpage()

mlocked_vma_newpage() is called with pte lock held(a spinlock), which
implies preemtion disabled, and the vm stat counter is not modified from
interrupt context, so we need not use an irq-safe mod_zone_page_state()
here, using a light-weight version __mod_zone_page_state() would be OK.

This patch also documents __mod_zone_page_state() and some of its
callsites.  The comment above __mod_zone_page_state() is from Hugh
Dickins, and acked by Christoph.

Most credits to Hugh and Christoph for the clarification on the usage of
the __mod_zone_page_state().

Suggested-by: Andrew Morton <[email protected]>
Acked-by: Hugh Dickins <[email protected]>
Signed-off-by: Jianyu Zhan <[email protected]>
Reviewed-by: Christoph Lameter <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
  • Loading branch information
JianyuZhan authored and sfrothwell committed May 22, 2014
1 parent dc2a783 commit 33c91a1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
7 changes: 6 additions & 1 deletion mm/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,12 @@ static inline int mlocked_vma_newpage(struct vm_area_struct *vma,
return 0;

if (!TestSetPageMlocked(page)) {
mod_zone_page_state(page_zone(page), NR_MLOCK,
/*
* We use the irq-unsafe __mod_zone_page_stat because
* this counter is not modified from interrupt context, and the
* pte lock is held(spinlock), which implies preemtion disabled.
*/
__mod_zone_page_state(page_zone(page), NR_MLOCK,
hpage_nr_pages(page));
count_vm_event(UNEVICTABLE_PGMLOCKED);
}
Expand Down
10 changes: 10 additions & 0 deletions mm/rmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,11 @@ void do_page_add_anon_rmap(struct page *page,
{
int first = atomic_inc_and_test(&page->_mapcount);
if (first) {
/*
* We use the irq-unsafe __{inc|mod}_zone_page_stat because
* these counters are not modified in interrupt context, and
* pte lock(a spinlock) is held, which implies preemtion disabled.
*/
if (PageTransHuge(page))
__inc_zone_page_state(page,
NR_ANON_TRANSPARENT_HUGEPAGES);
Expand Down Expand Up @@ -1073,6 +1078,11 @@ void page_remove_rmap(struct page *page)
/*
* Hugepages are not counted in NR_ANON_PAGES nor NR_FILE_MAPPED
* and not charged by memcg for now.
*
* We use the irq-unsafe __{inc|mod}_zone_page_stat because
* these counters are not modified in interrupt context, and
* these counters are not modified in interrupt context, and
* pte lock(a spinlock) is held, which implies preemtion disabled.
*/
if (unlikely(PageHuge(page)))
goto out;
Expand Down
4 changes: 3 additions & 1 deletion mm/vmstat.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,9 @@ void set_pgdat_percpu_threshold(pg_data_t *pgdat,
}

/*
* For use when we know that interrupts are disabled.
* For use when we know that interrupts are disabled,
* or when we know that preemption is disabled and that
* particular counter cannot be updated from interrupt context.
*/
void __mod_zone_page_state(struct zone *zone, enum zone_stat_item item,
int delta)
Expand Down

0 comments on commit 33c91a1

Please sign in to comment.