(BTRFS) System freezes with web browsers

Hello Community,

I have been struggling with the issue for a several months. I have changed the SSD to a new Crucial BX500 and the issue persists - system freezes untill I barely manage to kill the browser.
The Laptop is an old one , if that is of any importance.

So far I have noticed that only Web browsers (firefox/chrome) cause the issue, yet other tasks like video conversion does not trigger it.
I have a suspicion that BTRFS is somehow overloaded , but I have no hard evidence for that.

How much memory?

Browser? FireFox?

Desktop??

FF does not like to be short on memory.

Memory: 4G (usable 3.8Gi) with average use 1.9Gi
Browser: Both Chrome & Firefox
Desktop -> KDE

Do you have swap - even though Firefox may not need it - it seems to hang if there is not enough swap available.
I have 32 gb of ram and had to add 4 gb swap for Firefox not to hang.

Before making changes to the system, it’s best to understand what’s going on. Tools like htop, atop, iotop, iostat can help diagnose what using system’s resources.

Also, let’s see what I/O scheduler do you have. openSUSE currently identifies whether the system is running on spinning disks or SSDs and sets to an appropriate scheduler.

grep '\.*\]' /sys/block/*/queue/scheduler

That said, a couple tweaks can improve responsiveness. Proceed with monitoring for RAM usage and I/O, and whether it helps with responsiveness after each step.

  1. Disable caching to disk on Firefox

Open firefox, and navigate to about:config, type browser.cache.disk.enable and set that to false (double-click).

  1. Reduce swap to disk

Once the system achieves a given % load, it begins swapping to disk. This can be changed to a lower value = less swap activity.

Read the current value. The default value, vm.swappiness=60, put’s your system in a state that will perform swap often. The vm.vfs_cache_pressure settings controls how much the kernel reclaims memory holding inode entries.


sudo sysctl vm.swappiness
sudo sysctl vm.vfs_cache_pressure

Change to a lower number, say 10 (swapping starts at 10% free memory, I have it set to 1)

sudo sysctl -w vm.swappiness=10
sudo sysctl -w vm.vfs_cache_pressure=50

To make it permanent for the next boot, run this:

sudo tee /etc/sysctl.d/99-swap.conf >/dev/null <<EOF
vm.swappiness=10
vm.vfs_cache_pressure=50
EOF 

Reference: https://doc.opensuse.org/documentation/leap/tuning/html/book.sle.tuning/part-tuning-kernel.html

I have no swap dedicated:

mimi:~ # free -h
              total        used        free      shared  buff/cache   available
Mem:          3.8Gi       1.4Gi       820Mi       272Mi       1.6Gi       1.9Gi
Swap:            0B          0B          0B

SSD is using ‘noop’ , while rotating disk is using deadline.

mimi:~ # cat /sys/block/sd*/queue/scheduler 
[noop] deadline cfq 
noop [deadline] cfq 

I will try to disable disk caching on firefox and chrome.

After disabling disk caching for firefox, I still experience the problems.
I guess I will need to use XFS/ext for /home

Hi
Don’t see it here with btrfs, I do have a swap file and tweaked, but never seen Firefox use it… Up over a day here zero swap used, multiple Firefox windows and tabs in use. I don’t use those old schedulers… mq-deadline with SSD, bfq for rotating rust (btrfs/xfs)…


cat /sys/block/sd*/queue/scheduler 
[mq-deadline] kyber bfq none
[mq-deadline] kyber bfq none
mq-deadline kyber [bfq] none

{Add to grub kernel options}

scsi_mod.use_blk_mq=1

I would suspect the noop causing issues should be cfq or deadline with btrfs…

IMO you should configure a swap partition (or swap file if you have very limited storage)
All OS benefit from some swap, even if it’s minimal.
With 4GB RAM, you may also benefit by disabling unneeded bling if you’re running KDE or Gnome… Or, if you run a different “lighter” desktop you won’t have those extra loads by default.

I see the Crucial BX500 comes in various sizes so you’ll have to determine for yourself how and how much swap you can configure. One benefit of swap on an SSD is that I doubt you’ll have to worry about contiguous blocks, if your swap becomes fragmented I doubt it would have any effect on performance.

TSU

  1. Add RAM. 8 GB is the minimum for a browsing in our times.
  2. With small amount of RAM use only one browser. Firefox is more tolerable to it.
  3. You need swap, especially with a low memory usage.
  4. Tune memory volume dedicated to a graphics chip. 256-512 MB is good enough.
  5. Use XFS or Ext4 instead of BTRFS.

Users system may not support it since it’s an old laptop…

Not seen that here on a MacBook3,1 (late 2007 model) 4GB RAM, but do have a swap file, plus swap tweaked.

It may not be a feature of the laptop…

Like I indicated, i/o scheduler and could also be (since old laptop) the cpu in use and missing features that is needed…

@OP
Can you post the output from;


lscpu | egrep  "Model name:|Flags:"

More exactly:


**LANG=EN** lscpu | egrep  "Model name:|Flags:"

But for what do you need it?
I was using FF & Vivaldi with Athlon 64 + 3 GB RAM.
It was awful with BTRFS and bearable with ext4 and XFS.

To OP: for better results full description of your hardware is needed.

laptop:~ # LANG=EN lscpu | egrep “Model name:|Flags:”
Model name: Intel(R) Core™2 Duo CPU T9500 @ 2.60GHz
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts rep_good nopl cpuid aperfmperf pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm sse4_1 lahf_lm pti tpr_shadow vnmi flexpriority dtherm ida

ASUS K50IJ supports up to 4GB. I’m using only 1 browser at a time and it’s definitely not a memory problem or the OOM killer will kick in.

laptop:~ #lspci
00:00.0 Host bridge: Intel Corporation Mobile 4 Series Chipset Memory Controller Hub (rev 09)
00:02.0 VGA compatible controller: Intel Corporation Mobile 4 Series Chipset Integrated Graphics Controller (rev 09)
00:02.1 Display controller: Intel Corporation Mobile 4 Series Chipset Integrated Graphics Controller (rev 09)
00:1a.0 USB controller: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #4 (rev 03)
00:1a.1 USB controller: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #5 (rev 03)
00:1a.2 USB controller: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #6 (rev 03)
00:1a.7 USB controller: Intel Corporation 82801I (ICH9 Family) USB2 EHCI Controller #2 (rev 03)
00:1b.0 Audio device: Intel Corporation 82801I (ICH9 Family) HD Audio Controller (rev 03)
00:1c.0 PCI bridge: Intel Corporation 82801I (ICH9 Family) PCI Express Port 1 (rev 03)
00:1c.1 PCI bridge: Intel Corporation 82801I (ICH9 Family) PCI Express Port 2 (rev 03)
00:1c.5 PCI bridge: Intel Corporation 82801I (ICH9 Family) PCI Express Port 6 (rev 03)
00:1d.0 USB controller: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #1 (rev 03)
00:1d.1 USB controller: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #2 (rev 03)
00:1d.2 USB controller: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #3 (rev 03)
00:1d.7 USB controller: Intel Corporation 82801I (ICH9 Family) USB2 EHCI Controller #1 (rev 03)
00:1e.0 PCI bridge: Intel Corporation 82801 Mobile PCI Bridge (rev 93)
00:1f.0 ISA bridge: Intel Corporation ICH9M LPC Interface Controller (rev 03)
00:1f.2 SATA controller: Intel Corporation 82801IBM/IEM (ICH9M/ICH9M-E) 4 port SATA Controller [AHCI mode] (rev 03)
02:00.0 Network controller: Qualcomm Atheros AR9285 Wireless Network Adapter (PCI-Express) (rev 01)
03:00.0 Ethernet controller: Qualcomm Atheros AR8121/AR8113/AR8114 Gigabit or Fast Ethernet (rev b0)

Of course the GPU is ancient for a 9-year laptop,while the SSD -> Crucial BX500 (CT240BX500SSD1) , is fresh new. The scheduler for the SSD is noop, while for the spinning disk (for backup) is using deadline.

Can you keep a CPU monitor running while you use these browsers? If you could keep open the internal task manager for each browser as well it’s easier to detect if it’s a plugin or specific site.

You may update laptop’s BIOS: ASUS Global

Model name: Intel(R) Core™2 Duo CPU T9500 @ 2.60GHz

Chipset: 82GL40 (GMCH)
Graphics: Intel GMA 4500MHD.
OpenGL 2.0, etc.
Probably you have problems with video driver - browsers uses it.

Please show

glxinfo | grep -i opengl

and

inxi -Gxxx

You may use Intel Core2 Duo T9900 or Core2 Quad/Extreme: List of Intel Core 2 processors - Wikipedia .

Serial ATA (SATA) Controller
The ICH9 has two integrated SATA host controllers that support independent DMA operation on up to six ports (desktop only) or four ports (mobile only) and supports data transfer rates of up to 3.0 Gb/s (300 MB/s).

Use AHCI for better results.

I don’t get any hangs , but sadly I use the laptop far less than before:


snikolov@mimi:~> cat /sys/block/sda/queue/scheduler 
[mq-deadline] kyber bfq none
snikolov@mimi:~> cat /sys/block/sdb/queue/scheduler 
mq-deadline kyber [bfq] none
snikolov@mimi:~> cat /proc/cmdline 
BOOT_IMAGE=/boot/vmlinuz-4.12.14-lp151.28.52-default root=UUID=ab6c26a3-38e9-4873-aea6-7132763a5389 splash=silent resume=/dev/disk/by-uuid/28c6997b-7202-4354-be28-9ba69d9d778c mitigations=auto quiet scsi_mod.use_blk_mq=1

Bios is latest and using the best CPU I could found in e-bay. It seems T9900 is quite rare:

mimi:~ # lscpu | grep Model\ name
Model name:          Intel(R) Core(TM)2 Duo CPU     T9500  @ 2.60GHz
mimi:~ # dmidecode -s  bios-version
218 

Recently I patched to 15.2 and I had one lockup (HDD led was constantly lit), but I observe such issues very rarely.