netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kuniyuki Iwashima <kuniyu@amazon.com>
To: <pabeni@redhat.com>
Cc: <davem@davemloft.net>, <edumazet@google.com>, <kuba@kernel.org>,
	<kuni1840@gmail.com>, <kuniyu@amazon.com>,
	<netdev@vger.kernel.org>
Subject: Re: [PATCH v4 net-next 12/15] af_unix: Assign a unique index to SCC.
Date: Wed, 6 Mar 2024 12:59:23 -0800	[thread overview]
Message-ID: <20240306205923.17190-1-kuniyu@amazon.com> (raw)
In-Reply-To: <0bddd6e22f91e0d629b41a84c9e2eb56e3260176.camel@redhat.com>

From: Paolo Abeni <pabeni@redhat.com>
Date: Tue, 05 Mar 2024 09:44:00 +0100
> On Thu, 2024-02-29 at 18:22 -0800, Kuniyuki Iwashima wrote:
> > The definition of the lowlink in Tarjan's algorithm is the
> > smallest index of a vertex that is reachable with at most one
> > back-edge in SCC.  This is not useful for a cross-edge.
> > 
> > If we start traversing from A in the following graph, the final
> > lowlink of D is 3.  The cross-edge here is one between D and C.
> > 
> >   A -> B -> D   D = (4, 3)  (index, lowlink)
> >   ^    |    |   C = (3, 1)
> >   |    V    |   B = (2, 1)
> >   `--- C <--'   A = (1, 1)
> > 
> > This is because the lowlink of D is updated with the index of C.
> > 
> > In the following patch, we detect a dead SCC by checking two
> > conditions for each vertex.
> > 
> >   1) vertex has no edge directed to another SCC (no bridge)
> >   2) vertex's out_degree is the same as the refcount of its file
> > 
> > If 1) is false, there is a receiver of all fds of the SCC and
> > its ancestor SCC.
> > 
> > To evaluate 1), we need to assign a unique index to each SCC and
> > assign it to all vertices in the SCC.
> > 
> > This patch changes the lowlink update logic for cross-edge so
> > that in the example above, the lowlink of D is updated with the
> > lowlink of C.
> > 
> >   A -> B -> D   D = (4, 1)  (index, lowlink)
> >   ^    |    |   C = (3, 1)
> >   |    V    |   B = (2, 1)
> >   `--- C <--'   A = (1, 1)
> > 
> > Then, all vertices in the same SCC have the same lowlink, and we
> > can quickly find the bridge connecting to different SCC if exists.
> > 
> > However, it is no longer called lowlink, so we rename it to
> > scc_index.  (It's sometimes called lowpoint.)
> 
> I'm wondering if there is any reference to this variation of Tarjan's
> algorithm you can point, to help understanding, future memory,
> reviewing.

I don't have any reference... perhaps we can add comment like
/* why ? git-blame me. */ or .rst file under Documentation/ about
why GC is needed, how GC works / what algorithm is used, etc.

When I was wondering the same thing, I googled and found someone
who had the same question, but there was no reference.

  https://stackoverflow.com/questions/23213993/what-is-the-lowelink-mean-of-tarjans-algorithm

There might be a text book but I couldn't find online resources.
Even wiki says it looks odd.

  > // The next line may look odd - but is correct.
  > // It says w.index not w.lowlink; that is deliberate and from the original paper
  > v.lowlink := min(v.lowlink, w.index)
  https://en.wikipedia.org/wiki/Tarjan%27s_strongly_connected_components_algorithm

Regarding "lowpoint", I saw it in the wiki for the first time.

  > The lowlink is different from the lowpoint, which is the smallest
  > index reachable from v through any part of the graph.[1]: 156 [2]

In a pdf linked from the wiki:

  > lowpoint(v) = The lowest numbered vertex reachable from v using
  > zero or more tree edges followed by at most one back or cross edge.
  https://www.cs.cmu.edu/~15451-f18/lectures/lec19-DFS-strong-components.pdf

But I've just found that the original paper used LOWPT, which
is called lowlink now... :S

  > LOWPT(v) :=min(LOWPT(v) ,NUMBER(w)) ;
  https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=4569669

  reply	other threads:[~2024-03-06 20:59 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-01  2:22 [PATCH v4 net-next 00/15] af_unix: Rework GC Kuniyuki Iwashima
2024-03-01  2:22 ` [PATCH v4 net-next 01/15] af_unix: Allocate struct unix_vertex for each inflight AF_UNIX fd Kuniyuki Iwashima
2024-03-01  2:22 ` [PATCH v4 net-next 02/15] af_unix: Allocate struct unix_edge " Kuniyuki Iwashima
2024-03-05  8:47   ` Paolo Abeni
2024-03-06 19:44     ` Kuniyuki Iwashima
2024-03-01  2:22 ` [PATCH v4 net-next 03/15] af_unix: Link struct unix_edge when queuing skb Kuniyuki Iwashima
2024-03-01  2:22 ` [PATCH v4 net-next 04/15] af_unix: Bulk update unix_tot_inflight/unix_inflight " Kuniyuki Iwashima
2024-03-01  2:22 ` [PATCH v4 net-next 05/15] af_unix: Iterate all vertices by DFS Kuniyuki Iwashima
2024-03-05  8:53   ` Paolo Abeni
2024-03-06 20:14     ` Kuniyuki Iwashima
2024-03-07  9:08       ` Paolo Abeni
2024-03-01  2:22 ` [PATCH v4 net-next 06/15] af_unix: Detect Strongly Connected Components Kuniyuki Iwashima
2024-03-01  2:22 ` [PATCH v4 net-next 07/15] af_unix: Save listener for embryo socket Kuniyuki Iwashima
2024-03-01  2:22 ` [PATCH v4 net-next 08/15] af_unix: Fix up unix_edge.successor " Kuniyuki Iwashima
2024-03-01  2:22 ` [PATCH v4 net-next 09/15] af_unix: Save O(n) setup of Tarjan's algo Kuniyuki Iwashima
2024-03-01  2:22 ` [PATCH v4 net-next 10/15] af_unix: Skip GC if no cycle exists Kuniyuki Iwashima
2024-03-01  2:22 ` [PATCH v4 net-next 11/15] af_unix: Avoid Tarjan's algorithm if unnecessary Kuniyuki Iwashima
2024-03-01  2:22 ` [PATCH v4 net-next 12/15] af_unix: Assign a unique index to SCC Kuniyuki Iwashima
2024-03-05  8:44   ` Paolo Abeni
2024-03-06 20:59     ` Kuniyuki Iwashima [this message]
2024-03-01  2:22 ` [PATCH v4 net-next 13/15] af_unix: Detect dead SCC Kuniyuki Iwashima
2024-03-01  2:22 ` [PATCH v4 net-next 14/15] af_unix: Replace garbage collection algorithm Kuniyuki Iwashima
2024-03-01  2:22 ` [PATCH v4 net-next 15/15] selftest: af_unix: Test GC for SCM_RIGHTS Kuniyuki Iwashima
2024-03-04 16:18 ` [PATCH v4 net-next 00/15] af_unix: Rework GC Paolo Abeni
2024-03-04 17:31   ` Kuniyuki Iwashima

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=20240306205923.17190-1-kuniyu@amazon.com \
    --to=kuniyu@amazon.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=kuni1840@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /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;
as well as URLs for NNTP newsgroup(s).