[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240627155425.a31792e7c4709facfcbd417c@linux-foundation.org>
Date: Thu, 27 Jun 2024 15:54:25 -0700
From: Andrew Morton <akpm@...ux-foundation.org>
To: Yang Shi <yang@...amperecomputing.com>
Cc: peterx@...hat.com, yangge1116@....com, david@...hat.com,
linux-mm@...ck.org, linux-kernel@...r.kernel.org, stable@...r.kernel.org,
Vivek Kasireddy <vivek.kasireddy@...el.com>
Subject: Re: [v2 PATCH] mm: gup: do not call try_grab_folio() in slow path
On Thu, 27 Jun 2024 15:14:13 -0700 Yang Shi <yang@...amperecomputing.com> wrote:
> The try_grab_folio() is supposed to be used in fast path and it elevates
> folio refcount by using add ref unless zero. We are guaranteed to have
> at least one stable reference in slow path, so the simple atomic add
> could be used. The performance difference should be trivial, but the
> misuse may be confusing and misleading.
>
> In another thread [1] a kernel warning was reported when pinning folio
> in CMA memory when launching SEV virtual machine. The splat looks like:
>
> [ 464.325306] WARNING: CPU: 13 PID: 6734 at mm/gup.c:1313 __get_user_pages+0x423/0x520
> [ 464.325464] CPU: 13 PID: 6734 Comm: qemu-kvm Kdump: loaded Not tainted 6.6.33+ #6
> [ 464.325477] RIP: 0010:__get_user_pages+0x423/0x520
> [ 464.325515] Call Trace:
> [ 464.325520] <TASK>
> [ 464.325523] ? __get_user_pages+0x423/0x520
> [ 464.325528] ? __warn+0x81/0x130
> [ 464.325536] ? __get_user_pages+0x423/0x520
> [ 464.325541] ? report_bug+0x171/0x1a0
> [ 464.325549] ? handle_bug+0x3c/0x70
> [ 464.325554] ? exc_invalid_op+0x17/0x70
> [ 464.325558] ? asm_exc_invalid_op+0x1a/0x20
> [ 464.325567] ? __get_user_pages+0x423/0x520
> [ 464.325575] __gup_longterm_locked+0x212/0x7a0
> [ 464.325583] internal_get_user_pages_fast+0xfb/0x190
> [ 464.325590] pin_user_pages_fast+0x47/0x60
> [ 464.325598] sev_pin_memory+0xca/0x170 [kvm_amd]
> [ 464.325616] sev_mem_enc_register_region+0x81/0x130 [kvm_amd]
>
> ...
>
> Fixes: 57edfcfd3419 ("mm/gup: accelerate thp gup even for "pages != NULL"")
> Cc: <stable@...r.kernel.org> [6.6+]
So we want something against Linus mainline for backporting ease.
> 3. Rebased onto the latest mm-unstable
mm-unstable is quite different - memfd_pin_folios() doesn't exist in
mainline!
So can you please prepare the fix against current -linus? I'll hang
onto this patch to guide myself when I redo Vivek's "mm/gup: Introduce
memfd_pin_folios() for pinning memfd folios" series on top.
Powered by blists - more mailing lists