Switching VTs occasionally freezes the system

Hello,

Every once in a while (about 1/100) vt switches will crash the nvidia driver and the whole graphics stack along with it.
The system is then wholly unresponsive but not dead (somtimes, you can reach ssh, and things still get printed to the log), however the display totally freezes, and you basically have to reboot.

I am using Prime render offload on my notebook. Since closing and opening the lid causes two VT switches internally, this bug appears more often than I would like it to. It has only started appearing with prime, before (when I only used the internal GPU) it did not happen.

The log around the crash looks like this:

Sep 16 22:16:16 JosArchLaptop kernel: Xorg: page allocation failure: order:5, mode:0x40cc0(GFP_KERNEL|__GFP_COMP), nodemask=(null),cpuset=/,mems_allowed=0
Sep 16 22:16:16 JosArchLaptop kernel: CPU: 6 PID: 1273 Comm: Xorg Tainted: P     U  W  OE     5.8.7-arch1-1 #1
Sep 16 22:16:16 JosArchLaptop kernel: Hardware name: Acer Nitro AN515-52/Freed_CFS, BIOS V1.28 08/05/2019
Sep 16 22:16:16 JosArchLaptop kernel: Call Trace:
Sep 16 22:16:16 JosArchLaptop kernel:  dump_stack+0x6b/0x88
Sep 16 22:16:16 JosArchLaptop kernel:  warn_alloc.cold+0x78/0xdc
Sep 16 22:16:16 JosArchLaptop kernel:  ? __alloc_pages_direct_compact+0x140/0x160
Sep 16 22:16:16 JosArchLaptop kernel:  __alloc_pages_slowpath.constprop.0+0xd14/0xd50
Sep 16 22:16:16 JosArchLaptop kernel:  __alloc_pages_nodemask+0x2e4/0x310
Sep 16 22:16:16 JosArchLaptop kernel:  kmalloc_order+0x1b/0x80
Sep 16 22:16:16 JosArchLaptop kernel:  kmalloc_order_trace+0x1d/0xb0
Sep 16 22:16:16 JosArchLaptop kernel:  nvkms_alloc+0x20/0x50 [nvidia_modeset]
Sep 16 22:16:16 JosArchLaptop kernel:  _nv002653kms+0x16/0x30 [nvidia_modeset]
Sep 16 22:16:16 JosArchLaptop kernel:  ? _nv002759kms+0x66/0x1470 [nvidia_modeset]
Sep 16 22:16:16 JosArchLaptop kernel:  ? __alloc_pages_nodemask+0x15b/0x310
Sep 16 22:16:16 JosArchLaptop kernel:  ? _nv000531kms+0x50/0x50 [nvidia_modeset]
Sep 16 22:16:16 JosArchLaptop kernel:  ? _nv000673kms+0x31/0xe0 [nvidia_modeset]
Sep 16 22:16:16 JosArchLaptop kernel:  ? _copy_from_user+0x2e/0x60
Sep 16 22:16:16 JosArchLaptop kernel:  ? _nv000531kms+0x50/0x50 [nvidia_modeset]
Sep 16 22:16:16 JosArchLaptop kernel:  ? nvKmsIoctl+0x96/0x1d0 [nvidia_modeset]
Sep 16 22:16:16 JosArchLaptop kernel:  ? _raw_spin_lock_irqsave+0x26/0x50
Sep 16 22:16:16 JosArchLaptop kernel:  ? nvkms_ioctl+0x103/0x180 [nvidia_modeset]
Sep 16 22:16:16 JosArchLaptop kernel:  ? nvidia_frontend_unlocked_ioctl+0x37/0x50 [nvidia]
Sep 16 22:16:16 JosArchLaptop kernel:  ? ksys_ioctl+0x82/0xc0
Sep 16 22:16:16 JosArchLaptop kernel:  ? __x64_sys_ioctl+0x16/0x20
Sep 16 22:16:16 JosArchLaptop kernel:  ? do_syscall_64+0x44/0x70
Sep 16 22:16:16 JosArchLaptop kernel:  ? entry_SYSCALL_64_after_hwframe+0x44/0xa9
Sep 16 22:16:16 JosArchLaptop kernel: Mem-Info:
Sep 16 22:16:16 JosArchLaptop kernel: active_anon:2991476 inactive_anon:297968 isolated_anon:0
                                       active_file:141533 inactive_file:76631 isolated_file:0
                                       unevictable:30944 dirty:377 writeback:0
                                       slab_reclaimable:32854 slab_unreclaimable:72726
                                       mapped:262132 shmem:266845 pagetables:23347 bounce:0
                                       free:80604 free_pcp:53 free_cma:0
