[LU-14016] libcfs: use atomic64_t for libcfs_kmemory Created: 07/Oct/20  Updated: 29/Oct/20  Resolved: 29/Oct/20

Status: Resolved
Project: Lustre
Component/s: None
Affects Version/s: None
Fix Version/s: Lustre 2.14.0

Type: Bug Priority: Minor
Reporter: Amir Shehata (Inactive) Assignee: Amir Shehata (Inactive)
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Related
Severity: 3
Rank (Obsolete): 9223372036854775807

 Description   

If LNet uses more than ~2.14 GB of memory, then lnet_memused will display negative numbers.



 Comments   
Comment by Gerrit Updater [ 07/Oct/20 ]

Amir Shehata (ashehata@whamcloud.com) uploaded a new patch: https://review.whamcloud.com/40168
Subject: LU-14016 libcfs: use atomic64_t for libcfs_kmemory
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: 138267a313d645d3bab22f3e0045c586af85b813

Comment by Andreas Dilger [ 07/Oct/20 ]

It would probably be good (in a follow-on patch) to change libcfs_kmem (and obd_memory) to be struct percpu_counter instead of atomic64_t to avoid the overhead of atomic updates for every allocation, since we don't really depend on the current value of this variable for anything, only the eventual global consistency.

That would mostly be a matter of changing libcfs_kmem_read() to use percpu_counter_sum() (it is only used at module startup/shutdown so accuracy is more important than performance), libcfs_kmem_inc/dec() to use percpu_counter_add_batch() (with a batch=1M or so, since we don't need frequent updates, only enough for fcb->count to be updated for lnet_memused to be relatively accurate), and adding percpu_counter_init(&libcfs_kmem) at the start of libcfs_init() and percpu_counter_destroy(&libcfs_kmem) after its last usage in libcfs_exit().

Comment by Gerrit Updater [ 29/Oct/20 ]

Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/40168/
Subject: LU-14016 libcfs: use atomic64_t for libcfs_kmem
Project: fs/lustre-release
Branch: master
Current Patch Set:
Commit: 9397f8cf866ad363bc3908b248f41adfa5bd8f1c

Comment by Peter Jones [ 29/Oct/20 ]

Landed for 2.14

Generated at Sat Feb 10 03:06:07 UTC 2024 using Jira 9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c.