b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
From: Sven Eckelmann <sven@narfation.org>
To: b.a.t.m.a.n@lists.open-mesh.org
Cc: Marek Lindner <mareklindner@neomailbox.ch>,
	Antonio Quartulli <a@unstable.cc>
Subject: Re: [B.A.T.M.A.N.] [PATCH v2 1/7] batman-adv: tp_meter - prevent concurrent tp_meter sessions by using workqueue
Date: Wed, 29 Aug 2018 08:56:47 +0200	[thread overview]
Message-ID: <2069569.jAo6mdz6e2@bentobox> (raw)
In-Reply-To: <20180518014754.23644-2-mareklindner@neomailbox.ch>

[-- Attachment #1: Type: text/plain, Size: 2492 bytes --]

Hi,

looks like you have reference counting issues here:

On Freitag, 18. Mai 2018 09:47:48 CEST Marek Lindner wrote:
> -static void batadv_tp_start_kthread(struct batadv_tp_vars *tp_vars)
> +static void batadv_tp_start_work(struct batadv_tp_vars *tp_vars)
>  {
> -       struct task_struct *kthread;
> -       struct batadv_priv *bat_priv = tp_vars->bat_priv;
> -       u32 session_cookie;
> -
> -       kref_get(&tp_vars->refcount);
> -       kthread = kthread_create(batadv_tp_send, tp_vars, "kbatadv_tp_meter");
> -       if (IS_ERR(kthread)) {
> -               session_cookie = batadv_tp_session_cookie(tp_vars->session,
> -                                                         tp_vars->icmp_uid);
> -               pr_err("batadv: cannot create tp meter kthread\n");
> -               batadv_tp_batctl_error_notify(BATADV_TP_REASON_MEMORY_ERROR,
> -                                             tp_vars->other_end,
> -                                             bat_priv, session_cookie);
> -
> -               /* drop reserved reference for kthread */
> -               batadv_tp_vars_put(tp_vars);
> -
> -               /* cleanup of failed tp meter variables */
> -               batadv_tp_sender_cleanup(bat_priv, tp_vars);
> -               return;
> -       }
> -
> -       wake_up_process(kthread);
> +       /* init work item that will actually execute the test and schedule it */
> +       INIT_WORK(&tp_vars->test_work, batadv_tp_send);
> +       queue_work(batadv_tp_meter_queue, &tp_vars->test_work);
>  }

You completely ignore here that queue_work can fail. And then you have an item 
with a reference counter > 0 in memory and no one cares  about it.

>  
>  /**
> @@ -1053,13 +1035,10 @@ void batadv_tp_start(struct batadv_priv *bat_priv, const u8 *dst,
>         /* init work item for finished tp tests */
>         INIT_DELAYED_WORK(&tp_vars->finish_work, batadv_tp_sender_finish);
>  
> -       /* start tp kthread. This way the write() call issued from userspace can
> -        * happily return and avoid to block
> +       /* schedule the tp worker. This way the write() call issued from
> +        * userspace can happily return and avoid to block
>          */
> -       batadv_tp_start_kthread(tp_vars);
> -
> -       /* don't return reference to new tp_vars */
> -       batadv_tp_vars_put(tp_vars);
> +       batadv_tp_start_work(tp_vars);
>  }

Just from the context of this function, it isn't clear what happened with the 
reference.

Kind regards,
	Sven

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2018-08-29  6:56 UTC|newest]

Thread overview: 27+ 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 [this message]
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
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
2018-08-04  9:02       ` Sven Eckelmann
2018-08-04  9:08         ` 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=2069569.jAo6mdz6e2@bentobox \
    --to=sven@narfation.org \
    --cc=a@unstable.cc \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    --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 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).