All of lore.kernel.org
 help / color / mirror / Atom feed
* + mm-page_alloc-reduce-potential-fragmentation-in-make_alloc_exact.patch added to mm-unstable branch
@ 2022-06-01 20:44 Andrew Morton
  2022-10-19 18:59 ` Matthew Wilcox
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Morton @ 2022-06-01 20:44 UTC (permalink / raw)
  To: mm-commits, willy, Liam.Howlett, Liam.Howlett, akpm


The patch titled
     Subject: mm/page_alloc: reduce potential fragmentation in make_alloc_exact()
has been added to the -mm mm-unstable branch.  Its filename is
     mm-page_alloc-reduce-potential-fragmentation-in-make_alloc_exact.patch

This patch will shortly appear at
     https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-page_alloc-reduce-potential-fragmentation-in-make_alloc_exact.patch

This patch will later appear in the mm-unstable branch at
    git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next via the mm-everything
branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there every 2-3 working days

------------------------------------------------------
From: "Liam R. Howlett" <Liam.Howlett@Oracle.com>
Subject: mm/page_alloc: reduce potential fragmentation in make_alloc_exact()
Date: Tue, 31 May 2022 09:20:51 -0400

Try to avoid using the left over split page on the next request for a page
by calling __free_pages_ok() with FPI_TO_TAIL.  This increases the
potential of defragmenting memory when it's used for a short period of
time.

Link: https://lkml.kernel.org/r/20220531185626.yvlmymbxyoe5vags@revolver
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Suggested-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 mm/page_alloc.c |   18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

--- a/mm/page_alloc.c~mm-page_alloc-reduce-potential-fragmentation-in-make_alloc_exact
+++ a/mm/page_alloc.c
@@ -5724,14 +5724,18 @@ static void *make_alloc_exact(unsigned l
 		size_t size)
 {
 	if (addr) {
-		unsigned long alloc_end = addr + (PAGE_SIZE << order);
-		unsigned long used = addr + PAGE_ALIGN(size);
+		unsigned long nr = DIV_ROUND_UP(size, PAGE_SIZE);
+		struct page *page = virt_to_page((void *)addr);
+		struct page *last = page + nr;
 
-		split_page(virt_to_page((void *)addr), order);
-		while (used < alloc_end) {
-			free_page(used);
-			used += PAGE_SIZE;
-		}
+		split_page_owner(page, 1 << order);
+		split_page_memcg(page, 1 << order);
+		while (page < --last)
+			set_page_refcounted(last);
+
+		last = page + (1UL << order);
+		for (page += nr; page < last; page++)
+			__free_pages_ok(page, 0, FPI_TO_TAIL);
 	}
 	return (void *)addr;
 }
_

Patches currently in -mm which might be from Liam.Howlett@Oracle.com are

mips-rename-mt_init-to-mips_mt_init.patch
maple-tree-add-new-data-structure.patch
radix-tree-test-suite-add-pr_err-define.patch
radix-tree-test-suite-add-kmem_cache_set_non_kernel.patch
radix-tree-test-suite-add-allocation-counts-and-size-to-kmem_cache.patch
radix-tree-test-suite-add-support-for-slab-bulk-apis.patch
radix-tree-test-suite-add-lockdep_is_held-to-header.patch
lib-test_maple_tree-add-testing-for-maple-tree.patch
mm-start-tracking-vmas-with-maple-tree.patch
mm-mmap-use-the-maple-tree-in-find_vma-instead-of-the-rbtree.patch
mm-mmap-use-the-maple-tree-for-find_vma_prev-instead-of-the-rbtree.patch
mm-mmap-use-maple-tree-for-unmapped_area_topdown.patch
kernel-fork-use-maple-tree-for-dup_mmap-during-forking.patch
damon-convert-__damon_va_three_regions-to-use-the-vma-iterator.patch
mm-remove-rb-tree.patch
mmap-change-zeroing-of-maple-tree-in-__vma_adjust.patch
xen-use-vma_lookup-in-privcmd_ioctl_mmap.patch
mm-optimize-find_exact_vma-to-use-vma_lookup.patch
mm-khugepaged-optimize-collapse_pte_mapped_thp-by-using-vma_lookup.patch
mm-mmap-change-do_brk_flags-to-expand-existing-vma-and-add-do_brk_munmap.patch
mm-use-maple-tree-operations-for-find_vma_intersection.patch
mm-mmap-use-advanced-maple-tree-api-for-mmap_region.patch
mm-mmap-use-advanced-maple-tree-api-for-mmap_region-fix.patch
mm-remove-vmacache.patch
mm-convert-vma_lookup-to-use-mtree_load.patch
mm-mmap-move-mmap_region-below-do_munmap.patch
mm-mmap-reorganize-munmap-to-use-maple-states.patch
mm-mmap-change-do_brk_munmap-to-use-do_mas_align_munmap.patch
arm64-change-elfcore-for_each_mte_vma-to-use-vma-iterator.patch
fs-proc-base-use-maple-tree-iterators-in-place-of-linked-list.patch
userfaultfd-use-maple-tree-iterator-to-iterate-vmas.patch
ipc-shm-use-vma-iterator-instead-of-linked-list.patch
bpf-remove-vma-linked-list.patch
mm-gup-use-maple-tree-navigation-instead-of-linked-list.patch
mm-madvise-use-vma_find-instead-of-vma-linked-list.patch
mm-memcontrol-stop-using-mm-highest_vm_end.patch
mm-mempolicy-use-vma-iterator-maple-state-instead-of-vma-linked-list.patch
mm-mprotect-use-maple-tree-navigation-instead-of-vma-linked-list.patch
mm-mremap-use-vma_find_intersection-instead-of-vma-linked-list.patch
mm-msync-use-vma_find-instead-of-vma-linked-list.patch
mm-oom_kill-use-maple-tree-iterators-instead-of-vma-linked-list.patch
mm-swapfile-use-vma-iterator-instead-of-vma-linked-list.patch
riscv-use-vma-iterator-for-vdso.patch
mm-remove-the-vma-linked-list.patch
mm-mmap-drop-range_has_overlap-function.patch
mm-mmapc-pass-in-mapping-to-__vma_link_file.patch
mm-page_alloc-reduce-potential-fragmentation-in-make_alloc_exact.patch


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: + mm-page_alloc-reduce-potential-fragmentation-in-make_alloc_exact.patch added to mm-unstable branch
  2022-06-01 20:44 + mm-page_alloc-reduce-potential-fragmentation-in-make_alloc_exact.patch added to mm-unstable branch Andrew Morton
@ 2022-10-19 18:59 ` Matthew Wilcox
  2022-10-19 19:55   ` Andrew Morton
  0 siblings, 1 reply; 5+ messages in thread
From: Matthew Wilcox @ 2022-10-19 18:59 UTC (permalink / raw)
  To: Andrew Morton; +Cc: mm-commits, Liam.Howlett

On Wed, Jun 01, 2022 at 01:44:11PM -0700, Andrew Morton wrote:
> 
> The patch titled
>      Subject: mm/page_alloc: reduce potential fragmentation in make_alloc_exact()
> has been added to the -mm mm-unstable branch.  Its filename is
>      mm-page_alloc-reduce-potential-fragmentation-in-make_alloc_exact.patch

This patch doesn't seem to have made it upstream yet ... what happened?
I don't see it in mm-unstable any more, and I don't have an email saying
that it was dropped.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: + mm-page_alloc-reduce-potential-fragmentation-in-make_alloc_exact.patch added to mm-unstable branch
  2022-10-19 18:59 ` Matthew Wilcox
