Netdev List
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: dwindsor@gmail.com
Cc: netdev@vger.kernel.org, keescook@chromium.org,
	elena.reshetova@intel.com, ishkamiel@gmail.com
Subject: Re: Reference counting struct inet_peer
Date: Tue, 24 Jan 2017 14:20:35 -0500 (EST)	[thread overview]
Message-ID: <20170124.142035.1532512255377175036.davem@davemloft.net> (raw)
In-Reply-To: <CAEXv5_j1cz1EUPgmAKO5OHxKcoHVLuPPVRs316CWyMpw8UtpRw@mail.gmail.com>

From: David Windsor <dwindsor@gmail.com>
Date: Mon, 23 Jan 2017 07:42:51 -0500

> struct inet_peer objects get freed when their reference count
> becomes -1, not 0 as is the usual case.  Is there a reason why this
> is so?

inet peer entries that sit in the tree, but have no other reference
taken, have a reference count of zero.

Therefore, any entry which has a reference count of zero can be
safely garbage collected from the tree.

When the garbage collector purges entries with a zero refcnt, it
atomically sets the refcnt to -1 so that other threads of control
in RCU protected sections that still see this entry in the tree
will not be able to grab it for use.

The -1 marker is used as a synchronization mechanism between the
GC and lookup paths.

Once -1 is atomically set, the GC code knows that no external
reference can be created.

      parent reply	other threads:[~2017-01-24 19:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-23 12:42 Reference counting struct inet_peer David Windsor
2017-01-24  7:38 ` Julian Anastasov
2017-01-24 11:05   ` David Windsor
2017-01-24 19:20 ` David Miller [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170124.142035.1532512255377175036.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=dwindsor@gmail.com \
    --cc=elena.reshetova@intel.com \
    --cc=ishkamiel@gmail.com \
    --cc=keescook@chromium.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox