From: Sven Eckelmann <sven@narfation.org>
To: Antonio Quartulli <a@unstable.cc>, Remi Pommarel <repk@triplefau.lt>
Cc: b.a.t.m.a.n@lists.open-mesh.org,
Marek Lindner <mareklindner@neomailbox.ch>,
Simon Wunderlich <sw@simonwunderlich.de>
Subject: Re: [PATCH v3 1/5] batman-adv: Do not send uninitialized TT changes
Date: Thu, 21 Nov 2024 19:02:43 +0100 [thread overview]
Message-ID: <4345009.mogB4TqSGs@ripper> (raw)
In-Reply-To: <Zz9MrP6LBw0eY_Uv@pilgrim>
[-- Attachment #1: Type: text/plain, Size: 2746 bytes --]
On Thursday, 21 November 2024 16:07:24 CET Remi Pommarel wrote:
> So the patch would be quite similar, only tt->tt.changes_list_lock will
> be taken sooner in batadv_tt_tvlv_container_update().
>
> That will fix the ADD between two read situation as you described
> though.
>
> Do you still prefer this option ?
I can't speak for Antonio but I think I would prefer for the fix the current
version. The locking one would end up again with nested spinlocks and maybe
more refactoring. And it might be nicer for the stable backports to have less
noise in the patch.
Btw. just noticed that the code (not in your change - but overall) for the
filling of diff entries could have been something like:
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -980,6 +980,7 @@ static void batadv_tt_tvlv_container_update(struct
batadv_priv *bat_priv)
int tt_diff_entries_count = 0;
bool drop_changes = false;
size_t tt_extra_len = 0;
+ LIST_HEAD(tt_diffs);
u16 tvlv_len;
tt_diff_entries_num = READ_ONCE(bat_priv->tt.local_changes);
@@ -1011,9 +1012,10 @@ static void batadv_tt_tvlv_container_update(struct
batadv_priv *bat_priv)
spin_lock_bh(&bat_priv->tt.changes_list_lock);
bat_priv->tt.local_changes = 0;
+ list_splice_init(&bat_priv->tt.changes_list, &tt_diffs);
+ spin_unlock_bh(&bat_priv->tt.changes_list_lock);
- list_for_each_entry_safe(entry, safe, &bat_priv->tt.changes_list,
- list) {
+ list_for_each_entry_safe(entry, safe, &tt_diffs, list) {
if (tt_diff_entries_count < tt_diff_entries_num) {
memcpy(tt_change + tt_diff_entries_count,
&entry->change,
@@ -1023,7 +1025,6 @@ static void batadv_tt_tvlv_container_update(struct
batadv_priv *bat_priv)
list_del(&entry->list);
kmem_cache_free(batadv_tt_change_cache, entry);
}
- spin_unlock_bh(&bat_priv->tt.changes_list_lock);
tt_extra_len = batadv_tt_len(tt_diff_entries_num -
tt_diff_entries_count);
And then you can also move this before "tt_diff_entries_num = ..." and
save the corresponding bat_priv->tt.local_changes for the spliced list to the
inside the lock also in a local variable. And then operate on this variable
for the other decisions. Of course, you must still clean the local list in
case of an error. Which of course would slightly change the behavior in case
of an allocation error in batadv_tt_prepare_tvlv_local_data (which would
previously kept the list as it was).
But if it would be done like this then we could also remove the READ_ONCE and
not introduce the WRITE_ONCE - just because local_changes is only touched
inside a locked area (see changes_list_lock).
Please double check these statements - this was just a simple brain dump.
Kind regards,
Sven
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2024-11-21 18:03 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-20 17:47 [PATCH v3 0/5] batman-adv: TT change events fixes and improvements Remi Pommarel
2024-11-20 17:47 ` [PATCH v3 1/5] batman-adv: Do not send uninitialized TT changes Remi Pommarel
2024-11-21 13:05 ` Antonio Quartulli
2024-11-21 13:56 ` Remi Pommarel
2024-11-21 15:07 ` Remi Pommarel
2024-11-21 18:02 ` Sven Eckelmann [this message]
2024-11-21 20:24 ` Remi Pommarel
2024-11-21 21:07 ` Antonio Quartulli
2024-11-22 8:16 ` Sven Eckelmann
2024-11-20 17:47 ` [PATCH v3 2/5] batman-adv: Remove uninitialized data in full table TT response Remi Pommarel
2024-11-21 13:14 ` Antonio Quartulli
2024-11-21 18:20 ` Sven Eckelmann
2024-11-21 20:55 ` Antonio Quartulli
2024-11-20 17:47 ` [PATCH v3 3/5] batman-adv: Do not let TT changes list grows indefinitely Remi Pommarel
2024-11-21 13:50 ` Antonio Quartulli
2024-11-21 14:18 ` Remi Pommarel
2024-11-20 17:47 ` [PATCH v3 4/5] batman-adv: Remove atomic usage for tt.local_changes Remi Pommarel
2024-11-21 9:04 ` Sven Eckelmann
2024-11-21 9:28 ` Remi Pommarel
2024-11-21 9:34 ` Sven Eckelmann
2024-11-20 17:47 ` [PATCH v3 5/5] batman-adv: Don't keep redundant TT change events Remi Pommarel
2024-11-21 8:43 ` Sven Eckelmann
2024-11-21 9:13 ` Remi Pommarel
2024-11-21 9:23 ` Sven Eckelmann
2024-11-21 9:30 ` Sven Eckelmann
2024-11-21 9:35 ` Remi Pommarel
2024-11-20 19:46 ` [PATCH v3 0/5] batman-adv: TT change events fixes and improvements Sven Eckelmann
2024-11-20 19:54 ` Remi Pommarel
2024-11-20 20:29 ` Antonio Quartulli
2024-11-20 21:04 ` Sven Eckelmann
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=4345009.mogB4TqSGs@ripper \
--to=sven@narfation.org \
--cc=a@unstable.cc \
--cc=b.a.t.m.a.n@lists.open-mesh.org \
--cc=mareklindner@neomailbox.ch \
--cc=repk@triplefau.lt \
--cc=sw@simonwunderlich.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.