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 v1 net-next 2/6] af_unix: Save the number of loops in inflight graph.
Date: Tue, 7 May 2024 09:11:36 -0700 [thread overview]
Message-ID: <20240507161136.78482-1-kuniyu@amazon.com> (raw)
In-Reply-To: <37bb5b56bc27dbacfb48914f049efbb2bb8892f5.camel@redhat.com>
From: Paolo Abeni <pabeni@redhat.com>
Date: Tue, 07 May 2024 15:54:33 +0200
> On Fri, 2024-05-03 at 15:31 -0700, Kuniyuki Iwashima wrote:
> > unix_walk_scc_fast() calls unix_scc_cyclic() for every SCC so that we
> > can make unix_graph_maybe_cyclic false when all SCC are cleaned up.
> >
> > If we count the number of loops in the graph during Tarjan's algorithm,
> > we need not call unix_scc_cyclic() in unix_walk_scc_fast().
> >
> > Instead, we can just decrement the number when calling unix_collect_skb()
> > and update unix_graph_maybe_cyclic based on the count.
> >
> > Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
> > ---
> > net/unix/garbage.c | 19 +++++++++++--------
> > 1 file changed, 11 insertions(+), 8 deletions(-)
> >
> > diff --git a/net/unix/garbage.c b/net/unix/garbage.c
> > index 1f8b8cdfcdc8..7ffb80dd422c 100644
> > --- a/net/unix/garbage.c
> > +++ b/net/unix/garbage.c
> > @@ -405,6 +405,7 @@ static bool unix_scc_cyclic(struct list_head *scc)
> >
> > static LIST_HEAD(unix_visited_vertices);
> > static unsigned long unix_vertex_grouped_index = UNIX_VERTEX_INDEX_MARK2;
> > +static unsigned long unix_graph_circles;
> >
> > static void __unix_walk_scc(struct unix_vertex *vertex, unsigned long *last_index,
> > struct sk_buff_head *hitlist)
> > @@ -494,8 +495,8 @@ static void __unix_walk_scc(struct unix_vertex *vertex, unsigned long *last_inde
> >
> > if (scc_dead)
> > unix_collect_skb(&scc, hitlist);
> > - else if (!unix_graph_maybe_cyclic)
> > - unix_graph_maybe_cyclic = unix_scc_cyclic(&scc);
> > + else if (unix_scc_cyclic(&scc))
> > + unix_graph_circles++;
> >
> > list_del(&scc);
> > }
> > @@ -509,7 +510,7 @@ static void unix_walk_scc(struct sk_buff_head *hitlist)
> > {
> > unsigned long last_index = UNIX_VERTEX_INDEX_START;
> >
> > - unix_graph_maybe_cyclic = false;
> > + unix_graph_circles = 0;
> >
> > /* Visit every vertex exactly once.
> > * __unix_walk_scc() moves visited vertices to unix_visited_vertices.
> > @@ -524,13 +525,12 @@ static void unix_walk_scc(struct sk_buff_head *hitlist)
> > list_replace_init(&unix_visited_vertices, &unix_unvisited_vertices);
> > swap(unix_vertex_unvisited_index, unix_vertex_grouped_index);
> >
> > + unix_graph_maybe_cyclic = !!unix_graph_circles;
> > unix_graph_grouped = true;
> > }
> >
> > static void unix_walk_scc_fast(struct sk_buff_head *hitlist)
> > {
> > - unix_graph_maybe_cyclic = false;
> > -
> > while (!list_empty(&unix_unvisited_vertices)) {
> > struct unix_vertex *vertex;
> > struct list_head scc;
> > @@ -546,15 +546,18 @@ static void unix_walk_scc_fast(struct sk_buff_head *hitlist)
> > scc_dead = unix_vertex_dead(vertex);
> > }
> >
> > - if (scc_dead)
> > + if (scc_dead) {
> > unix_collect_skb(&scc, hitlist);
> > - else if (!unix_graph_maybe_cyclic)
> > - unix_graph_maybe_cyclic = unix_scc_cyclic(&scc);
> > + unix_graph_circles--;
>
> Possibly WARN_ON_ONCE(unix_graph_circles < 0) ?
Will add in v2.
>
> I find this patch a little scaring - meaning I can't understand it
> fully,
> I'm wondering if it would make any sense to postpone this patch
> to the next cycle?
It's fine by me to postpone patch 2 - 5, but it would be appreciated
if patch 1 makes it to this cycle.
Thanks!
next prev parent reply other threads:[~2024-05-07 16:11 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-03 22:31 [PATCH v1 net-next 0/6] af_unix: GC cleanup and optimisation Kuniyuki Iwashima
2024-05-03 22:31 ` [PATCH v1 net-next 1/6] af_unix: Add dead flag to struct scm_fp_list Kuniyuki Iwashima
2024-05-03 22:31 ` [PATCH v1 net-next 2/6] af_unix: Save the number of loops in inflight graph Kuniyuki Iwashima
2024-05-07 13:54 ` Paolo Abeni
2024-05-07 16:11 ` Kuniyuki Iwashima [this message]
2024-05-08 10:08 ` Paolo Abeni
2024-05-08 17:05 ` Kuniyuki Iwashima
2024-05-03 22:31 ` [PATCH v1 net-next 3/6] af_unix: Manage inflight graph state as unix_graph_state Kuniyuki Iwashima
2024-05-03 22:31 ` [PATCH v1 net-next 4/6] af_unix: Move wait_for_unix_gc() to unix_prepare_fpl() Kuniyuki Iwashima
2024-05-03 22:31 ` [PATCH v1 net-next 5/6] af_unix: Schedule GC based on graph state during sendmsg() Kuniyuki Iwashima
2024-05-03 22:31 ` [PATCH v1 net-next 6/6] af_unix: Schedule GC only if loop exists during close() 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=20240507161136.78482-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).