From: Kuniyuki Iwashima <kuniyu@amazon.com>
To: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: Kuniyuki Iwashima <kuniyu@amazon.com>,
Kuniyuki Iwashima <kuni1840@gmail.com>, <netdev@vger.kernel.org>
Subject: [PATCH v1 net-next 3/6] af_unix: Manage inflight graph state as unix_graph_state.
Date: Fri, 3 May 2024 15:31:47 -0700 [thread overview]
Message-ID: <20240503223150.6035-4-kuniyu@amazon.com> (raw)
In-Reply-To: <20240503223150.6035-1-kuniyu@amazon.com>
The graph state is managed by two variables, unix_graph_maybe_cyclic
and unix_graph_grouped.
However, unix_graph_grouped is checked only when unix_graph_maybe_cyclic
is true, so the graph state is actually tri-state.
Let's merge the two variables into unix_graph_state.
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
---
net/unix/garbage.c | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/net/unix/garbage.c b/net/unix/garbage.c
index 7ffb80dd422c..478b2eb479a2 100644
--- a/net/unix/garbage.c
+++ b/net/unix/garbage.c
@@ -112,8 +112,13 @@ static struct unix_vertex *unix_edge_successor(struct unix_edge *edge)
return edge->successor->vertex;
}
-static bool unix_graph_maybe_cyclic;
-static bool unix_graph_grouped;
+enum {
+ UNIX_GRAPH_NOT_CYCLIC,
+ UNIX_GRAPH_MAYBE_CYCLIC,
+ UNIX_GRAPH_CYCLIC,
+};
+
+static unsigned char unix_graph_state;
static void unix_update_graph(struct unix_vertex *vertex)
{
@@ -123,8 +128,7 @@ static void unix_update_graph(struct unix_vertex *vertex)
if (!vertex)
return;
- unix_graph_maybe_cyclic = true;
- unix_graph_grouped = false;
+ unix_graph_state = UNIX_GRAPH_MAYBE_CYCLIC;
}
static LIST_HEAD(unix_unvisited_vertices);
@@ -525,8 +529,7 @@ 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;
+ unix_graph_state = unix_graph_circles ? UNIX_GRAPH_CYCLIC : UNIX_GRAPH_NOT_CYCLIC;
}
static void unix_walk_scc_fast(struct sk_buff_head *hitlist)
@@ -557,7 +560,7 @@ static void unix_walk_scc_fast(struct sk_buff_head *hitlist)
list_replace_init(&unix_visited_vertices, &unix_unvisited_vertices);
if (!unix_graph_circles)
- unix_graph_maybe_cyclic = false;
+ unix_graph_state = UNIX_GRAPH_NOT_CYCLIC;
}
static bool gc_in_progress;
@@ -569,14 +572,14 @@ static void __unix_gc(struct work_struct *work)
spin_lock(&unix_gc_lock);
- if (!unix_graph_maybe_cyclic) {
+ if (unix_graph_state == UNIX_GRAPH_NOT_CYCLIC) {
spin_unlock(&unix_gc_lock);
goto skip_gc;
}
__skb_queue_head_init(&hitlist);
- if (unix_graph_grouped)
+ if (unix_graph_state == UNIX_GRAPH_CYCLIC)
unix_walk_scc_fast(&hitlist);
else
unix_walk_scc(&hitlist);
--
2.30.2
next prev parent reply other threads:[~2024-05-03 22:33 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
2024-05-08 10:08 ` Paolo Abeni
2024-05-08 17:05 ` Kuniyuki Iwashima
2024-05-03 22:31 ` Kuniyuki Iwashima [this message]
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=20240503223150.6035-4-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).