* [pve-devel] [PATCH kernel 1/2] add fix for CIFS client memory leak
@ 2024-07-10 11:37 Fiona Ebner
2024-07-10 11:37 ` [pve-devel] [PATCH kernel 2/2] cherry-pick potential fix for NULL pointer deref with AMD Arcturus GPU during boot Fiona Ebner
2024-07-12 14:54 ` [pve-devel] applied-series: [PATCH kernel 1/2] add fix for CIFS client memory leak Thomas Lamprecht
0 siblings, 2 replies; 4+ messages in thread
From: Fiona Ebner @ 2024-07-10 11:37 UTC (permalink / raw)
To: pve-devel
As reported in the community forum [0], there currently is a memory
leak in the CIFS client code. Reproduced by running a backup with CIFS
target storage:
> while true; do vzdump 101 --storage cifs --prune-backups keep-last=1; echo 3 > /proc/sys/vm/drop_caches; done
A fix was found on the kernel mailing list tagged for stable v6.6+
and it does solve the issue, but is not yet included in any (stable)
kernels.
[0]: https://forum.proxmox.com/threads/147603/post-682388
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
...ix-pagecache-leak-when-do-writepages.patch | 108 ++++++++++++++++++
1 file changed, 108 insertions(+)
create mode 100644 patches/kernel/0018-cifs-fix-pagecache-leak-when-do-writepages.patch
diff --git a/patches/kernel/0018-cifs-fix-pagecache-leak-when-do-writepages.patch b/patches/kernel/0018-cifs-fix-pagecache-leak-when-do-writepages.patch
new file mode 100644
index 0000000..495dd71
--- /dev/null
+++ b/patches/kernel/0018-cifs-fix-pagecache-leak-when-do-writepages.patch
@@ -0,0 +1,108 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Yang Erkun <yangerkun@huawei.com>
+Date: Tue, 25 Jun 2024 11:43:32 +0800
+Subject: [PATCH] cifs: fix pagecache leak when do writepages
+
+After commit f3dc1bdb6b0b("cifs: Fix writeback data corruption"), the
+writepages for cifs will find all folio needed writepage with two phase.
+The first folio will be found in cifs_writepages_begin, and the latter
+various folios will be found in cifs_extend_writeback.
+
+All those will first get folio, and for normal case, once we set page
+writeback and after do really write, we should put the reference, folio
+found in cifs_extend_writeback do this with folio_batch_release. But the
+folio found in cifs_writepages_begin never get the chance do it. And
+every writepages call, we will leak a folio(found this problem while do
+xfstests over cifs, the latter show that we will leak about 600M+ every
+we run generic/074).
+
+echo 3 > /proc/sys/vm/drop_caches ; cat /proc/meminfo | grep file
+Active(file): 34092 kB
+Inactive(file): 176192 kB
+./check generic/074 (smb v1)
+...
+generic/074 50s ... 53s
+Ran: generic/074
+Passed all 1 tests
+
+echo 3 > /proc/sys/vm/drop_caches ; cat /proc/meminfo | grep file
+Active(file): 35036 kB
+Inactive(file): 854708 kB
+
+Besides, the exist path seem never handle this folio correctly, fix it too
+with this patch.
+
+The problem does not exist in mainline since writepages path for cifs
+has changed to netfs(3ee1a1fc3981 ("cifs: Cut over to using netfslib")).
+It's had to backport all related change, so try fix this problem with this
+single patch.
+
+Fixes: f3dc1bdb6b0b ("cifs: Fix writeback data corruption")
+Cc: stable@kernel.org # v6.6+
+Signed-off-by: Yang Erkun <yangerkun@huawei.com>
+(picked from https://lore.kernel.org/linux-cifs/20240625034332.750312-1-yangerkun@huawei.com/)
+Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
+---
+ fs/smb/client/file.c | 16 +++++++++++++---
+ 1 file changed, 13 insertions(+), 3 deletions(-)
+
+diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c
+index af5c476db6e6..8aee0f520300 100644
+--- a/fs/smb/client/file.c
++++ b/fs/smb/client/file.c
+@@ -2845,17 +2845,21 @@ static ssize_t cifs_write_back_from_locked_folio(struct address_space *mapping,
+ rc = cifs_get_writable_file(CIFS_I(inode), FIND_WR_ANY, &cfile);
+ if (rc) {
+ cifs_dbg(VFS, "No writable handle in writepages rc=%d\n", rc);
++ folio_unlock(folio);
+ goto err_xid;
+ }
+
+ rc = server->ops->wait_mtu_credits(server, cifs_sb->ctx->wsize,
+ &wsize, credits);
+- if (rc != 0)
++ if (rc != 0) {
++ folio_unlock(folio);
+ goto err_close;
++ }
+
+ wdata = cifs_writedata_alloc(cifs_writev_complete);
+ if (!wdata) {
+ rc = -ENOMEM;
++ folio_unlock(folio);
+ goto err_uncredit;
+ }
+
+@@ -3002,17 +3006,22 @@ static ssize_t cifs_writepages_begin(struct address_space *mapping,
+ lock_again:
+ if (wbc->sync_mode != WB_SYNC_NONE) {
+ ret = folio_lock_killable(folio);
+- if (ret < 0)
++ if (ret < 0) {
++ folio_put(folio);
+ return ret;
++ }
+ } else {
+- if (!folio_trylock(folio))
++ if (!folio_trylock(folio)) {
++ folio_put(folio);
+ goto search_again;
++ }
+ }
+
+ if (folio->mapping != mapping ||
+ !folio_test_dirty(folio)) {
+ start += folio_size(folio);
+ folio_unlock(folio);
++ folio_put(folio);
+ goto search_again;
+ }
+
+@@ -3042,6 +3051,7 @@ static ssize_t cifs_writepages_begin(struct address_space *mapping,
+ out:
+ if (ret > 0)
+ *_start = start + ret;
++ folio_put(folio);
+ return ret;
+ }
+
--
2.39.2
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* [pve-devel] [PATCH kernel 2/2] cherry-pick potential fix for NULL pointer deref with AMD Arcturus GPU during boot
2024-07-10 11:37 [pve-devel] [PATCH kernel 1/2] add fix for CIFS client memory leak Fiona Ebner
@ 2024-07-10 11:37 ` Fiona Ebner
2024-07-16 9:41 ` Alexander Zeidler
2024-07-12 14:54 ` [pve-devel] applied-series: [PATCH kernel 1/2] add fix for CIFS client memory leak Thomas Lamprecht
1 sibling, 1 reply; 4+ messages in thread
From: Fiona Ebner @ 2024-07-10 11:37 UTC (permalink / raw)
To: pve-devel
The issue was reported in the enterprise support and is handled by
Alexander Zeidler. It has the following trace [0] and causes an issue
with the networking down the line, because 'udevadm settle' would time
out. The customer reported that mainline kernel 6.9.3 booted fine.
Looking at the new commits, this one stood out, as it heavily modifies
the arcturus_get_power_limit() function. While not tagged for stable,
it seems straightforward enough and has a good chance to fix the
issue.
[0]:
> Jul 09 07:34:59 proxmox kernel: BUG: kernel NULL pointer dereference, address: 000000000000000f
> Jul 09 07:34:59 proxmox kernel: #PF: supervisor read access in kernel mode
> Jul 09 07:34:59 proxmox kernel: #PF: error_code(0x0000) - not-present page
> Jul 09 07:34:59 proxmox kernel: PGD 0 P4D 0
> Jul 09 07:34:59 proxmox kernel: Oops: 0000 [#1] PREEMPT SMP NOPTI
> Jul 09 07:34:59 proxmox kernel: CPU: 0 PID: 9 Comm: kworker/0:1 Tainted: P O 6.8.8-2-pve #1
> Jul 09 07:34:59 proxmox kernel: Hardware name: Supermicro AS -4124GS-TNR-03-EB004/H12DSG-O-CPU, BIOS 2.7 09/21/2023
> Jul 09 07:34:59 proxmox kernel: Workqueue: events work_for_cpu_fn
> Jul 09 07:34:59 proxmox kernel: RIP: 0010:arcturus_get_power_limit+0xb5/0x1b0 [amdgpu]
> Jul 09 07:34:59 proxmox kernel: Code: 24 48 85 d2 74 05 8b 45 cc 89 02 4d 85 ff 74 38 44 0f b6 a3 b8 06 00 00 41 80 fc 01 0f 87 81 d7 3d 00 48 8b 45 b0 41 83 e4 01 <0f> b6 40 0f 75 10 84 c0 74 14 45 8b bf 86 01 00 00 45 31 e4 eb 0e
> Jul 09 07:34:59 proxmox kernel: RSP: 0018:ffffaa42c029fc38 EFLAGS: 00010246
> Jul 09 07:34:59 proxmox kernel: RAX: 0000000000000000 RBX: ffff8d803362b000 RCX: 0000000000000000
> Jul 09 07:34:59 proxmox kernel: RDX: ffff8d803362b6c0 RSI: 0000000000000000 RDI: 0000000000000000
> Jul 09 07:34:59 proxmox kernel: RBP: ffffaa42c029fc88 R08: 0000000000000000 R09: ffffffffc177e1f0
> Jul 09 07:34:59 proxmox kernel: R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000
> Jul 09 07:34:59 proxmox kernel: R13: ffff8d803362b6c8 R14: ffff8d803362b6c4 R15: ffff8d80424a1014
> Jul 09 07:34:59 proxmox kernel: FS: 0000000000000000(0000) GS:ffff8e7f0ae00000(0000) knlGS:0000000000000000
> Jul 09 07:34:59 proxmox kernel: CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> Jul 09 07:34:59 proxmox kernel: CR2: 000000000000000f CR3: 0000006b24a36003 CR4: 0000000000f70ef0
> Jul 09 07:34:59 proxmox kernel: PKRU: 55555554
> Jul 09 07:34:59 proxmox kernel: Call Trace:
> Jul 09 07:34:59 proxmox kernel: <TASK>
> Jul 09 07:34:59 proxmox kernel: ? show_regs+0x6d/0x80
> Jul 09 07:34:59 proxmox kernel: ? __die+0x24/0x80
> Jul 09 07:34:59 proxmox kernel: ? page_fault_oops+0x176/0x500
> Jul 09 07:34:59 proxmox kernel: ? do_user_addr_fault+0x2f9/0x6b0
> Jul 09 07:34:59 proxmox kernel: ? exc_page_fault+0x83/0x1b0
> Jul 09 07:34:59 proxmox kernel: ? asm_exc_page_fault+0x27/0x30
> Jul 09 07:34:59 proxmox kernel: ? __pfx_arcturus_get_power_limit+0x10/0x10 [amdgpu]
> Jul 09 07:34:59 proxmox kernel: ? arcturus_get_power_limit+0xb5/0x1b0 [amdgpu]
> Jul 09 07:34:59 proxmox kernel: ? arcturus_get_power_limit+0x62/0x1b0 [amdgpu]
> Jul 09 07:34:59 proxmox kernel: smu_late_init+0x16f/0x4d0 [amdgpu]
> Jul 09 07:34:59 proxmox kernel: amdgpu_device_ip_late_init+0x68/0x2a0 [amdgpu]
> Jul 09 07:34:59 proxmox kernel: amdgpu_device_init+0x242d/0x26e0 [amdgpu]
> Jul 09 07:34:59 proxmox kernel: ? srso_alias_return_thunk+0x5/0xfbef5
> Jul 09 07:34:59 proxmox kernel: amdgpu_driver_load_kms+0x1a/0x1c0 [amdgpu]
> Jul 09 07:34:59 proxmox kernel: amdgpu_pci_probe+0x195/0x520 [amdgpu]
> Jul 09 07:34:59 proxmox kernel: local_pci_probe+0x47/0xb0
> Jul 09 07:34:59 proxmox kernel: work_for_cpu_fn+0x1a/0x30
> Jul 09 07:34:59 proxmox kernel: process_one_work+0x16d/0x350
> Jul 09 07:34:59 proxmox kernel: worker_thread+0x306/0x440
> Jul 09 07:34:59 proxmox kernel: ? __pfx_worker_thread+0x10/0x10
> Jul 09 07:34:59 proxmox kernel: kthread+0xf2/0x120
> Jul 09 07:34:59 proxmox kernel: ? __pfx_kthread+0x10/0x10
> Jul 09 07:34:59 proxmox kernel: ret_from_fork+0x47/0x70
> Jul 09 07:34:59 proxmox kernel: ? __pfx_kthread+0x10/0x10
> Jul 09 07:34:59 proxmox kernel: ret_from_fork_asm+0x1b/0x30
> Jul 09 07:34:59 proxmox kernel: </TASK>
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
...pu-pm-Don-t-use-OD-table-on-Arcturus.patch | 69 +++++++++++++++++++
1 file changed, 69 insertions(+)
create mode 100644 patches/kernel/0019-drm-amdgpu-pm-Don-t-use-OD-table-on-Arcturus.patch
diff --git a/patches/kernel/0019-drm-amdgpu-pm-Don-t-use-OD-table-on-Arcturus.patch b/patches/kernel/0019-drm-amdgpu-pm-Don-t-use-OD-table-on-Arcturus.patch
new file mode 100644
index 0000000..cd88e43
--- /dev/null
+++ b/patches/kernel/0019-drm-amdgpu-pm-Don-t-use-OD-table-on-Arcturus.patch
@@ -0,0 +1,69 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Ma Jun <Jun.Ma2@amd.com>
+Date: Tue, 19 Mar 2024 11:02:29 +0800
+Subject: [PATCH] drm/amdgpu/pm: Don't use OD table on Arcturus
+
+OD is not supported on Arcturus, so the OD table
+should not be used.
+
+Signed-off-by: Ma Jun <Jun.Ma2@amd.com>
+Acked-by: Alex Deucher <alexander.deucher@amd.com>
+Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
+(cherry picked from commit bc55c344b06f7e6f99eb92d393ff0a84c1532514)
+Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
+---
+ .../gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c | 33 +++----------------
+ 1 file changed, 5 insertions(+), 28 deletions(-)
+
+diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c
+index 40ba7227cca5..0c2d04f978ac 100644
+--- a/drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c
++++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c
+@@ -1283,11 +1283,8 @@ static int arcturus_get_power_limit(struct smu_context *smu,
+ uint32_t *max_power_limit,
+ uint32_t *min_power_limit)
+ {
+- struct smu_11_0_powerplay_table *powerplay_table =
+- (struct smu_11_0_powerplay_table *)smu->smu_table.power_play_table;
+- struct smu_11_0_overdrive_table *od_settings = smu->od_settings;
+ PPTable_t *pptable = smu->smu_table.driver_pptable;
+- uint32_t power_limit, od_percent_upper = 0, od_percent_lower = 0;
++ uint32_t power_limit;
+
+ if (smu_v11_0_get_current_power_limit(smu, &power_limit)) {
+ /* the last hope to figure out the ppt limit */
+@@ -1303,30 +1300,10 @@ static int arcturus_get_power_limit(struct smu_context *smu,
+ *current_power_limit = power_limit;
+ if (default_power_limit)
+ *default_power_limit = power_limit;
+-
+- if (powerplay_table) {
+- if (smu->od_enabled &&
+- od_settings->cap[SMU_11_0_ODCAP_POWER_LIMIT]) {
+- od_percent_upper = le32_to_cpu(powerplay_table->overdrive_table.max[SMU_11_0_ODSETTING_POWERPERCENTAGE]);
+- od_percent_lower = le32_to_cpu(powerplay_table->overdrive_table.min[SMU_11_0_ODSETTING_POWERPERCENTAGE]);
+- } else if (od_settings->cap[SMU_11_0_ODCAP_POWER_LIMIT]) {
+- od_percent_upper = 0;
+- od_percent_lower = le32_to_cpu(powerplay_table->overdrive_table.min[SMU_11_0_ODSETTING_POWERPERCENTAGE]);
+- }
+- }
+-
+- dev_dbg(smu->adev->dev, "od percent upper:%d, od percent lower:%d (default power: %d)\n",
+- od_percent_upper, od_percent_lower, power_limit);
+-
+- if (max_power_limit) {
+- *max_power_limit = power_limit * (100 + od_percent_upper);
+- *max_power_limit /= 100;
+- }
+-
+- if (min_power_limit) {
+- *min_power_limit = power_limit * (100 - od_percent_lower);
+- *min_power_limit /= 100;
+- }
++ if (max_power_limit)
++ *max_power_limit = power_limit;
++ if (min_power_limit)
++ *min_power_limit = power_limit;
+
+ return 0;
+ }
--
2.39.2
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* [pve-devel] applied-series: [PATCH kernel 1/2] add fix for CIFS client memory leak
2024-07-10 11:37 [pve-devel] [PATCH kernel 1/2] add fix for CIFS client memory leak Fiona Ebner
2024-07-10 11:37 ` [pve-devel] [PATCH kernel 2/2] cherry-pick potential fix for NULL pointer deref with AMD Arcturus GPU during boot Fiona Ebner
@ 2024-07-12 14:54 ` Thomas Lamprecht
1 sibling, 0 replies; 4+ messages in thread
From: Thomas Lamprecht @ 2024-07-12 14:54 UTC (permalink / raw)
To: Proxmox VE development discussion, Fiona Ebner
On 10/07/2024 13:37, Fiona Ebner wrote:
> As reported in the community forum [0], there currently is a memory
> leak in the CIFS client code. Reproduced by running a backup with CIFS
> target storage:
>
>> while true; do vzdump 101 --storage cifs --prune-backups keep-last=1; echo 3 > /proc/sys/vm/drop_caches; done
>
> A fix was found on the kernel mailing list tagged for stable v6.6+
> and it does solve the issue, but is not yet included in any (stable)
> kernels.
>
> [0]: https://forum.proxmox.com/threads/147603/post-682388
>
> Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
> ---
> ...ix-pagecache-leak-when-do-writepages.patch | 108 ++++++++++++++++++
> 1 file changed, 108 insertions(+)
> create mode 100644 patches/kernel/0018-cifs-fix-pagecache-leak-when-do-writepages.patch
>
>
applied both patches, thanks!
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-07-16 9:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-10 11:37 [pve-devel] [PATCH kernel 1/2] add fix for CIFS client memory leak Fiona Ebner
2024-07-10 11:37 ` [pve-devel] [PATCH kernel 2/2] cherry-pick potential fix for NULL pointer deref with AMD Arcturus GPU during boot Fiona Ebner
2024-07-16 9:41 ` Alexander Zeidler
2024-07-12 14:54 ` [pve-devel] applied-series: [PATCH kernel 1/2] add fix for CIFS client memory leak Thomas Lamprecht
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox