mirror of
https://github.com/torvalds/linux.git
synced 2025-08-15 14:11:42 +02:00
kdump: wait for DMA to finish when using CMA
When re-using the CMA area for kdump there is a risk of pending DMA into pinned user pages in the CMA area. Pages residing in CMA areas can usually not get long-term pinned and are instead migrated away from the CMA area, so long-term pinning is typically not a concern. (BUGs in the kernel might still lead to long-term pinning of such pages if everything goes wrong.) Pages pinned without FOLL_LONGTERM remain in the CMA and may possibly be the source or destination of a pending DMA transfer. Although there is no clear specification how long a page may be pinned without FOLL_LONGTERM, pinning without the flag shows an intent of the caller to only use the memory for short-lived DMA transfers, not a transfer initiated by a device asynchronously at a random time in the future. Add a delay of CMA_DMA_TIMEOUT_SEC seconds before starting the kdump kernel, giving such short-lived DMA transfers time to finish before the CMA memory is re-used by the kdump kernel. Set CMA_DMA_TIMEOUT_SEC to 10 seconds - chosen arbitrarily as both a huge margin for a DMA transfer, yet not increasing the kdump time too significantly. Link: https://lkml.kernel.org/r/aEqpgDIBndZ5LXSo@dwarf.suse.cz Signed-off-by: Jiri Bohac <jbohac@suse.cz> Acked-by: David Hildenbrand <david@redhat.com> Cc: Baoquan He <bhe@redhat.com> Cc: Dave Young <dyoung@redhat.com> Cc: Donald Dutile <ddutile@redhat.com> Cc: Michal Hocko <mhocko@suse.cz> Cc: Philipp Rudo <prudo@redhat.com> Cc: Pingfan Liu <piliu@redhat.com> Cc: Tao Liu <ltao@redhat.com> Cc: Vivek Goyal <vgoyal@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
ce1bf19a34
commit
e1280f3071
1 changed files with 15 additions and 0 deletions
|
@ -21,6 +21,7 @@
|
||||||
#include <linux/reboot.h>
|
#include <linux/reboot.h>
|
||||||
#include <linux/btf.h>
|
#include <linux/btf.h>
|
||||||
#include <linux/objtool.h>
|
#include <linux/objtool.h>
|
||||||
|
#include <linux/delay.h>
|
||||||
|
|
||||||
#include <asm/page.h>
|
#include <asm/page.h>
|
||||||
#include <asm/sections.h>
|
#include <asm/sections.h>
|
||||||
|
@ -33,6 +34,11 @@
|
||||||
/* Per cpu memory for storing cpu states in case of system crash. */
|
/* Per cpu memory for storing cpu states in case of system crash. */
|
||||||
note_buf_t __percpu *crash_notes;
|
note_buf_t __percpu *crash_notes;
|
||||||
|
|
||||||
|
/* time to wait for possible DMA to finish before starting the kdump kernel
|
||||||
|
* when a CMA reservation is used
|
||||||
|
*/
|
||||||
|
#define CMA_DMA_TIMEOUT_SEC 10
|
||||||
|
|
||||||
#ifdef CONFIG_CRASH_DUMP
|
#ifdef CONFIG_CRASH_DUMP
|
||||||
|
|
||||||
int kimage_crash_copy_vmcoreinfo(struct kimage *image)
|
int kimage_crash_copy_vmcoreinfo(struct kimage *image)
|
||||||
|
@ -97,6 +103,14 @@ int kexec_crash_loaded(void)
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(kexec_crash_loaded);
|
EXPORT_SYMBOL_GPL(kexec_crash_loaded);
|
||||||
|
|
||||||
|
static void crash_cma_clear_pending_dma(void)
|
||||||
|
{
|
||||||
|
if (!crashk_cma_cnt)
|
||||||
|
return;
|
||||||
|
|
||||||
|
mdelay(CMA_DMA_TIMEOUT_SEC * 1000);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* No panic_cpu check version of crash_kexec(). This function is called
|
* No panic_cpu check version of crash_kexec(). This function is called
|
||||||
* only when panic_cpu holds the current CPU number; this is the only CPU
|
* only when panic_cpu holds the current CPU number; this is the only CPU
|
||||||
|
@ -119,6 +133,7 @@ void __noclone __crash_kexec(struct pt_regs *regs)
|
||||||
crash_setup_regs(&fixed_regs, regs);
|
crash_setup_regs(&fixed_regs, regs);
|
||||||
crash_save_vmcoreinfo();
|
crash_save_vmcoreinfo();
|
||||||
machine_crash_shutdown(&fixed_regs);
|
machine_crash_shutdown(&fixed_regs);
|
||||||
|
crash_cma_clear_pending_dma();
|
||||||
machine_kexec(kexec_crash_image);
|
machine_kexec(kexec_crash_image);
|
||||||
}
|
}
|
||||||
kexec_unlock();
|
kexec_unlock();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue