[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


File: 2026_01_29.png (526 KB, 1350x740)
526 KB
526 KB PNG
previous: >>107993991

#define __NR_msync                26

https://man7.org/linux/man-pages/man2/msync.2.html

a fine enough syscall. everyone wants to make sure their writes are actually flushed back to disk, where appropriate. but i don't think many people actually bother to use this syscall. generally i suspect most people just assume things will get flushed by the kernel relatively quickly. which isn't necessarily an unreasonable expectation, but as can be seen from the man page, there are no guarantees without it!
have you ever been burned by something similar?

relevant resources:
man man

man syscalls

https://man7.org/linux/man-pages/
https://linux.die.net/man/
https://elixir.bootlin.com/linux/
https://elixir.bootlin.com/musl/
https://elixir.bootlin.com/glibc/
>>
>>108003055
>everyone wants to make sure their writes are actually flushed back to disk
I'm libeatmydatamaxxing
>>
>>108003536
lol
>>
>>108003536
>libeatmydatamaxxing
based....
>>
File: images.jpg (8 KB, 259x194)
8 KB
8 KB JPG
Lookin' at the crowd
And I see your body sway, come on
Wishin' I could thank you
In a different way, come on
'Cause all of your time spent
Keeps us alive, yeah
All you people, can't you see, can't you see
How your love's affecting our reality?
Every time we're down, you can make it right
And that makes you larger than life
>>
>>108004564
>>108004571
I'm also tmpfstacked

#
# on startup
#
user=$(basename $path)
grep -q $user /etc/passwd || break

uid=$(id -u $user)
gid=$(id -g $user)

mkdir -m 700 -p /run/user/$uid
chown $uid:$gid /run/user/$uid

tmpfs_root=/run/user/$uid/tmpfs
mkdir -m 700 -p $tmpfs_root
chown $uid:$gid $tmpfs_root

for target in .mozilla .cache/mozilla; do
if [ -d $path/$target ] && ! [ -e $tmpfs_root/$target ]; then
(
umask 077
mkdir -p $tmpfs_root/$target
chown $uid:$gid $tmpfs_root/$target
)
options="uid=$uid,gid=$gid,mode=$(stat -c %a $path/$target),size=50%"
mount -t tmpfs -o $options tmpfs $tmpfs_root/$target
rsync -a $path/$target/ $tmpfs_root/$target/
mount --move $tmpfs_root/$target $path/$target
fi
done

#
# on shutdown
#
user=$(basename $path)
grep -q $user /etc/passwd || break

uid=$(id -u $user)
gid=$(id -g $user)
tmpfs_root=/run/user/$uid/tmpfs

if ! [ -d $tmpfs_root ]; then
break
fi

for target in .mozilla .cache/mozilla; do
if mountpoint -q $path/$target && [ -d $tmpfs_root/$target ]; then
open_fd_pid=$(lsof +i -t $path/$target)
kill -15 $open_fd_pid 2> /dev/null
waitpid -t 5 -e $open_fd_pid 2> /dev/null
kill -9 $open_fd_pid 2> /dev/null
mount --move $path/$target $tmpfs_root/$target
rsync -a --checksum --inplace --no-whole-file --delete $tmpfs_root/$target/ $path/$target/
umount $tmpfs_root/$target
rmdir $tmpfs_root/$target
fi
done
>>
>>108003055
I just call sync manually from command line and wait.
>>
>>108003055
why are we having this thread when the previous one is still up?
>>
>>108006079
i make a thread about a new syscall every day. if people want to keep an old thread alive because there's good discussion, that's totally fine and encouraged, but it's got nothing to do with the next day's thread
>>
>>108006106
cool cool, I just didn't know that was the plan.

So apparently you can filter specific syscalls with the -e flag on strace, pretty usefull.

strace -e read cp x /dev/null
.....
read(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 262144) = 262144
....
>>
>>108006031
What are you confused about?
>>
>>108003055
>have you ever been burned by something similar?
I use mmap with map_private some 99% of the time, so no, I don't think I have.
>>
>>108004634
...eehh can't you just make .cache a tmpfs through /etc/fstab?
>>
>>108003055
>Storage systems often present a durability/performance trade-off to
users. If the user wishes data that is written to be immediately durable,
the system must go through the full effort of committing the newly-
written data to disk, and thus the write is slow (but safe). However, if
the user can tolerate the loss of a little data, the system can buffer writes in memory for some time and write them later to the disk (in the background). Doing so makes writes appear to complete quickly, thus improving perceived performance; however, if a crash occurs, writes not yet committed to disk will be lost, and hence the trade-off.

> for example, if an inode bitmap is updated when one file is created and then updated moments later as another file is created, the file system saves an I/O by delaying the write after the first update.

By using msync you're keeping the kernel from scheduling and batching writes, therefore worsening performance. Aren't most systems stable enough to allow the kernel to buffer a write and eventually flush it out as it sees fit? Unless you're working on a database, what's the point of manually flushing things out?
>>
>>108010123
probably in most cases there is no point!



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.