Sep 16 22:16:16 JosArchLaptop kernel: Node 0 active_anon:11965904kB inactive_anon:1191872kB active_file:566132kB inactive_file:306524kB unevictable:123776kB isolated(anon):0kB isolated(file):0kB mapped:1048528kB dirty:1508kB writeback:0kB shmem:1067380kB shmem_thp: 0kB shmem_pmdmapped: 0kB anon_thp: 0kB writeback_tmp:0kB all_unreclaimable? no
Sep 16 22:16:16 JosArchLaptop kernel: Node 0 DMA free:13792kB min:64kB low:80kB high:96kB reserved_highatomic:0KB active_anon:0kB inactive_anon:0kB active_file:0kB inactive_file:0kB unevictable:0kB writepending:0kB present:15992kB managed:15904kB mlocked:0kB kernel_stack:0kB pagetables:0kB bounce:0kB free_pcp:0kB local_pcp:0kB free_cma:0kB
Sep 16 22:16:16 JosArchLaptop kernel: lowmem_reserve[]: 0 2069 15808 15808 15808
Sep 16 22:16:16 JosArchLaptop kernel: Node 0 DMA32 free:103540kB min:8836kB low:11044kB high:13252kB reserved_highatomic:2048KB active_anon:972740kB inactive_anon:449260kB active_file:35968kB inactive_file:111172kB unevictable:101632kB writepending:88kB present:2206396kB managed:2139880kB mlocked:4kB kernel_stack:3580kB pagetables:9692kB bounce:0kB free_pcp:16kB local_pcp:0kB free_cma:0kB
Sep 16 22:16:16 JosArchLaptop kernel: lowmem_reserve[]: 0 0 13738 13738 13738
Sep 16 22:16:16 JosArchLaptop kernel: Node 0 Normal free:205084kB min:60724kB low:75392kB high:90060kB reserved_highatomic:2048KB active_anon:10993780kB inactive_anon:742388kB active_file:530124kB inactive_file:195336kB unevictable:22244kB writepending:1412kB present:14393344kB managed:14074644kB mlocked:112kB kernel_stack:25156kB pagetables:83696kB bounce:0kB free_pcp:196kB local_pcp:0kB free_cma:0kB
Sep 16 22:16:16 JosArchLaptop kernel: lowmem_reserve[]: 0 0 0 0 0
Sep 16 22:16:16 JosArchLaptop kernel: Node 0 DMA: 2*4kB (U) 1*8kB (U) 1*16kB (U) 0*32kB 1*64kB (U) 1*128kB (U) 1*256kB (U) 0*512kB 1*1024kB (U) 2*2048kB (UM) 2*4096kB (M) = 13792kB
Sep 16 22:16:16 JosArchLaptop kernel: Node 0 DMA32: 2376*4kB (UMEH) 1496*8kB (UMEH) 1551*16kB (UMEH) 1365*32kB (UMEH) 224*64kB (UMEH) 2*128kB (H) 0*256kB 0*512kB 0*1024kB 0*2048kB 0*4096kB = 104560kB
Sep 16 22:16:16 JosArchLaptop kernel: Node 0 Normal: 33799*4kB (UMEH) 4822*8kB (UMEH) 1741*16kB (UMEH) 200*32kB (UMEH) 2*64kB (ME) 0*128kB 0*256kB 0*512kB 0*1024kB 0*2048kB 0*4096kB = 208156kB
Sep 16 22:16:16 JosArchLaptop kernel: Node 0 hugepages_total=0 hugepages_free=0 hugepages_surp=0 hugepages_size=1048576kB
Sep 16 22:16:16 JosArchLaptop kernel: Node 0 hugepages_total=0 hugepages_free=0 hugepages_surp=0 hugepages_size=2048kB
Sep 16 22:16:16 JosArchLaptop kernel: 543168 total pagecache pages
Sep 16 22:16:16 JosArchLaptop kernel: 58782 pages in swap cache
Sep 16 22:16:16 JosArchLaptop kernel: Swap cache stats: add 3718501, delete 3659640, find 1226897/1727382
Sep 16 22:16:16 JosArchLaptop kernel: Free swap  = 35857460kB
Sep 16 22:16:16 JosArchLaptop kernel: Total swap = 39248956kB
Sep 16 22:16:16 JosArchLaptop kernel: 4153933 pages RAM
Sep 16 22:16:16 JosArchLaptop kernel: 0 pages HighMem/MovableOnly
Sep 16 22:16:16 JosArchLaptop kernel: 96326 pages reserved
Sep 16 22:16:16 JosArchLaptop kernel: 0 pages hwpoisoned
Sep 16 22:16:16 JosArchLaptop kernel: BUG: unable to handle page fault for address: 0000000000007980
Sep 16 22:16:16 JosArchLaptop kernel: #PF: supervisor read access in kernel mode
Sep 16 22:16:16 JosArchLaptop kernel: #PF: error_code(0x0000) - not-present page
Sep 16 22:16:16 JosArchLaptop kernel: PGD 0 P4D 0 
Sep 16 22:16:16 JosArchLaptop kernel: Oops: 0000 [#1] PREEMPT SMP PTI
Sep 16 22:16:16 JosArchLaptop kernel: CPU: 6 PID: 1273 Comm: Xorg Tainted: P     U  W  OE     5.8.7-arch1-1 #1
Sep 16 22:16:16 JosArchLaptop kernel: Hardware name: Acer Nitro AN515-52/Freed_CFS, BIOS V1.28 08/05/2019
Sep 16 22:16:16 JosArchLaptop kernel: RIP: 0010:_nv002606kms+0x60/0x100 [nvidia_modeset]
Sep 16 22:16:16 JosArchLaptop kernel: Code: eb 40 0f 1f 84 00 00 00 00 00 48 c7 03 00 00 00 00 c6 43 08 00 41 8b 86 d0 00 00 00 83 c5 01 48 81 c3 28 04 00 00 39 e8 76 18 <48> 8b 3b 48 85 ff 74 ea 80 7b 08 00 75 d2 e8 dd d2 ff ff eb cb 0f
Sep 16 22:16:16 JosArchLaptop kernel: RSP: 0018:ffffaf12c115bcf8 EFLAGS: 00010202
Sep 16 22:16:16 JosArchLaptop kernel: RAX: 0000000000000004 RBX: 0000000000007980 RCX: 0000000000000004
Sep 16 22:16:16 JosArchLaptop kernel: RDX: 0000000000000055 RSI: 0000000000007980 RDI: ffff9d88138be008
Sep 16 22:16:16 JosArchLaptop kernel: RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
Sep 16 22:16:16 JosArchLaptop kernel: R10: 0000000000000004 R11: 0000000000000004 R12: 0000000000007980
Sep 16 22:16:16 JosArchLaptop kernel: R13: 0000000000007980 R14: ffff9d88138be008 R15: 0000000000000001
Sep 16 22:16:16 JosArchLaptop kernel: FS:  00007f84071a8540(0000) GS:ffff9d881e380000(0000) knlGS:0000000000000000
Sep 16 22:16:16 JosArchLaptop kernel: CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
Sep 16 22:16:16 JosArchLaptop kernel: CR2: 0000000000007980 CR3: 000000043dd1e001 CR4: 00000000003606e0
Sep 16 22:16:16 JosArchLaptop kernel: Call Trace:
Sep 16 22:16:16 JosArchLaptop kernel:  ? _nv002759kms+0x3ca/0x1470 [nvidia_modeset]
Sep 16 22:16:16 JosArchLaptop kernel:  ? _nv000531kms+0x50/0x50 [nvidia_modeset]
Sep 16 22:16:16 JosArchLaptop kernel:  ? _nv000673kms+0x31/0xe0 [nvidia_modeset]
Sep 16 22:16:16 JosArchLaptop kernel:  ? _copy_from_user+0x2e/0x60
Sep 16 22:16:16 JosArchLaptop kernel:  ? _nv000531kms+0x50/0x50 [nvidia_modeset]
Sep 16 22:16:16 JosArchLaptop kernel:  ? nvKmsIoctl+0x96/0x1d0 [nvidia_modeset]
Sep 16 22:16:16 JosArchLaptop kernel:  ? _raw_spin_lock_irqsave+0x26/0x50
Sep 16 22:16:16 JosArchLaptop kernel:  ? nvkms_ioctl+0x103/0x180 [nvidia_modeset]
Sep 16 22:16:16 JosArchLaptop kernel:  ? nvidia_frontend_unlocked_ioctl+0x37/0x50 [nvidia]
Sep 16 22:16:16 JosArchLaptop kernel:  ? ksys_ioctl+0x82/0xc0
Sep 16 22:16:16 JosArchLaptop kernel:  ? __x64_sys_ioctl+0x16/0x20
Sep 16 22:16:16 JosArchLaptop kernel:  ? do_syscall_64+0x44/0x70
Sep 16 22:16:16 JosArchLaptop kernel:  ? entry_SYSCALL_64_after_hwframe+0x44/0xa9
Sep 16 22:16:16 JosArchLaptop kernel: Modules linked in: nls_utf8 isofs sr_mod cdrom uas usb_storage snd_usb_audio snd_usbmidi_lib snd_rawmidi snd_seq_dummy snd_hrtimer snd_seq snd_seq_device ccm rfcomm fuse xt_CHECKSUM xt_MASQUERADE ip6t_REJECT nf_reject_ipv6 ipt_REJECT nf_reject_ipv4 ip6table_mangle ip6table_nat iptable_mangle iptable_nat nf_nat ebtable_filter ebtables ip6table_filter ip6_tables tun bridge stp llc cmac algif_hash algif_skcipher af_alg bnep xt_tcpudp xt_conntrack nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 libcrc32c iptable_filter squashfs loop nvidia_drm(POE) nvidia_modeset(POE) nvidia(POE) snd_sof_pci snd_sof_intel_byt snd_sof_intel_ipc snd_sof_intel_hda_common nls_iso8859_1 snd_soc_hdac_hda nls_cp437 snd_sof_xtensa_dsp vfat intel_rapl_msr snd_sof_intel_hda snd_sof intel_rapl_common fat snd_soc_skl 8250_dw hid_multitouch iTCO_wdt intel_pmc_bxt snd_soc_sst_ipc mei_hdcp ee1004 iTCO_vendor_support intel_wmi_thunderbolt wmi_bmof snd_soc_sst_dsp acer_wmi snd_hda_ext_core sparse_keymap
Sep 16 22:16:16 JosArchLaptop kernel:  snd_soc_acpi_intel_match snd_soc_acpi snd_hda_codec_realtek snd_soc_core iwlmvm snd_hda_codec_generic x86_pkg_temp_thermal intel_powerclamp snd_compress ledtrig_audio ac97_bus coretemp snd_pcm_dmaengine uvcvideo btusb mac80211 snd_hda_intel kvm_intel btrtl videobuf2_vmalloc videobuf2_memops btbcm videobuf2_v4l2 btintel snd_intel_dspcfg videobuf2_common libarc4 kvm bluetooth snd_hda_codec irqbypass ofpart rapl iwlwifi videodev cmdlinepart snd_hda_core mousedev joydev intel_cstate ecdh_generic intel_spi_pci mc intel_uncore snd_hwdep ecc intel_spi cfg80211 snd_pcm r8169 spi_nor pcspkr input_leds snd_timer realtek i2c_i801 mei_me intel_lpss_pci snd libphy mtd intel_lpss i2c_smbus mei soundcore rfkill idma64 intel_pch_thermal i2c_hid battery ac wmi tpm_crb tpm_tis tpm_tis_core evdev mac_hid acer_wireless vboxnetflt(OE) vboxnetadp(OE) vboxdrv(OE) sg crypto_user ip_tables x_tables ext4 crc32c_generic crc16 mbcache jbd2 hid_generic usbhid hid dm_crypt cbc encrypted_keys dm_mod trusted
Sep 16 22:16:16 JosArchLaptop kernel:  tpm rng_core raid1 md_mod rtsx_pci_sdmmc serio_raw mmc_core atkbd libps2 crct10dif_pclmul crc32_pclmul crc32c_intel ghash_clmulni_intel aesni_intel xhci_pci crypto_simd xhci_pci_renesas cryptd glue_helper xhci_hcd rtsx_pci i8042 serio i915 intel_gtt i2c_algo_bit drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops cec rc_core drm agpgart
Sep 16 22:16:16 JosArchLaptop kernel: CR2: 0000000000007980
Sep 16 22:16:16 JosArchLaptop kernel: ---[ end trace 38e1873669923645 ]---
Sep 16 22:16:16 JosArchLaptop kernel: RIP: 0010:_nv002606kms+0x60/0x100 [nvidia_modeset]
Sep 16 22:16:16 JosArchLaptop kernel: Code: eb 40 0f 1f 84 00 00 00 00 00 48 c7 03 00 00 00 00 c6 43 08 00 41 8b 86 d0 00 00 00 83 c5 01 48 81 c3 28 04 00 00 39 e8 76 18 <48> 8b 3b 48 85 ff 74 ea 80 7b 08 00 75 d2 e8 dd d2 ff ff eb cb 0f
Sep 16 22:16:16 JosArchLaptop kernel: RSP: 0018:ffffaf12c115bcf8 EFLAGS: 00010202
Sep 16 22:16:16 JosArchLaptop kernel: RAX: 0000000000000004 RBX: 0000000000007980 RCX: 0000000000000004
Sep 16 22:16:16 JosArchLaptop kernel: RDX: 0000000000000055 RSI: 0000000000007980 RDI: ffff9d88138be008
Sep 16 22:16:16 JosArchLaptop kernel: RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
Sep 16 22:16:16 JosArchLaptop kernel: R10: 0000000000000004 R11: 0000000000000004 R12: 0000000000007980
Sep 16 22:16:16 JosArchLaptop kernel: R13: 0000000000007980 R14: ffff9d88138be008 R15: 0000000000000001
Sep 16 22:16:16 JosArchLaptop kernel: FS:  00007f84071a8540(0000) GS:ffff9d881e380000(0000) knlGS:0000000000000000
Sep 16 22:16:16 JosArchLaptop kernel: CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
Sep 16 22:16:16 JosArchLaptop kernel: CR2: 0000000000007980 CR3: 000000043dd1e001 CR4: 00000000003606e0

I was not able to run the bug reporting script afterwards yet, however here is the what this produces otherwise:
nvidia-bug-report.log.gz (790.6 KB)
log.txt (12.2 KB)