Commit 4a51c60a authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'akpm' (patches from Andrew)

Merge misc fixes from Andrew Morton:
 "8 patches.

  Subsystems affected by this patch series: mm (madvise, pagemap,
  readahead, memcg, userfaultfd), kbuild, and vfs"

* emailed patches from Andrew Morton <akpm@linux-foundation.org>:
  mm: fix madvise WILLNEED performance problem
  libfs: fix error cast of negative value in simple_attr_write()
  mm/userfaultfd: do not access vma->vm_mm after calling handle_userfault()
  mm: memcg/slab: fix root memcg vmstats
  mm: fix readahead_page_batch for retry entries
  mm: fix phys_to_target_node() and memory_add_physaddr_to_nid() exports
  compiler-clang: remove version check for BPF Tracing
  mm/madvise: fix memory leak from process_madvise
parents d27637ec 66383800
...@@ -18,4 +18,10 @@ ...@@ -18,4 +18,10 @@
#endif #endif
#endif /* CONFIG_SPARSEMEM */ #endif /* CONFIG_SPARSEMEM */
#ifdef CONFIG_MEMORY_HOTPLUG
int memory_add_physaddr_to_nid(u64 addr);
#define memory_add_physaddr_to_nid memory_add_physaddr_to_nid
#endif
#endif /* _ASM_IA64_SPARSEMEM_H */ #endif /* _ASM_IA64_SPARSEMEM_H */
...@@ -46,5 +46,10 @@ u64 memory_hotplug_max(void); ...@@ -46,5 +46,10 @@ u64 memory_hotplug_max(void);
#define __HAVE_ARCH_RESERVED_KERNEL_PAGES #define __HAVE_ARCH_RESERVED_KERNEL_PAGES
#endif #endif
#ifdef CONFIG_MEMORY_HOTPLUG
extern int create_section_mapping(unsigned long start, unsigned long end,
int nid, pgprot_t prot);
#endif
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */
#endif /* _ASM_MMZONE_H_ */ #endif /* _ASM_MMZONE_H_ */
...@@ -13,9 +13,9 @@ ...@@ -13,9 +13,9 @@
#endif /* CONFIG_SPARSEMEM */ #endif /* CONFIG_SPARSEMEM */
#ifdef CONFIG_MEMORY_HOTPLUG #ifdef CONFIG_MEMORY_HOTPLUG
extern int create_section_mapping(unsigned long start, unsigned long end,
int nid, pgprot_t prot);
extern int remove_section_mapping(unsigned long start, unsigned long end); extern int remove_section_mapping(unsigned long start, unsigned long end);
extern int memory_add_physaddr_to_nid(u64 start);
#define memory_add_physaddr_to_nid memory_add_physaddr_to_nid
#ifdef CONFIG_NUMA #ifdef CONFIG_NUMA
extern int hot_add_scn_to_nid(unsigned long scn_addr); extern int hot_add_scn_to_nid(unsigned long scn_addr);
...@@ -26,6 +26,5 @@ static inline int hot_add_scn_to_nid(unsigned long scn_addr) ...@@ -26,6 +26,5 @@ static inline int hot_add_scn_to_nid(unsigned long scn_addr)
} }
#endif /* CONFIG_NUMA */ #endif /* CONFIG_NUMA */
#endif /* CONFIG_MEMORY_HOTPLUG */ #endif /* CONFIG_MEMORY_HOTPLUG */
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */
#endif /* _ASM_POWERPC_SPARSEMEM_H */ #endif /* _ASM_POWERPC_SPARSEMEM_H */
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
#include <asm/rtas.h> #include <asm/rtas.h>
#include <asm/kasan.h> #include <asm/kasan.h>
#include <asm/svm.h> #include <asm/svm.h>
#include <asm/mmzone.h>
#include <mm/mmu_decl.h> #include <mm/mmu_decl.h>
......
...@@ -28,4 +28,14 @@ ...@@ -28,4 +28,14 @@
#endif #endif
#endif /* CONFIG_SPARSEMEM */ #endif /* CONFIG_SPARSEMEM */
#ifndef __ASSEMBLY__
#ifdef CONFIG_NUMA_KEEP_MEMINFO
extern int phys_to_target_node(phys_addr_t start);
#define phys_to_target_node phys_to_target_node
extern int memory_add_physaddr_to_nid(u64 start);
#define memory_add_physaddr_to_nid memory_add_physaddr_to_nid
#endif
#endif /* __ASSEMBLY__ */
#endif /* _ASM_X86_SPARSEMEM_H */ #endif /* _ASM_X86_SPARSEMEM_H */
...@@ -938,6 +938,7 @@ int phys_to_target_node(phys_addr_t start) ...@@ -938,6 +938,7 @@ int phys_to_target_node(phys_addr_t start)
return meminfo_to_nid(&numa_reserved_meminfo, start); return meminfo_to_nid(&numa_reserved_meminfo, start);
} }
EXPORT_SYMBOL_GPL(phys_to_target_node);
int memory_add_physaddr_to_nid(u64 start) int memory_add_physaddr_to_nid(u64 start)
{ {
...@@ -947,4 +948,5 @@ int memory_add_physaddr_to_nid(u64 start) ...@@ -947,4 +948,5 @@ int memory_add_physaddr_to_nid(u64 start)
nid = numa_meminfo.blk[0].nid; nid = numa_meminfo.blk[0].nid;
return nid; return nid;
} }
EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid);
#endif #endif
...@@ -50,7 +50,6 @@ config DEV_DAX_HMEM ...@@ -50,7 +50,6 @@ config DEV_DAX_HMEM
Say M if unsure. Say M if unsure.
config DEV_DAX_HMEM_DEVICES config DEV_DAX_HMEM_DEVICES
depends on NUMA_KEEP_MEMINFO # for phys_to_target_node()
depends on DEV_DAX_HMEM && DAX=y depends on DEV_DAX_HMEM && DAX=y
def_bool y def_bool y
......
...@@ -959,7 +959,7 @@ ssize_t simple_attr_write(struct file *file, const char __user *buf, ...@@ -959,7 +959,7 @@ ssize_t simple_attr_write(struct file *file, const char __user *buf,
size_t len, loff_t *ppos) size_t len, loff_t *ppos)
{ {
struct simple_attr *attr; struct simple_attr *attr;
u64 val; unsigned long long val;
size_t size; size_t size;
ssize_t ret; ssize_t ret;
...@@ -977,7 +977,9 @@ ssize_t simple_attr_write(struct file *file, const char __user *buf, ...@@ -977,7 +977,9 @@ ssize_t simple_attr_write(struct file *file, const char __user *buf,
goto out; goto out;
attr->set_buf[size] = '\0'; attr->set_buf[size] = '\0';
val = simple_strtoll(attr->set_buf, NULL, 0); ret = kstrtoull(attr->set_buf, 0, &val);
if (ret)
goto out;
ret = attr->set(attr->data, val); ret = attr->set(attr->data, val);
if (ret == 0) if (ret == 0)
ret = len; /* on success, claim we got the whole input */ ret = len; /* on success, claim we got the whole input */
......
...@@ -8,8 +8,10 @@ ...@@ -8,8 +8,10 @@
+ __clang_patchlevel__) + __clang_patchlevel__)
#if CLANG_VERSION < 100001 #if CLANG_VERSION < 100001
#ifndef __BPF_TRACING__
# error Sorry, your version of Clang is too old - please use 10.0.1 or newer. # error Sorry, your version of Clang is too old - please use 10.0.1 or newer.
#endif #endif
#endif
/* Compiler specific definitions for Clang compiler */ /* Compiler specific definitions for Clang compiler */
......
...@@ -281,20 +281,6 @@ static inline bool movable_node_is_enabled(void) ...@@ -281,20 +281,6 @@ static inline bool movable_node_is_enabled(void)
} }
#endif /* ! CONFIG_MEMORY_HOTPLUG */ #endif /* ! CONFIG_MEMORY_HOTPLUG */
#ifdef CONFIG_NUMA
extern int memory_add_physaddr_to_nid(u64 start);
extern int phys_to_target_node(u64 start);
#else
static inline int memory_add_physaddr_to_nid(u64 start)
{
return 0;
}
static inline int phys_to_target_node(u64 start)
{
return 0;
}
#endif
#if defined(CONFIG_MEMORY_HOTPLUG) || defined(CONFIG_DEFERRED_STRUCT_PAGE_INIT) #if defined(CONFIG_MEMORY_HOTPLUG) || defined(CONFIG_DEFERRED_STRUCT_PAGE_INIT)
/* /*
* pgdat resizing functions * pgdat resizing functions
......
...@@ -21,13 +21,41 @@ ...@@ -21,13 +21,41 @@
#endif #endif
#ifdef CONFIG_NUMA #ifdef CONFIG_NUMA
#include <linux/printk.h>
#include <asm/sparsemem.h>
/* Generic implementation available */ /* Generic implementation available */
int numa_map_to_online_node(int node); int numa_map_to_online_node(int node);
#else
#ifndef memory_add_physaddr_to_nid
static inline int memory_add_physaddr_to_nid(u64 start)
{
pr_info_once("Unknown online node for memory at 0x%llx, assuming node 0\n",
start);
return 0;
}
#endif
#ifndef phys_to_target_node
static inline int phys_to_target_node(u64 start)
{
pr_info_once("Unknown target node for memory at 0x%llx, assuming node 0\n",
start);
return 0;
}
#endif
#else /* !CONFIG_NUMA */
static inline int numa_map_to_online_node(int node) static inline int numa_map_to_online_node(int node)
{ {
return NUMA_NO_NODE; return NUMA_NO_NODE;
} }
static inline int memory_add_physaddr_to_nid(u64 start)
{
return 0;
}
static inline int phys_to_target_node(u64 start)
{
return 0;
}
#endif #endif
#endif /* _LINUX_NUMA_H */ #endif /* _LINUX_NUMA_H */
...@@ -906,6 +906,8 @@ static inline unsigned int __readahead_batch(struct readahead_control *rac, ...@@ -906,6 +906,8 @@ static inline unsigned int __readahead_batch(struct readahead_control *rac,
xas_set(&xas, rac->_index); xas_set(&xas, rac->_index);
rcu_read_lock(); rcu_read_lock();
xas_for_each(&xas, page, rac->_index + rac->_nr_pages - 1) { xas_for_each(&xas, page, rac->_index + rac->_nr_pages - 1) {
if (xas_retry(&xas, page))
continue;
VM_BUG_ON_PAGE(!PageLocked(page), page); VM_BUG_ON_PAGE(!PageLocked(page), page);
VM_BUG_ON_PAGE(PageTail(page), page); VM_BUG_ON_PAGE(PageTail(page), page);
array[i++] = page; array[i++] = page;
......
...@@ -710,7 +710,6 @@ vm_fault_t do_huge_pmd_anonymous_page(struct vm_fault *vmf) ...@@ -710,7 +710,6 @@ vm_fault_t do_huge_pmd_anonymous_page(struct vm_fault *vmf)
transparent_hugepage_use_zero_page()) { transparent_hugepage_use_zero_page()) {
pgtable_t pgtable; pgtable_t pgtable;
struct page *zero_page; struct page *zero_page;
bool set;
vm_fault_t ret; vm_fault_t ret;
pgtable = pte_alloc_one(vma->vm_mm); pgtable = pte_alloc_one(vma->vm_mm);
if (unlikely(!pgtable)) if (unlikely(!pgtable))
...@@ -723,25 +722,25 @@ vm_fault_t do_huge_pmd_anonymous_page(struct vm_fault *vmf) ...@@ -723,25 +722,25 @@ vm_fault_t do_huge_pmd_anonymous_page(struct vm_fault *vmf)
} }
vmf->ptl = pmd_lock(vma->vm_mm, vmf->pmd); vmf->ptl = pmd_lock(vma->vm_mm, vmf->pmd);
ret = 0; ret = 0;
set = false;
if (pmd_none(*vmf->pmd)) { if (pmd_none(*vmf->pmd)) {
ret = check_stable_address_space(vma->vm_mm); ret = check_stable_address_space(vma->vm_mm);
if (ret) { if (ret) {
spin_unlock(vmf->ptl); spin_unlock(vmf->ptl);
pte_free(vma->vm_mm, pgtable);
} else if (userfaultfd_missing(vma)) { } else if (userfaultfd_missing(vma)) {
spin_unlock(vmf->ptl); spin_unlock(vmf->ptl);
pte_free(vma->vm_mm, pgtable);
ret = handle_userfault(vmf, VM_UFFD_MISSING); ret = handle_userfault(vmf, VM_UFFD_MISSING);
VM_BUG_ON(ret & VM_FAULT_FALLBACK); VM_BUG_ON(ret & VM_FAULT_FALLBACK);
} else { } else {
set_huge_zero_page(pgtable, vma->vm_mm, vma, set_huge_zero_page(pgtable, vma->vm_mm, vma,
haddr, vmf->pmd, zero_page); haddr, vmf->pmd, zero_page);
spin_unlock(vmf->ptl); spin_unlock(vmf->ptl);
set = true;
} }
} else } else {
spin_unlock(vmf->ptl); spin_unlock(vmf->ptl);
if (!set)
pte_free(vma->vm_mm, pgtable); pte_free(vma->vm_mm, pgtable);
}
return ret; return ret;
} }
gfp = alloc_hugepage_direct_gfpmask(vma); gfp = alloc_hugepage_direct_gfpmask(vma);
......
...@@ -226,7 +226,7 @@ static void force_shm_swapin_readahead(struct vm_area_struct *vma, ...@@ -226,7 +226,7 @@ static void force_shm_swapin_readahead(struct vm_area_struct *vma,
struct address_space *mapping) struct address_space *mapping)
{ {
XA_STATE(xas, &mapping->i_pages, linear_page_index(vma, start)); XA_STATE(xas, &mapping->i_pages, linear_page_index(vma, start));
pgoff_t end_index = end / PAGE_SIZE; pgoff_t end_index = linear_page_index(vma, end + PAGE_SIZE - 1);
struct page *page; struct page *page;
rcu_read_lock(); rcu_read_lock();
...@@ -1231,8 +1231,6 @@ SYSCALL_DEFINE5(process_madvise, int, pidfd, const struct iovec __user *, vec, ...@@ -1231,8 +1231,6 @@ SYSCALL_DEFINE5(process_madvise, int, pidfd, const struct iovec __user *, vec,
ret = total_len - iov_iter_count(&iter); ret = total_len - iov_iter_count(&iter);
mmput(mm); mmput(mm);
return ret;
release_task: release_task:
put_task_struct(task); put_task_struct(task);
put_pid: put_pid:
......
...@@ -867,8 +867,13 @@ void __mod_lruvec_slab_state(void *p, enum node_stat_item idx, int val) ...@@ -867,8 +867,13 @@ void __mod_lruvec_slab_state(void *p, enum node_stat_item idx, int val)
rcu_read_lock(); rcu_read_lock();
memcg = mem_cgroup_from_obj(p); memcg = mem_cgroup_from_obj(p);
/* Untracked pages have no memcg, no lruvec. Update only the node */ /*
if (!memcg || memcg == root_mem_cgroup) { * Untracked pages have no memcg, no lruvec. Update only the
* node. If we reparent the slab objects to the root memcg,
* when we free the slab object, we need to update the per-memcg
* vmstats to keep it correct for the root memcg.
*/
if (!memcg) {
__mod_node_page_state(pgdat, idx, val); __mod_node_page_state(pgdat, idx, val);
} else { } else {
lruvec = mem_cgroup_lruvec(memcg, pgdat); lruvec = mem_cgroup_lruvec(memcg, pgdat);
......
...@@ -350,24 +350,6 @@ int __ref __add_pages(int nid, unsigned long pfn, unsigned long nr_pages, ...@@ -350,24 +350,6 @@ int __ref __add_pages(int nid, unsigned long pfn, unsigned long nr_pages,
return err; return err;
} }
#ifdef CONFIG_NUMA
int __weak memory_add_physaddr_to_nid(u64 start)
{
pr_info_once("Unknown online node for memory at 0x%llx, assuming node 0\n",
start);
return 0;
}
EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid);
int __weak phys_to_target_node(u64 start)
{
pr_info_once("Unknown target node for memory at 0x%llx, assuming node 0\n",
start);
return 0;
}
EXPORT_SYMBOL_GPL(phys_to_target_node);
#endif
/* find the smallest valid pfn in the range [start_pfn, end_pfn) */ /* find the smallest valid pfn in the range [start_pfn, end_pfn) */
static unsigned long find_smallest_section_pfn(int nid, struct zone *zone, static unsigned long find_smallest_section_pfn(int nid, struct zone *zone,
unsigned long start_pfn, unsigned long start_pfn,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment