Skip to content

When is gf_mem_acct_fini() called and actually does something? #2775

Answered by mykaul
mykaul asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks, I got slightly confused, and you've corrected it well, but I still don't see how in _gf_free() it'll ever clear anything, let me try again:

  1. In xlator_mem_acct_init() we set refcnt to 1:
GF_ATOMIC_INIT(xl->mem_acct->refcnt, 1);
  1. On the first allocation of a specific type, we increment it again, in gf_mem_set_acct_info() function:
        /* We only take a reference for each memory type used, not for each
         * allocation. This minimizes the use of atomic operations. */
        if (new_ref) {
            GF_ATOMIC_INC(mem_acct->refcnt);
        }
  1. When we __gf_free(), if it's the last allocation of that specific type, we call xlator_mem_acct_unref():
    if (last_ref) {
 …

Replies: 4 comments 4 replies

Comment options

mykaul
Sep 17, 2021
Collaborator Author

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

mykaul
Sep 21, 2021
Collaborator Author

You must be logged in to vote
1 reply
@mohit84
Comment options

mohit84 Sep 22, 2021
Collaborator

Answer selected by mohit84
Comment options

mykaul
Sep 29, 2021
Collaborator Author

You must be logged in to vote
3 replies
@mohit84
Comment options

mohit84 Sep 29, 2021
Collaborator

@mykaul
Comment options

mykaul Sep 29, 2021
Collaborator Author

@mohit84
Comment options

mohit84 Sep 29, 2021
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants