From: Martin KaFai Lau <martin.lau@linux.dev>
To: Kuniyuki Iwashima <kuniyu@amazon.com>
Cc: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
David Ahern <dsahern@kernel.org>,
Martin KaFai Lau <martin.lau@kernel.org>,
Kuniyuki Iwashima <kuni1840@gmail.com>,
netdev@vger.kernel.org
Subject: Re: [PATCH v2 net] tcp/dccp: Don't use timer_pending() in reqsk_queue_unlink().
Date: Wed, 9 Oct 2024 22:46:57 -0700 [thread overview]
Message-ID: <a1ecbca9-52c8-4653-a404-961b8e4fc674@linux.dev> (raw)
In-Reply-To: <20241009174226.7738-1-kuniyu@amazon.com>
On 10/9/24 10:42 AM, Kuniyuki Iwashima wrote:
> diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
> index 2c5632d4fddb..23cff5278a64 100644
> --- a/net/ipv4/inet_connection_sock.c
> +++ b/net/ipv4/inet_connection_sock.c
> @@ -1045,12 +1045,13 @@ static bool reqsk_queue_unlink(struct request_sock *req)
> found = __sk_nulls_del_node_init_rcu(sk);
> spin_unlock(lock);
> }
> - if (timer_pending(&req->rsk_timer) && del_timer_sync(&req->rsk_timer))
> - reqsk_put(req);
> +
> return found;
> }
>
> -bool inet_csk_reqsk_queue_drop(struct sock *sk, struct request_sock *req)
> +static bool __inet_csk_reqsk_queue_drop(struct sock *sk,
> + struct request_sock *req,
> + bool from_timer)
> {
> bool unlinked = reqsk_queue_unlink(req);
>
> @@ -1058,8 +1059,17 @@ bool inet_csk_reqsk_queue_drop(struct sock *sk, struct request_sock *req)
> reqsk_queue_removed(&inet_csk(sk)->icsk_accept_queue, req);
> reqsk_put(req);
> }
> +
> + if (!from_timer && timer_delete_sync(&req->rsk_timer))
timer_delete_sync() is now done after the above reqsk_queue_removed().
The reqsk_timer_handler() may do the "req->num_timeout++" while the above
reqsk_queue_removed() needs to check for req->num_timeout. Would it race?
Others lgtm. Thanks for the patch.
> + reqsk_put(req);
> +
> return unlinked;
> }
next prev parent reply other threads:[~2024-10-10 5:47 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-09 17:42 [PATCH v2 net] tcp/dccp: Don't use timer_pending() in reqsk_queue_unlink() Kuniyuki Iwashima
2024-10-10 5:46 ` Martin KaFai Lau [this message]
2024-10-10 17:36 ` Kuniyuki Iwashima
2024-10-12 4:13 ` Martin KaFai Lau
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=a1ecbca9-52c8-4653-a404-961b8e4fc674@linux.dev \
--to=martin.lau@linux.dev \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=kuni1840@gmail.com \
--cc=kuniyu@amazon.com \
--cc=martin.lau@kernel.org \
--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).