From: Lino Sanfilippo <LinoSanfilippo(a)gmx.de>
Several drivers that support setting the RS485 configuration via userspace
implement one or more of the following tasks:
- in case of an invalid RTS configuration (both RTS after send and RTS on
send set or both unset) fall back to enable RTS on send and disable RTS
after send
- nullify the padding field of the returned serial_rs485 struct
- copy the configuration into the uart port struct
- limit RTS delays to 100 ms
Move these tasks into the serial core to make them generic and to provide
a consistent behaviour among all drivers.
Signed-off-by: Lino Sanfilippo <LinoSanfilippo(a)gmx.de>
Link: https://lore.kernel.org/r/20220410104642.32195-2-LinoSanfilippo@gmx.de
Signed-off-by: Greg Kroah-Hartman <gregkh(a)linuxfoundation.org>
[ Upstream commit 0ed12afa5655512ee418047fb3546d229df20aa1 ]
Signed-off-by: Daisuke Mizobuchi <mizo(a)atmark-techno.com>
Signed-off-by: Dominique Martinet <dominique.martinet(a)atmark-techno.com>
---
Follow-up of https://lkml.kernel.org/r/20221017013807.34614-1-dominique.martinet@atmark-…
v2: identical to v1
drivers/tty/serial/serial_core.c | 33 ++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index b578f7090b63..6cc909d44a81 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -42,6 +42,11 @@ static struct lock_class_key port_lock_key;
#define HIGH_BITS_OFFSET ((sizeof(long)-sizeof(int))*8)
+/*
+ * Max time with active RTS before/after data is sent.
+ */
+#define RS485_MAX_RTS_DELAY 100 /* msecs */
+
static void uart_change_speed(struct tty_struct *tty, struct uart_state *state,
struct ktermios *old_termios);
static void uart_wait_until_sent(struct tty_struct *tty, int timeout);
@@ -1326,8 +1331,36 @@ static int uart_set_rs485_config(struct uart_port *port,
if (copy_from_user(&rs485, rs485_user, sizeof(*rs485_user)))
return -EFAULT;
+ /* pick sane settings if the user hasn't */
+ if (!(rs485.flags & SER_RS485_RTS_ON_SEND) ==
+ !(rs485.flags & SER_RS485_RTS_AFTER_SEND)) {
+ dev_warn_ratelimited(port->dev,
+ "%s (%d): invalid RTS setting, using RTS_ON_SEND instead\n",
+ port->name, port->line);
+ rs485.flags |= SER_RS485_RTS_ON_SEND;
+ rs485.flags &= ~SER_RS485_RTS_AFTER_SEND;
+ }
+
+ if (rs485.delay_rts_before_send > RS485_MAX_RTS_DELAY) {
+ rs485.delay_rts_before_send = RS485_MAX_RTS_DELAY;
+ dev_warn_ratelimited(port->dev,
+ "%s (%d): RTS delay before sending clamped to %u ms\n",
+ port->name, port->line, rs485.delay_rts_before_send);
+ }
+
+ if (rs485.delay_rts_after_send > RS485_MAX_RTS_DELAY) {
+ rs485.delay_rts_after_send = RS485_MAX_RTS_DELAY;
+ dev_warn_ratelimited(port->dev,
+ "%s (%d): RTS delay after sending clamped to %u ms\n",
+ port->name, port->line, rs485.delay_rts_after_send);
+ }
+ /* Return clean padding area to userspace */
+ memset(rs485.padding, 0, sizeof(rs485.padding));
+
spin_lock_irqsave(&port->lock, flags);
ret = port->rs485_config(port, &rs485);
+ if (!ret)
+ port->rs485 = rs485;
spin_unlock_irqrestore(&port->lock, flags);
if (ret)
return ret;
--
2.35.1
This is the start of the stable review cycle for the 5.4.221 release.
There are 53 patches in this series, all will be posted as a response
to this one. If anyone has any issues with these being applied, please
let me know.
Responses should be made by Sat, 29 Oct 2022 16:50:35 +0000.
Anything received after that time might be too late.
The whole patch series can be found in one patch at:
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.4.221-rc…
or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-5.4.y
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <gregkh(a)linuxfoundation.org>
Linux 5.4.221-rc1
Seth Jenkins <sethjenkins(a)google.com>
mm: /proc/pid/smaps_rollup: fix no vma's null-deref
Gaurav Kohli <gauravkohli(a)linux.microsoft.com>
hv_netvsc: Fix race between VF offering and VF association message from host
Nick Desaulniers <ndesaulniers(a)google.com>
Makefile.debug: re-enable debug info for .S files
Werner Sembach <wse(a)tuxedocomputers.com>
ACPI: video: Force backlight native for more TongFang devices
Conor Dooley <conor.dooley(a)microchip.com>
riscv: topology: fix default topology reporting
Conor Dooley <conor.dooley(a)microchip.com>
arm64: topology: move store_cpu_topology() to shared code
Jerry Snitselaar <jsnitsel(a)redhat.com>
iommu/vt-d: Clean up si_domain in the init_dmars() error path
Yang Yingliang <yangyingliang(a)huawei.com>
net: hns: fix possible memory leak in hnae_ae_register()
Zhengchao Shao <shaozhengchao(a)huawei.com>
net: sched: cake: fix null pointer access issue when cake_init() fails
Harini Katakam <harini.katakam(a)amd.com>
net: phy: dp83867: Extend RX strap quirk for SGMII mode
Xiaobo Liu <cppcoffee(a)gmail.com>
net/atm: fix proc_mpc_write incorrect return value
José Expósito <jose.exposito89(a)gmail.com>
HID: magicmouse: Do not set BTN_MOUSE on double report
Alexander Potapenko <glider(a)google.com>
tipc: fix an information leak in tipc_topsrv_kern_subscr
Mark Tomlinson <mark.tomlinson(a)alliedtelesis.co.nz>
tipc: Fix recognition of trial period
Tony Luck <tony.luck(a)intel.com>
ACPI: extlog: Handle multiple records
Filipe Manana <fdmanana(a)suse.com>
btrfs: fix processing of delayed tree block refs during backref walking
Filipe Manana <fdmanana(a)suse.com>
btrfs: fix processing of delayed data refs during backref walking
Jean-Francois Le Fillatre <jflf_kernel(a)gmx.com>
r8152: add PID for the Lenovo OneLink+ Dock
James Morse <james.morse(a)arm.com>
arm64: errata: Remove AES hwcap for COMPAT tasks
Bryan O'Donoghue <bryan.odonoghue(a)linaro.org>
media: venus: dec: Handle the case where find_format fails
Eric Ren <renzhengeek(a)gmail.com>
KVM: arm64: vgic: Fix exit condition in scan_its_table()
Kai-Heng Feng <kai.heng.feng(a)canonical.com>
ata: ahci: Match EM_MAX_SLOTS with SATA_PMP_MAX_PORTS
Alexander Stein <alexander.stein(a)ew.tq-group.com>
ata: ahci-imx: Fix MODULE_ALIAS
Zhang Rui <rui.zhang(a)intel.com>
hwmon/coretemp: Handle large core ID value
Borislav Petkov <bp(a)suse.de>
x86/microcode/AMD: Apply the patch early on every logical thread
Joseph Qi <joseph.qi(a)linux.alibaba.com>
ocfs2: fix BUG when iput after ocfs2_mknod fails
Joseph Qi <joseph.qi(a)linux.alibaba.com>
ocfs2: clear dinode links count in case of error
Dave Chinner <dchinner(a)redhat.com>
xfs: fix use-after-free on CIL context on shutdown
Darrick J. Wong <darrick.wong(a)oracle.com>
xfs: move inode flush to the sync workqueue
Christoph Hellwig <hch(a)lst.de>
xfs: reflink should force the log out if mounted with wsync
Christoph Hellwig <hch(a)lst.de>
xfs: factor out a new xfs_log_force_inode helper
Brian Foster <bfoster(a)redhat.com>
xfs: trylock underlying buffer on dquot flush
Darrick J. Wong <darrick.wong(a)oracle.com>
xfs: don't write a corrupt unmount record to force summary counter recalc
Dave Chinner <dchinner(a)redhat.com>
xfs: tail updates only need to occur when LSN changes
Dave Chinner <dchinner(a)redhat.com>
xfs: factor common AIL item deletion code
Dave Chinner <dchinner(a)redhat.com>
xfs: Throttle commits on delayed background CIL push
Dave Chinner <dchinner(a)redhat.com>
xfs: Lower CIL flush limit for large logs
Darrick J. Wong <darrick.wong(a)oracle.com>
xfs: preserve default grace interval during quotacheck
Brian Foster <bfoster(a)redhat.com>
xfs: fix unmount hang and memory leak on shutdown during quotaoff
Brian Foster <bfoster(a)redhat.com>
xfs: factor out quotaoff intent AIL removal and memory free
Pavel Reichl <preichl(a)redhat.com>
xfs: Replace function declaration by actual definition
Pavel Reichl <preichl(a)redhat.com>
xfs: remove the xfs_qoff_logitem_t typedef
Pavel Reichl <preichl(a)redhat.com>
xfs: remove the xfs_dq_logitem_t typedef
Pavel Reichl <preichl(a)redhat.com>
xfs: remove the xfs_disk_dquot_t and xfs_dquot_t
Takashi Iwai <tiwai(a)suse.de>
xfs: Use scnprintf() for avoiding potential buffer overflow
Darrick J. Wong <darrick.wong(a)oracle.com>
xfs: check owner of dir3 blocks
Darrick J. Wong <darrick.wong(a)oracle.com>
xfs: check owner of dir3 data blocks
Darrick J. Wong <darrick.wong(a)oracle.com>
xfs: fix buffer corruption reporting when xfs_dir3_free_header_check fails
Darrick J. Wong <darrick.wong(a)oracle.com>
xfs: xfs_buf_corruption_error should take __this_address
Darrick J. Wong <darrick.wong(a)oracle.com>
xfs: add a function to deal with corrupt buffers post-verifiers
Brian Foster <bfoster(a)redhat.com>
xfs: rework collapse range into an atomic operation
Brian Foster <bfoster(a)redhat.com>
xfs: rework insert range into an atomic operation
Brian Foster <bfoster(a)redhat.com>
xfs: open code insert range extent split helper
-------------
Diffstat:
Documentation/arm64/silicon-errata.rst | 4 +
Makefile | 8 +-
arch/arm64/Kconfig | 16 ++++
arch/arm64/include/asm/cpucaps.h | 3 +-
arch/arm64/kernel/cpu_errata.c | 16 ++++
arch/arm64/kernel/cpufeature.c | 13 ++-
arch/arm64/kernel/topology.c | 40 ---------
arch/riscv/Kconfig | 2 +-
arch/riscv/kernel/smpboot.c | 4 +-
arch/x86/kernel/cpu/microcode/amd.c | 16 +++-
drivers/acpi/acpi_extlog.c | 33 ++++---
drivers/acpi/video_detect.c | 64 ++++++++++++++
drivers/ata/ahci.h | 2 +-
drivers/ata/ahci_imx.c | 2 +-
drivers/base/arch_topology.c | 19 ++++
drivers/hid/hid-magicmouse.c | 2 +-
drivers/hwmon/coretemp.c | 56 ++++++++----
drivers/iommu/intel-iommu.c | 5 ++
drivers/media/platform/qcom/venus/vdec.c | 2 +
drivers/net/ethernet/hisilicon/hns/hnae.c | 4 +-
drivers/net/hyperv/hyperv_net.h | 3 +
drivers/net/hyperv/netvsc.c | 4 +
drivers/net/hyperv/netvsc_drv.c | 20 +++++
drivers/net/phy/dp83867.c | 8 ++
drivers/net/usb/cdc_ether.c | 7 ++
drivers/net/usb/r8152.c | 1 +
fs/btrfs/backref.c | 46 ++++++----
fs/ocfs2/namei.c | 23 +++--
fs/proc/task_mmu.c | 2 +-
fs/xfs/libxfs/xfs_alloc.c | 2 +-
fs/xfs/libxfs/xfs_attr_leaf.c | 6 +-
fs/xfs/libxfs/xfs_bmap.c | 32 +------
fs/xfs/libxfs/xfs_bmap.h | 3 +-
fs/xfs/libxfs/xfs_btree.c | 2 +-
fs/xfs/libxfs/xfs_da_btree.c | 10 +--
fs/xfs/libxfs/xfs_dir2_block.c | 33 ++++++-
fs/xfs/libxfs/xfs_dir2_data.c | 32 ++++++-
fs/xfs/libxfs/xfs_dir2_leaf.c | 2 +-
fs/xfs/libxfs/xfs_dir2_node.c | 8 +-
fs/xfs/libxfs/xfs_dquot_buf.c | 8 +-
fs/xfs/libxfs/xfs_format.h | 10 +--
fs/xfs/libxfs/xfs_trans_resv.c | 6 +-
fs/xfs/xfs_attr_inactive.c | 6 +-
fs/xfs/xfs_attr_list.c | 2 +-
fs/xfs/xfs_bmap_util.c | 57 ++++++------
fs/xfs/xfs_buf.c | 22 +++++
fs/xfs/xfs_buf.h | 2 +
fs/xfs/xfs_dquot.c | 26 +++---
fs/xfs/xfs_dquot.h | 98 +++++++++++----------
fs/xfs/xfs_dquot_item.c | 47 +++++++---
fs/xfs/xfs_dquot_item.h | 35 ++++----
fs/xfs/xfs_error.c | 7 +-
fs/xfs/xfs_error.h | 2 +-
fs/xfs/xfs_export.c | 14 +--
fs/xfs/xfs_file.c | 16 ++--
fs/xfs/xfs_inode.c | 23 ++++-
fs/xfs/xfs_inode.h | 1 +
fs/xfs/xfs_inode_item.c | 28 +++---
fs/xfs/xfs_log.c | 26 +++---
fs/xfs/xfs_log_cil.c | 39 ++++++--
fs/xfs/xfs_log_priv.h | 53 +++++++++--
fs/xfs/xfs_log_recover.c | 5 +-
fs/xfs/xfs_mount.h | 5 ++
fs/xfs/xfs_qm.c | 64 ++++++++------
fs/xfs/xfs_qm_bhv.c | 6 +-
fs/xfs/xfs_qm_syscalls.c | 142 +++++++++++++++---------------
fs/xfs/xfs_stats.c | 10 +--
fs/xfs/xfs_super.c | 28 ++++--
fs/xfs/xfs_trace.h | 1 +
fs/xfs/xfs_trans_ail.c | 88 +++++++++++-------
fs/xfs/xfs_trans_dquot.c | 54 ++++++------
fs/xfs/xfs_trans_priv.h | 6 +-
net/atm/mpoa_proc.c | 3 +-
net/sched/sch_cake.c | 4 +
net/tipc/discover.c | 2 +-
net/tipc/topsrv.c | 2 +-
virt/kvm/arm/vgic/vgic-its.c | 5 +-
77 files changed, 973 insertions(+), 535 deletions(-)
Your email was luckly selected to received a donation of 10 BTC (BITCOIN) equal to 4,124,270.00 from Elon Musk.
Urgently email us: (teamelonmusk94(a)gmail.com).
The quilt patch titled
Subject: hugetlb: don't delete vma_lock in hugetlb MADV_DONTNEED processing
has been removed from the -mm tree. Its filename was
hugetlb-dont-delete-vma_lock-in-hugetlb-madv_dontneed-processing.patch
This patch was dropped because an updated version will be merged
------------------------------------------------------
From: Mike Kravetz <mike.kravetz(a)oracle.com>
Subject: hugetlb: don't delete vma_lock in hugetlb MADV_DONTNEED processing
Date: Sat, 22 Oct 2022 19:50:47 -0700
madvise(MADV_DONTNEED) ends up calling zap_page_range() to clear the page
tables associated with the address range. For hugetlb vmas,
zap_page_range will call __unmap_hugepage_range_final. However,
__unmap_hugepage_range_final assumes the passed vma is about to be removed
and deletes the vma_lock to prevent pmd sharing as the vma is on the way
out. In the case of madvise(MADV_DONTNEED) the vma remains, but the
missing vma_lock prevents pmd sharing and could potentially lead to issues
with truncation/fault races.
This issue was originally reported here [1] as a BUG triggered in
page_try_dup_anon_rmap. Prior to the introduction of the hugetlb
vma_lock, __unmap_hugepage_range_final cleared the VM_MAYSHARE flag to
prevent pmd sharing. Subsequent faults on this vma were confused as
VM_MAYSHARE indicates a sharable vma, but was not set so page_mapping was
not set in new pages added to the page table. This resulted in pages that
appeared anonymous in a VM_SHARED vma and triggered the BUG.
Create a new routine clear_hugetlb_page_range() that can be called from
madvise(MADV_DONTNEED) for hugetlb vmas. It has the same setup as
zap_page_range, but does not delete the vma_lock.
[1] https://lore.kernel.org/lkml/CAO4mrfdLMXsao9RF4fUE8-Wfde8xmjsKrTNMNC9wjUb6J…
Link: https://lkml.kernel.org/r/20221023025047.470646-1-mike.kravetz@oracle.com
Fixes: 90e7e7f5ef3f ("mm: enable MADV_DONTNEED for hugetlb mappings")
Signed-off-by: Mike Kravetz <mike.kravetz(a)oracle.com>
Reported-by: Wei Chen <harperchen1110(a)gmail.com>
Cc: Axel Rasmussen <axelrasmussen(a)google.com>
Cc: David Hildenbrand <david(a)redhat.com>
Cc: Matthew Wilcox (Oracle) <willy(a)infradead.org>
Cc: Mike Kravetz <mike.kravetz(a)oracle.com>
Cc: Mina Almasry <almasrymina(a)google.com>
Cc: Naoya Horiguchi <naoya.horiguchi(a)linux.dev>
Cc: Peter Xu <peterx(a)redhat.com>
Cc: Rik van Riel <riel(a)surriel.com>
Cc: Vlastimil Babka <vbabka(a)suse.cz>
Cc: <stable(a)vger.kernel.org>
Signed-off-by: Andrew Morton <akpm(a)linux-foundation.org>
---
include/linux/hugetlb.h | 7 ++++
mm/hugetlb.c | 62 ++++++++++++++++++++++++++++++--------
mm/madvise.c | 5 ++-
3 files changed, 61 insertions(+), 13 deletions(-)
--- a/include/linux/hugetlb.h~hugetlb-dont-delete-vma_lock-in-hugetlb-madv_dontneed-processing
+++ a/include/linux/hugetlb.h
@@ -156,6 +156,8 @@ long follow_hugetlb_page(struct mm_struc
void unmap_hugepage_range(struct vm_area_struct *,
unsigned long, unsigned long, struct page *,
zap_flags_t);
+void clear_hugetlb_page_range(struct vm_area_struct *vma,
+ unsigned long start, unsigned long end);
void __unmap_hugepage_range_final(struct mmu_gather *tlb,
struct vm_area_struct *vma,
unsigned long start, unsigned long end,
@@ -460,6 +462,11 @@ static inline void __unmap_hugepage_rang
BUG();
}
+static void __maybe_unused clear_hugetlb_page_range(struct vm_area_struct *vma,
+ unsigned long start, unsigned long end)
+{
+}
+
static inline vm_fault_t hugetlb_fault(struct mm_struct *mm,
struct vm_area_struct *vma, unsigned long address,
unsigned int flags)
--- a/mm/hugetlb.c~hugetlb-dont-delete-vma_lock-in-hugetlb-madv_dontneed-processing
+++ a/mm/hugetlb.c
@@ -5194,28 +5194,66 @@ static void __unmap_hugepage_range(struc
tlb_flush_mmu_tlbonly(tlb);
}
-void __unmap_hugepage_range_final(struct mmu_gather *tlb,
+static void __unmap_hugepage_range_locking(struct mmu_gather *tlb,
struct vm_area_struct *vma, unsigned long start,
unsigned long end, struct page *ref_page,
- zap_flags_t zap_flags)
+ zap_flags_t zap_flags, bool final)
{
hugetlb_vma_lock_write(vma);
i_mmap_lock_write(vma->vm_file->f_mapping);
__unmap_hugepage_range(tlb, vma, start, end, ref_page, zap_flags);
- /*
- * Unlock and free the vma lock before releasing i_mmap_rwsem. When
- * the vma_lock is freed, this makes the vma ineligible for pmd
- * sharing. And, i_mmap_rwsem is required to set up pmd sharing.
- * This is important as page tables for this unmapped range will
- * be asynchrously deleted. If the page tables are shared, there
- * will be issues when accessed by someone else.
- */
- __hugetlb_vma_unlock_write_free(vma);
+ if (final) {
+ /*
+ * Unlock and free the vma lock before releasing i_mmap_rwsem.
+ * When the vma_lock is freed, this makes the vma ineligible
+ * for pmd sharing. And, i_mmap_rwsem is required to set up
+ * pmd sharing. This is important as page tables for this
+ * unmapped range will be asynchrously deleted. If the page
+ * tables are shared, there will be issues when accessed by
+ * someone else.
+ */
+ __hugetlb_vma_unlock_write_free(vma);
+ i_mmap_unlock_write(vma->vm_file->f_mapping);
+ } else {
+ i_mmap_unlock_write(vma->vm_file->f_mapping);
+ hugetlb_vma_unlock_write(vma);
+ }
+}
+
+void __unmap_hugepage_range_final(struct mmu_gather *tlb,
+ struct vm_area_struct *vma, unsigned long start,
+ unsigned long end, struct page *ref_page,
+ zap_flags_t zap_flags)
+{
+ __unmap_hugepage_range_locking(tlb, vma, start, end, ref_page,
+ zap_flags, true);
+}
+
+#ifdef CONFIG_ADVISE_SYSCALLS
+/*
+ * Similar setup as in zap_page_range(). madvise(MADV_DONTNEED) can not call
+ * zap_page_range for hugetlb vmas as __unmap_hugepage_range_final will delete
+ * the associated vma_lock.
+ */
+void clear_hugetlb_page_range(struct vm_area_struct *vma, unsigned long start,
+ unsigned long end)
+{
+ struct mmu_notifier_range range;
+ struct mmu_gather tlb;
+
+ mmu_notifier_range_init(&range, MMU_NOTIFY_CLEAR, 0, vma, vma->vm_mm,
+ start, end);
+ tlb_gather_mmu(&tlb, vma->vm_mm);
+ update_hiwater_rss(vma->vm_mm);
+
+ __unmap_hugepage_range_locking(&tlb, vma, start, end, NULL, 0, false);
- i_mmap_unlock_write(vma->vm_file->f_mapping);
+ mmu_notifier_invalidate_range_end(&range);
+ tlb_finish_mmu(&tlb);
}
+#endif
void unmap_hugepage_range(struct vm_area_struct *vma, unsigned long start,
unsigned long end, struct page *ref_page,
--- a/mm/madvise.c~hugetlb-dont-delete-vma_lock-in-hugetlb-madv_dontneed-processing
+++ a/mm/madvise.c
@@ -790,7 +790,10 @@ static int madvise_free_single_vma(struc
static long madvise_dontneed_single_vma(struct vm_area_struct *vma,
unsigned long start, unsigned long end)
{
- zap_page_range(vma, start, end - start);
+ if (!is_vm_hugetlb_page(vma))
+ zap_page_range(vma, start, end - start);
+ else
+ clear_hugetlb_page_range(vma, start, end);
return 0;
}
_
Patches currently in -mm which might be from mike.kravetz(a)oracle.com are
hugetlb-simplify-hugetlb-handling-in-follow_page_mask.patch
hugetlb-simplify-hugetlb-handling-in-follow_page_mask-v4.patch
The quilt patch titled
Subject: mm: migrate: fix return value if all subpages of THPs are migrated successfully
has been removed from the -mm tree. Its filename was
mm-migrate-fix-return-value-if-all-subpages-of-thps-are-migrated-successfully.patch
This patch was dropped because it was merged into the mm-hotfixes-stable branch
of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: Baolin Wang <baolin.wang(a)linux.alibaba.com>
Subject: mm: migrate: fix return value if all subpages of THPs are migrated successfully
Date: Mon, 24 Oct 2022 16:34:21 +0800
During THP migration, if THPs are not migrated but they are split and all
subpages are migrated successfully, migrate_pages() will still return the
number of THP pages that were not migrated. This will confuse the callers
of migrate_pages(). For example, the longterm pinning will failed though
all pages are migrated successfully.
Thus we should return 0 to indicate that all pages are migrated in this
case
Link: https://lkml.kernel.org/r/de386aa864be9158d2f3b344091419ea7c38b2f7.16665998…
Fixes: b5bade978e9b ("mm: migrate: fix the return value of migrate_pages()")
Signed-off-by: Baolin Wang <baolin.wang(a)linux.alibaba.com>
Reviewed-by: Alistair Popple <apopple(a)nvidia.com>
Reviewed-by: Yang Shi <shy828301(a)gmail.com>
Cc: David Hildenbrand <david(a)redhat.com>
Cc: "Huang, Ying" <ying.huang(a)intel.com>
Cc: Zi Yan <ziy(a)nvidia.com>
Cc: <stable(a)vger.kernel.org>
Signed-off-by: Andrew Morton <akpm(a)linux-foundation.org>
---
--- a/mm/migrate.c~mm-migrate-fix-return-value-if-all-subpages-of-thps-are-migrated-successfully
+++ a/mm/migrate.c
@@ -1582,6 +1582,13 @@ out:
*/
list_splice(&ret_pages, from);
+ /*
+ * Return 0 in case all subpages of fail-to-migrate THPs are
+ * migrated successfully.
+ */
+ if (list_empty(from))
+ rc = 0;
+
count_vm_events(PGMIGRATE_SUCCESS, nr_succeeded);
count_vm_events(PGMIGRATE_FAIL, nr_failed_pages);
count_vm_events(THP_MIGRATION_SUCCESS, nr_thp_succeeded);
_
Patches currently in -mm which might be from baolin.wang(a)linux.alibaba.com are
mm-migrate-try-again-if-thp-split-is-failed-due-to-page-refcnt.patch