All of lore.kernel.org
 help / color / mirror / Atom feed
From: Antonio Quartulli <a@unstable.cc>
To: "The list for a Better Approach To Mobile Ad-hoc Networking"
	<b.a.t.m.a.n@lists.open-mesh.org>,
	"Linus Lüssing" <linus.luessing@c0d3.blue>
Cc: Marek Lindner <mareklindner@neomailbox.ch>
Subject: Re: [B.A.T.M.A.N.] [PATCH v2 6/7] batman-adv: ELP - use tp meter to estimate the throughput if otherwise not available
Date: Sat, 4 Aug 2018 17:39:42 +0800	[thread overview]
Message-ID: <7a8296d8-d9e2-bba3-f8cd-42cf5da4f506@unstable.cc> (raw)
In-Reply-To: <20180521144854.GO7162@otheros>


[-- Attachment #1.1: Type: text/plain, Size: 1937 bytes --]

Hi Lunus,

On 21/05/18 22:48, Linus Lüssing wrote:
> On Fri, May 18, 2018 at 09:47:53AM +0800, Marek Lindner wrote:
>> +/**
>> + * batadv_v_elp_tp_start() - start a tp meter session for a neighbor
>> + * @neigh: neighbor to run tp meter on
>> + */
>> +static void batadv_v_elp_tp_start(struct batadv_hardif_neigh_node *neigh)
>> +{
>> +	struct batadv_hard_iface *hard_iface = neigh->if_incoming;
>> +	struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
>> +
>> +	neigh->bat_v.tp_meter_running = true;
>> +	batadv_tp_start(bat_priv, neigh->addr, neigh, 10, NULL, BATADV_TP_ELP);
>> +}
> 
> This seems racy here? We have no ordering constraints between
> the assigment and batadv_tp_start() which might lead to...
> 
>> @@ -152,6 +192,25 @@ static u32 batadv_v_elp_get_throughput(struct batadv_hardif_neigh_node *neigh)
>>  			return throughput * 10;
>>  	}
>>  
>> +fallback_throughput:
>> +	last_tp_run_jiffies = jiffies - neigh->bat_v.last_tp_meter_run;
>> +	last_tp_run_msecs = jiffies_to_msecs(last_tp_run_jiffies);
>> +
>> +	/* check the tp_meter_running flag before checking the timestamp to
>> +	 * avoid a race condition where a new tp meter session is scheduled
>> +	 * right after the previous tp meter session has completed
>> +	 */
>> +	if (!neigh->bat_v.tp_meter_running &&
>> +	    last_tp_run_msecs > BATADV_ELP_TP_RUN_INTERVAL)
>> +		batadv_v_elp_tp_start(neigh);
> 
> ...multiple instances potentially being started at the same time here?
> 

- batadv_tp_start() is only invoked by batadv_v_elp_get_throughput();
- batadv_v_elp_get_throughput() is only invoked by
batadv_v_elp_throughput_metric_update();
- batadv_v_elp_throughput_metric_update() is a periodic function
executed by a timer and we can't have concurrent executions (unless we
use crazy interval values).

Maybe we should add a comment to make this more clear?



-- 
Antonio Quartulli


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2018-08-04  9:39 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-18  1:47 [B.A.T.M.A.N.] [PATCH v2 0/7] B.A.T.M.A.N. V - fallback to tp meter estimation if throughput otherwise not available Marek Lindner
2018-05-18  1:47 ` [B.A.T.M.A.N.] [PATCH v2 1/7] batman-adv: tp_meter - prevent concurrent tp_meter sessions by using workqueue Marek Lindner
2018-08-29  6:56   ` Sven Eckelmann
2018-05-18  1:47 ` [B.A.T.M.A.N.] [PATCH v2 2/7] batman-adv: tp_meter - don't check for existing session Marek Lindner
2018-05-18  1:47 ` [B.A.T.M.A.N.] [PATCH v2 3/7] batman-adv: tp_meter - allow up to 10 queued sessions Marek Lindner
2018-05-18  1:47 ` [B.A.T.M.A.N.] [PATCH v2 4/7] batman-adv: tp_meter - add caller distinction Marek Lindner
2018-05-18  1:47 ` [B.A.T.M.A.N.] [PATCH v2 5/7] batman-adv: tp_meter - add option to perform one-hop test Marek Lindner
2018-05-18  1:47 ` [B.A.T.M.A.N.] [PATCH v2 6/7] batman-adv: ELP - use tp meter to estimate the throughput if otherwise not available Marek Lindner
2018-05-21 13:17   ` Linus Lüssing
2018-05-21 17:51     ` Sven Eckelmann
2018-05-21 19:06     ` Sven Eckelmann
2018-08-04  9:31       ` Antonio Quartulli
2018-05-21 14:43   ` Linus Lüssing
2018-08-04  9:35     ` Marek Lindner
2018-05-21 14:48   ` Linus Lüssing
2018-08-04  9:39     ` Antonio Quartulli [this message]
2018-05-21 15:01   ` Linus Lüssing
2018-08-04  8:59     ` Antonio Quartulli
2018-05-21 16:36   ` Sven Eckelmann
2018-05-18  1:47 ` [B.A.T.M.A.N.] [PATCH v2 7/7] batman-adv: ELP - add throughput meter test duration attribute Marek Lindner
2018-05-21 13:46   ` Linus Lüssing
2018-05-21 13:57     ` Linus Lüssing
2018-08-04  9:05     ` Marek Lindner
2018-05-21 14:34   ` Sven Eckelmann
2018-08-04  8:41     ` Antonio Quartulli
     [not found]       ` <314bf0ac-4c10-da7a-d527-45afe92423fa-2CpIooy/SPIKlTDg6p0iyA@public.gmane.org>
2018-08-04  9:02         ` Sven Eckelmann
2018-08-04  9:02           ` [B.A.T.M.A.N.] " Sven Eckelmann
2018-08-04  9:08           ` Antonio Quartulli
2018-08-04  9:08             ` [B.A.T.M.A.N.] " Antonio Quartulli

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=7a8296d8-d9e2-bba3-f8cd-42cf5da4f506@unstable.cc \
    --to=a@unstable.cc \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    --cc=linus.luessing@c0d3.blue \
    --cc=mareklindner@neomailbox.ch \
    /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.