History

mm/shmem: annotate benign data-race in shmem_getattr()

shmem_getattr() reads info->alloced, info->swapped and i_mapping->nrpages without info->lock to decide whether shmem_recalc_inode() should be called. shmem_recalc_inode() recomputes these under info->lock, so a stale read here only affects whether shmem_recalc_inode() runs. Annotate data_race() to silence KCSAN.

Jaeyeon Lee committed 4 months ago

Commit 889d3781 parent 3fe06201 file · +2 −1Browse files

Unified · Split

mm/shmem.c+2−1
@@ -1297,7 +1297,8 @@ static int shmem_getattr(struct mnt_idmap *idmap, · 1296 unmodified lines
12971297 struct inode *inode = path->dentry->d_inode;
12981298 struct shmem_inode_info *info = SHMEM_I(inode);
12991299
1300− if (info->alloced - info->swapped != inode->i_mapping->nrpages)
1300+ /* Fast-path hint; recalc under info->lock corrects any stale read. */
1301+ if (data_race(info->alloced - info->swapped != inode->i_mapping->nrpages))
13011302 shmem_recalc_inode(inode, 0, 0);
13021303
13031304 if (info->fsflags & FS_APPEND_FL)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t