Skip to content

Commit

Permalink
Merge branch 'akpm' (patches from Andrew)
Browse files Browse the repository at this point in the history
Merge fixes from Andrew Morton:
 "15 patches.

  Subsystems affected by this patch series: mailmap, mm/hotfixes,
  mm/thp, mm/memory-hotplug, misc, kcsan"

* emailed patches from Andrew Morton <[email protected]>:
  kcsan: kconfig: move to menu 'Generic Kernel Debugging Instruments'
  fs/fs-writeback.c: adjust dirtytime_interval_handler definition to match prototype
  stackleak: let stack_erasing_sysctl take a kernel pointer buffer
  ftrace: let ftrace_enable_sysctl take a kernel pointer buffer
  mm/memory_hotplug: drain per-cpu pages again during memory offline
  selftests/vm: fix display of page size in map_hugetlb
  mm/thp: fix __split_huge_pmd_locked() for migration PMD
  kprobes: fix kill kprobe which has been marked as gone
  tmpfs: restore functionality of nr_inodes=0
  mlock: fix unevictable_pgs event counts on THP
  mm: fix check_move_unevictable_pages() on THP
  mm: migration of hugetlbfs page skip memcg
  ksm: reinstate memcg charge on copied pages
  mailmap: add older email addresses for Kees Cook
  • Loading branch information
torvalds committed Sep 20, 2020
2 parents c8d1a46 + 2645d43 commit 325d0ea
Show file tree
Hide file tree
Showing 18 changed files with 102 additions and 50 deletions.
4 changes: 4 additions & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ Juha Yrjola <[email protected]>
Julien Thierry <[email protected]> <[email protected]>
Kamil Konieczny <[email protected]> <[email protected]>
Kay Sievers <[email protected]>
Kees Cook <[email protected]> <[email protected]>
Kees Cook <[email protected]> <[email protected]>
Kees Cook <[email protected]> <[email protected]>
Kees Cook <[email protected]> <[email protected]>
Kenneth W Chen <[email protected]>
Konstantin Khlebnikov <[email protected]> <[email protected]>
Konstantin Khlebnikov <[email protected]> <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion fs/fs-writeback.c
Original file line number Diff line number Diff line change
Expand Up @@ -2184,7 +2184,7 @@ static int __init start_dirtytime_writeback(void)
__initcall(start_dirtytime_writeback);

int dirtytime_interval_handler(struct ctl_table *table, int write,
void __user *buffer, size_t *lenp, loff_t *ppos)
void *buffer, size_t *lenp, loff_t *ppos)
{
int ret;

Expand Down
3 changes: 1 addition & 2 deletions include/linux/ftrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ static inline int ftrace_mod_get_kallsym(unsigned int symnum, unsigned long *val
extern int ftrace_enabled;
extern int
ftrace_enable_sysctl(struct ctl_table *table, int write,
void __user *buffer, size_t *lenp,
loff_t *ppos);
void *buffer, size_t *lenp, loff_t *ppos);

struct ftrace_ops;

Expand Down
2 changes: 1 addition & 1 deletion include/linux/stackleak.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ static inline void stackleak_task_init(struct task_struct *t)

#ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE
int stack_erasing_sysctl(struct ctl_table *table, int write,
void __user *buffer, size_t *lenp, loff_t *ppos);
void *buffer, size_t *lenp, loff_t *ppos);
#endif

#else /* !CONFIG_GCC_PLUGIN_STACKLEAK */
Expand Down
9 changes: 8 additions & 1 deletion kernel/kprobes.c
Original file line number Diff line number Diff line change
Expand Up @@ -2140,6 +2140,9 @@ static void kill_kprobe(struct kprobe *p)

lockdep_assert_held(&kprobe_mutex);

if (WARN_ON_ONCE(kprobe_gone(p)))
return;