@ 2022-10-19 19:55   ` Andrew Morton
  2022-10-19 20:16     ` Matthew Wilcox
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Morton @ 2022-10-19 19:55 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: mm-commits, Liam.Howlett

On Wed, 19 Oct 2022 19:59:13 +0100 Matthew Wilcox <willy@infradead.org> wrote:

> On Wed, Jun 01, 2022 at 01:44:11PM -0700, Andrew Morton wrote:
> > 
> > The patch titled
> >      Subject: mm/page_alloc: reduce potential fragmentation in make_alloc_exact()
> > has been added to the -mm mm-unstable branch.  Its filename is
> >      mm-page_alloc-reduce-potential-fragmentation-in-make_alloc_exact.patch
> 
> This patch doesn't seem to have made it upstream yet ... what happened?
> I don't see it in mm-unstable any more, and I don't have an email saying
> that it was dropped.

That was around the time I was transitioning stuff into the git-based
workflow and I guess it got lost in the mayhem.  Thanks, I resurrected
it.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: + mm-page_alloc-reduce-potential-fragmentation-in-make_alloc_exact.patch added to mm-unstable branch
  2022-10-19 19:55   ` Andrew Morton
@ 2022-10-19 20:16     ` Matthew Wilcox
  0 siblings, 0 replies; 5+ messages in thread
