Page MenuHomeFreeBSD

tmpfs: restore atime updates for reads from page cache.
ClosedPublic

Authored by kib on Sep 16 2020, 12:54 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Apr 20, 10:44 PM
Unknown Object (File)
Feb 11 2024, 1:45 AM
Unknown Object (File)
Feb 9 2024, 1:51 PM
Unknown Object (File)
Jan 17 2024, 3:01 PM
Unknown Object (File)
Dec 22 2023, 10:29 PM
Unknown Object (File)
Dec 12 2023, 7:11 PM
Unknown Object (File)
Nov 8 2023, 11:51 AM
Unknown Object (File)
Oct 28 2023, 12:40 PM
Subscribers

Details

Summary

Split TMPFS_NODE_ACCCESSED bit into dedicated byte that can be updated atomically without locks or (locked) atomics.

tn_update_getattr() change also contains unrelated bug fix.

Reported by: lwhsu
PR: 249362

(Not tested).

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kib requested review of this revision.Sep 16 2020, 12:54 PM

The tmpfs_set_accessed call in pgread has to move up prior to vfs_smr_exit. I can't make an inline comment for some reason.

On a more general note perhaps this can finally move to just getnanotime() on access and updating the stored value only if it goes forward. While this would incur some loss of concurrency it may be small enough to be more than tolerable, all while finally providing reasonable timestamp accuracy. Note as it is atime is updated who-knows-when. Same goes for other counters.

In D26451#588463, @mjg wrote:

The tmpfs_set_accessed call in pgread has to move up prior to vfs_smr_exit. I can't make an inline comment for some reason.

Done.

On a more general note perhaps this can finally move to just getnanotime() on access and updating the stored value only if it goes forward. While this would incur some loss of concurrency it may be small enough to be more than tolerable, all while finally providing reasonable timestamp accuracy. Note as it is atime is updated who-knows-when. Same goes for other counters.

At least we do not write torn values to Xtime fields. I do not want to take node lock in tmpfs_pgcache_read(), after all efforts I put to remove object and node referencing.

Move write to tn_accesses before vfs_smr_exit().

markj added inline comments.
sys/fs/tmpfs/tmpfs.h
175 ↗(On Diff #77098)

I would add a sentence explaining why the field is split.

sys/fs/tmpfs/tmpfs_subr.c
1866 ↗(On Diff #77098)

atomic_store_8()?

This revision is now accepted and ready to land.Sep 16 2020, 4:19 PM
In D26451#588469, @kib wrote:
In D26451#588463, @mjg wrote:

On a more general note perhaps this can finally move to just getnanotime() on access and updating the stored value only if it goes forward. While this would incur some loss of concurrency it may be small enough to be more than tolerable, all while finally providing reasonable timestamp accuracy. Note as it is atime is updated who-knows-when. Same goes for other counters.

At least we do not write torn values to Xtime fields. I do not want to take node lock in tmpfs_pgcache_read(), after all efforts I put to remove object and node referencing.

But we don't have to have torn writes or any locking. The most aggressive take on it would just store the 4 byte ticks and make sure something eventually takes care of it before a potential wrap around. The general problem is that atime updates from reads on all filesystems is drastically inaccurate - timestamp is updated many seconds later. That said, fixing even if only for tmpfs may be beyond the scope of this patch.

sys/fs/tmpfs/tmpfs_subr.c
1864 ↗(On Diff #77098)

Can we skip tm_ronly checks? Instead it can be asserted that tn_status never gets TMPFS_NODE_ACCESSED nor TMPFS_NODE_MODIFIED bits set and the tn_accessed field can be ignored in tmpfs_itimes.

kib marked 3 inline comments as done.Sep 16 2020, 6:09 PM
In D26451#588524, @mjg wrote:
In D26451#588469, @kib wrote:
In D26451#588463, @mjg wrote:

On a more general note perhaps this can finally move to just getnanotime() on access and updating the stored value only if it goes forward. While this would incur some loss of concurrency it may be small enough to be more than tolerable, all while finally providing reasonable timestamp accuracy. Note as it is atime is updated who-knows-when. Same goes for other counters.

At least we do not write torn values to Xtime fields. I do not want to take node lock in tmpfs_pgcache_read(), after all efforts I put to remove object and node referencing.

But we don't have to have torn writes or any locking. The most aggressive take on it would just store the 4 byte ticks and make sure something eventually takes care of it before a potential wrap around. The general problem is that atime updates from reads on all filesystems is drastically inaccurate - timestamp is updated many seconds later. That said, fixing even if only for tmpfs may be beyond the scope of this patch.

Storing timecounter raw value means that we need to do active scan each second.

sys/fs/tmpfs/tmpfs_subr.c
1864 ↗(On Diff #77098)

It is not that simple, right now code is organized so that we must process all times even after tm_ronly and MNT_RDONLY are set.

I might look at restructuring rw->ro remount, then it could be possible with some adjustments.

kib marked an inline comment as done.

Add comment about tn_accessed.
Use atomic_store_8.
Unrelated style changes will be committed separately.

This revision now requires review to proceed.Sep 16 2020, 6:11 PM
This revision was not accepted when it landed; it landed in state Needs Review.Sep 16 2020, 9:28 PM
This revision was automatically updated to reflect the committed changes.