p->flags |= KPROBE_FLAG_GONE;
if (kprobe_aggrprobe(p)) {
/*
Expand Down Expand Up @@ -2419,7 +2422,10 @@ static int kprobes_module_callback(struct notifier_block *nb,
mutex_lock(&kprobe_mutex);
for (i = 0; i < KPROBE_TABLE_SIZE; i++) {
head = &kprobe_table[i];
hlist_for_each_entry(p, head, hlist)
hlist_for_each_entry(p, head, hlist) {
if (kprobe_gone(p))
continue;

if (within_module_init((unsigned long)p->addr, mod) ||
(checkcore &&
within_module_core((unsigned long)p->addr, mod))) {
Expand All @@ -2436,6 +2442,7 @@ static int kprobes_module_callback(struct notifier_block *nb,
*/
kill_kprobe(p);
}
}
}
if (val == MODULE_STATE_GOING)
remove_module_kprobe_blacklist(mod);
Expand Down
2 changes: 1 addition & 1 deletion kernel/stackleak.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
static DEFINE_STATIC_KEY_FALSE(stack_erasing_bypass);

int stack_erasing_sysctl(struct ctl_table *table, int write,
void __user *buffer, size_t *lenp, loff_t *ppos)
void *buffer, size_t *lenp, loff_t *ppos)
{
int ret = 0;
int state = !static_branch_unlikely(&stack_erasing_bypass);
Expand Down
3 changes: 1 addition & 2 deletions kernel/trace/ftrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -7531,8 +7531,7 @@ static bool is_permanent_ops_registered(void)

int
ftrace_enable_sysctl(struct ctl_table *table, int write,
void __user *buffer, size_t *lenp,
loff_t *ppos)
void *buffer, size_t *lenp, loff_t *ppos)
{
int ret = -ENODEV;

Expand Down
4 changes: 1 addition & 3 deletions lib/Kconfig.debug
Original file line number Diff line number Diff line change
Expand Up @@ -520,8 +520,8 @@ config DEBUG_FS_ALLOW_NONE
endchoice

source "lib/Kconfig.kgdb"

source "lib/Kconfig.ubsan"
source "lib/Kconfig.kcsan"

endmenu

Expand Down Expand Up @@ -1620,8 +1620,6 @@ config PROVIDE_OHCI1394_DMA_INIT

source "samples/Kconfig"

source "lib/Kconfig.kcsan"

config ARCH_HAS_DEVMEM_IS_ALLOWED
bool

Expand Down
42 changes: 23 additions & 19 deletions mm/huge_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -2022,7 +2022,7 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd,
put_page(page);
add_mm_counter(mm, mm_counter_file(page), -HPAGE_PMD_NR);
return;
} else if (is_huge_zero_pmd(*pmd)) {
} else if (pmd_trans_huge(*pmd) && is_huge_zero_pmd(*pmd)) {
/*
* FIXME: Do we want to invalidate secondary mmu by calling
* mmu_notifier_invalidate_range() see comments below inside
Expand Down Expand Up @@ -2116,30 +2116,34 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd,
pte = pte_offset_map(&_pmd, addr);
BUG_ON(!pte_none(*pte));
set_pte_at(mm, addr, pte, entry);
atomic_inc(&page[i]._mapcount);
pte_unmap(pte);
}

/*
* Set PG_double_map before dropping compound_mapcount to avoid
* false-negative page_mapped().
*/
if (compound_mapcount(page) > 1 && !TestSetPageDoubleMap(page)) {
for (i = 0; i < HPAGE_PMD_NR; i++)
if (!pmd_migration)
atomic_inc(&page[i]._mapcount);
pte_unmap(pte);
}

lock_page_memcg(page);
if (atomic_add_negative(-1, compound_mapcount_ptr(page))) {
/* Last compound_mapcount is gone. */
__dec_lruvec_page_state(page, NR_ANON_THPS);
if (TestClearPageDoubleMap(page)) {
/* No need in mapcount reference anymore */
if (!pmd_migration) {
/*
* Set PG_double_map before dropping compound_mapcount to avoid
* false-negative page_mapped().
*/
if (compound_mapcount(page) > 1 &&
!TestSetPageDoubleMap(page)) {
for (i = 0; i < HPAGE_PMD_NR; i++)
atomic_dec(&page[i]._mapcount);
atomic_inc(&page[i]._mapcount);
}

lock_page_memcg(page);
if (atomic_add_negative(-1, compound_mapcount_ptr(page))) {
/* Last compound_mapcount is gone. */
__dec_lruvec_page_state(page, NR_ANON_THPS);
if (TestClearPageDoubleMap(page)) {
/* No need in mapcount reference anymore */
for (i = 0; i < HPAGE_PMD_NR; i++)
atomic_dec(&page[i]._mapcount);
}
}
unlock_page_memcg(page);
}
unlock_page_memcg(page);

smp_wmb(); /* make pte visible before pmd */
pmd_populate(mm, pmd, pgtable);
Expand Down
4 changes: 4 additions & 0 deletions mm/ksm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2586,6 +2586,10 @@ struct page *ksm_might_need_to_copy(struct page *page,
return page; /* let do_swap_page report the error */

new_page = alloc_page_vma(GFP_HIGHUSER_MOVABLE, vma, address);
if (new_page && mem_cgroup_charge(new_page, vma->vm_mm, GFP_KERNEL)) {
put_page(new_page);
new_page = NULL;
}
if (new_page) {
copy_user_highpage(new_page, page, address, vma);

Expand Down
14 changes: 14 additions & 0 deletions mm/memory_hotplug.c
Original file line number Diff line number Diff line change
Expand Up @@ -1575,6 +1575,20 @@ static int __ref __offline_pages(unsigned long start_pfn,
/* check again */
ret = walk_system_ram_range(start_pfn, end_pfn - start_pfn,
NULL, check_pages_isolated_cb);
/*
* per-cpu pages are drained in start_isolate_page_range, but if
* there are still pages that are not free, make sure that we
* drain again, because when we isolated range we might
* have raced with another thread that was adding pages to pcp
* list.
*
* Forward progress should be still guaranteed because
* pages on the pcp list can only belong to MOVABLE_ZONE
* because has_unmovable_pages explicitly checks for
* PageBuddy on freed pages on other zones.
*/
if (ret)
drain_all_pages(zone);
} while (ret);

/* Ok, all of our target is isolated.
Expand Down
3 changes: 2 additions & 1 deletion mm/migrate.c
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,8 @@ void migrate_page_states(struct page *newpage, struct page *page)

copy_page_owner(page, newpage);

mem_cgroup_migrate(page, newpage);
if (!PageHuge(page))
mem_cgroup_migrate(page, newpage);
}
EXPORT_SYMBOL(migrate_page_states);

Expand Down
24 changes: 15 additions & 9 deletions mm/mlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,14 @@ EXPORT_SYMBOL(can_do_mlock);
*/
void clear_page_mlock(struct page *page)
{
int nr_pages;

if (!TestClearPageMlocked(page))
return;

mod_zone_page_state(page_zone(page), NR_MLOCK, -thp_nr_pages(page));
count_vm_event(UNEVICTABLE_PGCLEARED);
nr_pages = thp_nr_pages(page);
mod_zone_page_state(page_zone(page), NR_MLOCK, -nr_pages);
count_vm_events(UNEVICTABLE_PGCLEARED, nr_pages);
/*
* The previous TestClearPageMlocked() corresponds to the smp_mb()
* in __pagevec_lru_add_fn().
Expand All @@ -76,7 +79,7 @@ void clear_page_mlock(struct page *page)
* We lost the race. the page already moved to evictable list.
*/
if (PageUnevictable(page))
count_vm_event(UNEVICTABLE_PGSTRANDED);
count_vm_events(UNEVICTABLE_PGSTRANDED, nr_pages);
}
}

Expand All @@ -93,9 +96,10 @@ void mlock_vma_page(struct page *page)
VM_BUG_ON_PAGE(PageCompound(page) && PageDoubleMap(page), page);

if (!TestSetPageMlocked(page)) {
mod_zone_page_state(page_zone(page), NR_MLOCK,
thp_nr_pages(page));
count_vm_event(UNEVICTABLE_PGMLOCKED);
int nr_pages = thp_nr_pages(page);

mod_zone_page_state(page_zone(page), NR_MLOCK, nr_pages);
count_vm_events(UNEVICTABLE_PGMLOCKED, nr_pages);
if (!isolate_lru_page(page))
putback_lru_page(page);
}
Expand Down Expand Up @@ -138,7 +142,7 @@ static void __munlock_isolated_page(struct page *page)

/* Did try_to_unlock() succeed or punt? */
if (!PageMlocked(page))
count_vm_event(UNEVICTABLE_PGMUNLOCKED);
count_vm_events(UNEVICTABLE_PGMUNLOCKED, thp_nr_pages(page));

putback_lru_page(page);
}
Expand All @@ -154,10 +158,12 @@ static void __munlock_isolated_page(struct page *page)
*/
static void __munlock_isolation_failed(struct page *page)
{
int nr_pages = thp_nr_pages(page);

if (PageUnevictable(page))
__count_vm_event(UNEVICTABLE_PGSTRANDED);
__count_vm_events(UNEVICTABLE_PGSTRANDED, nr_pages);
else
__count_vm_event(UNEVICTABLE_PGMUNLOCKED);
__count_vm_events(UNEVICTABLE_PGMUNLOCKED, nr_pages);
}

/**
Expand Down
8 changes: 8 additions & 0 deletions mm/page_isolation.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,14 @@ __first_valid_page(unsigned long pfn, unsigned long nr_pages)
* pageblocks we may have modified and return -EBUSY to caller. This
* prevents two threads from simultaneously working on overlapping ranges.
*
* Please note that there is no strong synchronization with the page allocator
* either. Pages might be freed while their page blocks are marked ISOLATED.
* In some cases pages might still end up on pcp lists and that would allow
* for their allocation even when they are in fact isolated already. Depending
* on how strong of a guarantee the caller needs drain_all_pages might be needed
* (e.g. __offline_pages will need to call it after check for isolated range for
* a next retry).
*
* Return: the number of isolated pageblocks on success and -EBUSY if any part
* of range cannot be isolated.
*/
Expand Down
10 changes: 6 additions & 4 deletions mm/shmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,13 @@ static int shmem_reserve_inode(struct super_block *sb, ino_t *inop)

if (!(sb->s_flags & SB_KERNMOUNT)) {
spin_lock(&sbinfo->stat_lock);
if (!sbinfo->free_inodes) {
spin_unlock(&sbinfo->stat_lock);
return -ENOSPC;
if (sbinfo->max_inodes) {
if (!sbinfo->free_inodes) {
spin_unlock(&sbinfo->stat_lock);
return -ENOSPC;
}
sbinfo->free_inodes--;
}
sbinfo->free_inodes--;
if (inop) {
ino = sbinfo->next_ino++;
if (unlikely(is_zero_ino(ino)))
Expand Down
6 changes: 3 additions & 3 deletions mm/swap.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,14 +494,14 @@ void lru_cache_add_inactive_or_unevictable(struct page *page,

unevictable = (vma->vm_flags & (VM_LOCKED | VM_SPECIAL)) == VM_LOCKED;
if (unlikely(unevictable) && !TestSetPageMlocked(page)) {
int nr_pages = thp_nr_pages(page);
/*
* 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 preemption disabled.
*/
__mod_zone_page_state(page_zone(page), NR_MLOCK,
thp_nr_pages(page));
count_vm_event(UNEVICTABLE_PGMLOCKED);
__mod_zone_page_state(page_zone(page), NR_MLOCK, nr_pages);
count_vm_events(UNEVICTABLE_PGMLOCKED, nr_pages);
}
lru_cache_add(page);
}
Expand Down
10 changes: 8 additions & 2 deletions mm/vmscan.c
Original file line number Diff line number Diff line change
Expand Up @@ -4268,8 +4268,14 @@ void check_move_unevictable_pages(struct pagevec *pvec)
for (i = 0; i < pvec->nr; i++) {
struct page *page = pvec->pages[i];
struct pglist_data *pagepgdat = page_pgdat(page);
int nr_pages;

if (PageTransTail(page))
continue;

nr_pages = thp_nr_pages(page);
pgscanned += nr_pages;

pgscanned++;
if (pagepgdat != pgdat) {
if (pgdat)
spin_unlock_irq(&pgdat->lru_lock);
Expand All @@ -4288,7 +4294,7 @@ void check_move_unevictable_pages(struct pagevec *pvec)
ClearPageUnevictable(page);
del_page_from_lru_list(page, lruvec, LRU_UNEVICTABLE);
add_page_to_lru_list(page, lruvec, lru);
pgrescued++;
pgrescued += nr_pages;
}
}

Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/vm/map_hugetlb.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ int main(int argc, char **argv)
}

if (shift)
printf("%u kB hugepages\n", 1 << shift);
printf("%u kB hugepages\n", 1 << (shift - 10));
else
printf("Default size hugepages\n");
printf("Mapping %lu Mbytes\n", (unsigned long)length >> 20);
Expand Down

0 comments on commit 325d0ea

Please sign in to comment.