From: Matthew Wilcox @ 2022-10-19 20:16 UTC (permalink / raw)
  To: Andrew Morton; +Cc: mm-commits, Liam.Howlett

On Wed, Oct 19, 2022 at 12:55:19PM -0700, Andrew Morton wrote:
> On Wed, 19 Oct 2022 19:59:13 +0100 Matthew Wilcox <willy@infradead.org> wrote:
> 
> > On Wed, Jun 01, 2022 at 01:44:11PM -0700, Andrew Morton wrote:
> > > 
> > > The patch titled
> > >      Subject: mm/page_alloc: reduce potential fragmentation in make_alloc_exact()
> > > has been added to the -mm mm-unstable branch.  Its filename is
> > >      mm-page_alloc-reduce-potential-fragmentation-in-make_alloc_exact.patch
> > 
> > This patch doesn't seem to have made it upstream yet ... what happened?
> > I don't see it in mm-unstable any more, and I don't have an email saying
> > that it was dropped.
> 
> That was around the time I was transitioning stuff into the git-based
> workflow and I guess it got lost in the mayhem.  Thanks, I resurrected
> it.

Thanks.  We may need to get it to Linus soon.  This patch was required
to make some nommu platforms work with the maple tree as the current
code ends up fragmenting memory to the point that it can no longer run
executables.  I haven't seen any bug reports yet, but I can imagine that
nommu is much more lightly tested than many other configs.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* + mm-page_alloc-reduce-potential-fragmentation-in-make_alloc_exact.patch added to mm-unstable branch
@ 2022-10-19 19:55 Andrew Morton
  0 siblings, 0 replies; 5+ messages in thread
From: Andrew Morton @ 2022-10-19 19:55 UTC (permalink / raw)
  To: mm-commits, willy, Liam.Howlett, Liam.Howlett, akpm


The patch titled
     Subject: mm/page_alloc: reduce potential fragmentation in make_alloc_exact()
has been added to the -mm mm-unstable branch.  Its filename is
     mm-page_alloc-reduce-potential-fragmentation-in-make_alloc_exact.patch

This patch will shortly appear at
     https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-page_alloc-reduce-potential-fragmentation-in-make_alloc_exact.patch

This patch will later appear in the mm-unstable branch at
    git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next via the mm-everything
branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there every 2-3 working days

------------------------------------------------------
From: "Liam R. Howlett" <Liam.Howlett@Oracle.com>
Subject: mm/page_alloc: reduce potential fragmentation in make_alloc_exact()
Date: Tue, 31 May 2022 09:20:51 -0400

Try to avoid using the left over split page on the next request for a page
by calling __free_pages_ok() with FPI_TO_TAIL.  This increases the
potential of defragmenting memory when it's used for a short period of
time.

Link: https://lkml.kernel.org/r/20220531185626.yvlmymbxyoe5vags@revolver
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Suggested-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 mm/page_alloc.c |   18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

--- a/mm/page_alloc.c~mm-page_alloc-reduce-potential-fragmentation-in-make_alloc_exact
+++ a/mm/page_alloc.c
@@ -5784,14 +5784,18 @@ static void *make_alloc_exact(unsigned l
 		size_t size)
 {
 	if (addr) {
-		unsigned long alloc_end = addr + (PAGE_SIZE << order);
-		unsigned long used = addr + PAGE_ALIGN(size);
+		unsigned long nr = DIV_ROUND_UP(size, PAGE_SIZE);
+		struct page *page = virt_to_page((void *)addr);
+		struct page *last = page + nr;
 
-		split_page(virt_to_page((void *)addr), order);
-		while (used < alloc_end) {
-			free_page(used);
-			used += PAGE_SIZE;
-		}
+		split_page_owner(page, 1 << order);
+		split_page_memcg(page, 1 << order);
+		while (page < --last)
+			set_page_refcounted(last);
+
+		last = page + (1UL << order);
+		for (page += nr; page < last; page++)
+			__free_pages_ok(page, 0, FPI_TO_TAIL);
 	}
 	return (void *)addr;
 }
_

Patches currently in -mm which might be from Liam.Howlett@Oracle.com are

mm-page_alloc-reduce-potential-fragmentation-in-make_alloc_exact.patch


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-10-19 20:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-01 20:44 + mm-page_alloc-reduce-potential-fragmentation-in-make_alloc_exact.patch added to mm-unstable branch Andrew Morton
2022-10-19 18:59 ` Matthew Wilcox
2022-10-19 19:55   ` Andrew Morton
2022-10-19 20:16     ` Matthew Wilcox
2022-10-19 19:55 Andrew Morton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.