lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CANaxB-zB6Qs_AYCJCQNC3ekx+DMoXoHB4Yq-uMBm7qs-bMPv4A@mail.gmail.com>
Date: Fri, 9 Feb 2024 12:29:58 -0800
From: Andrei Vagin <avagin@...il.com>
To: Muhammad Usama Anjum <usama.anjum@...labora.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>, Paul Gofman <pgofman@...eweavers.com>, 
	kernel@...labora.com, Michał Mirosław <emmir@...gle.com>, 
	linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] mm/migrate: preserve exact soft-dirty state

On Tue, Feb 6, 2024 at 12:48 AM Muhammad Usama Anjum
<usama.anjum@...labora.com> wrote:
>
> From: Paul Gofman <pgofman@...eweavers.com>
>
> pte_mkdirty() sets both _PAGE_DIRTY and _PAGE_SOFT_DIRTY bits. The
> _PAGE_SOFT_DIRTY can get set even if it wasn't set on original page
> before migration. This makes non-soft-dirty pages soft-dirty just
> because of migration/compaction. Clear the _PAGE_SOFT_DIRTY flag if
> it wasn't set on original page.
>
> By definition of soft-dirty feature, there can be spurious soft-dirty
> pages because of kernel's internal activity such as VMA merging or
> migration/compaction. This patch is eliminating the spurious soft-dirty
> pages because of migration/compaction.
>
> Cc: Michał Mirosław <emmir@...gle.com>
> Cc: Andrei Vagin <avagin@...il.com>

Acked-by: Andrei Vagin <avagin@...il.com>

> Signed-off-by: Paul Gofman <pgofman@...eweavers.com>
> Signed-off-by: Muhammad Usama Anjum <usama.anjum@...labora.com>
> ---
>  mm/migrate.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/mm/migrate.c b/mm/migrate.c
> index cc9f2bcd73b4..05d6ca437321 100644
> --- a/mm/migrate.c
> +++ b/mm/migrate.c
> @@ -211,14 +211,17 @@ static bool remove_migration_pte(struct folio *folio,
>                 folio_get(folio);
>                 pte = mk_pte(new, READ_ONCE(vma->vm_page_prot));
>                 old_pte = ptep_get(pvmw.pte);
> -               if (pte_swp_soft_dirty(old_pte))
> -                       pte = pte_mksoft_dirty(pte);
>
>                 entry = pte_to_swp_entry(old_pte);
>                 if (!is_migration_entry_young(entry))
>                         pte = pte_mkold(pte);
>                 if (folio_test_dirty(folio) && is_migration_entry_dirty(entry))
>                         pte = pte_mkdirty(pte);
> +               if (pte_swp_soft_dirty(old_pte))
> +                       pte = pte_mksoft_dirty(pte);
> +               else
> +                       pte = pte_clear_soft_dirty(pte);
> +
>                 if (is_writable_migration_entry(entry))
>                         pte = pte_mkwrite(pte, vma);
>                 else if (pte_swp_uffd_wp(old_pte))
> --
> 2.42.0
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