DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Carrillo, Erik G" <erik.g.carrillo@intel.com>
To: "Burakov, Anatoly" <anatoly.burakov@intel.com>,
	"rsanford@akamai.com" <rsanford@akamai.com>,
	"thomas@monjalon.net" <thomas@monjalon.net>
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH v2] timer: fix resource leak in finalize
Date: Tue, 7 May 2019 22:04:21 +0000	[thread overview]
Message-ID: <BE54F058557D9A4FAC1D84E2FC6D875723405E77@fmsmsx115.amr.corp.intel.com> (raw)
In-Reply-To: <7baed0b9-432f-be86-5e39-68035bc309a4@intel.com>

Hi Anatoly,

Thanks for the review.  Comments in-line:

<...snipped...>

> >   #define RTE_MAX_DATA_ELS 64
> > +static const struct rte_memzone *rte_timer_data_mz; static
> > +rte_atomic16_t *rte_timer_mz_refcnt;
> >   static struct rte_timer_data *rte_timer_data_arr;
> >   static const uint32_t default_data_id;
> >   static uint32_t rte_timer_subsystem_initialized; @@ -155,6 +157,7 @@
> > rte_timer_subsystem_init_v1905(void)
> >   	struct rte_timer_data *data;
> >   	int i, lcore_id;
> >   	static const char *mz_name = "rte_timer_mz";
> > +	size_t data_arr_size = RTE_MAX_DATA_ELS *
> > +sizeof(*rte_timer_data_arr);
> 
> nitpicking, but... const?
> 

No problem - I'll make this change if this line persists into the next version.

<...snipped...>

> >
> > @@ -205,8 +216,11 @@
> BIND_DEFAULT_SYMBOL(rte_timer_subsystem_init, _v1905, 19.05);
> >   void __rte_experimental
> >   rte_timer_subsystem_finalize(void)
> >   {
> > -	if (rte_timer_data_arr)
> > -		rte_free(rte_timer_data_arr);
> > +	if (!rte_timer_subsystem_initialized)
> > +		return;
> > +
> > +	if (rte_atomic16_dec_and_test(rte_timer_mz_refcnt))
> > +		rte_memzone_free(rte_timer_data_mz);
> 
> I think there's a race here. You may get preempted after test but before
> free, where another secondary could initialize. As far as i know, we also

Indeed, thanks for catching this.

> support a case when secondary initializes after primary stops running.
> 
> Let's even suppose that we allow secondary processes to initialize the timer
> subsystem by reserving memzone and checking rte_errno. You would still
> have a chance of two init/deinit conflicting, because there's a hole between
> memzone allocation and atomic increment.
> 
> I don't think this race can be resolved in a safe way, so we might just have to
> settle for a memory leak.
> 

I don't see a solution here currently either.  I'll look at removing the memzone_free()
call and possibly the rte_timer_subsystem_finalize() API, since it seems like
there's no reason for it to exist if it can't free the allocations.

Regards,
Erik

> >
> >   	rte_timer_subsystem_initialized = 0;
> >   }
> >
> 
> 
> --
> Thanks,
> Anatoly

  parent reply	other threads:[~2019-05-07 22:04 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-01 19:00 [dpdk-dev] [PATCH] " Erik Gabriel Carrillo
2019-05-01 19:00 ` Erik Gabriel Carrillo
2019-05-02  9:18 ` Burakov, Anatoly
2019-05-02  9:18   ` Burakov, Anatoly
2019-05-02 12:19   ` Carrillo, Erik G
2019-05-02 12:19     ` Carrillo, Erik G
2019-05-02 13:03     ` Burakov, Anatoly
2019-05-02 13:03       ` Burakov, Anatoly
2019-05-02 13:48       ` Carrillo, Erik G
2019-05-02 13:48         ` Carrillo, Erik G
2019-05-03 22:54 ` [dpdk-dev] [PATCH v2] " Erik Gabriel Carrillo
2019-05-03 22:54   ` Erik Gabriel Carrillo
2019-05-07 11:03   ` Burakov, Anatoly
2019-05-07 11:03     ` Burakov, Anatoly
2019-05-07 22:04     ` Carrillo, Erik G [this message]
2019-05-07 22:04       ` Carrillo, Erik G
2019-05-08  8:49       ` Burakov, Anatoly
2019-05-08  8:49         ` Burakov, Anatoly
2019-05-08 23:01         ` Carrillo, Erik G
2019-05-08 23:01           ` Carrillo, Erik G
2019-05-09  7:44           ` Thomas Monjalon
2019-05-09  7:44             ` Thomas Monjalon
2019-05-08 22:35   ` [dpdk-dev] [PATCH v3] " Erik Gabriel Carrillo
2019-05-08 22:35     ` Erik Gabriel Carrillo
2019-05-09  8:29     ` Burakov, Anatoly
2019-05-09  8:29       ` Burakov, Anatoly
2019-06-05  9:33       ` Thomas Monjalon
2019-06-05  9:47         ` Burakov, Anatoly
2019-06-25 16:11     ` [dpdk-dev] [PATCH 0/2] Fix timer resource leak Anatoly Burakov
2019-07-05 13:20       ` [dpdk-dev] [PATCH v2 0/1] " Anatoly Burakov
2019-07-05 17:22         ` [dpdk-dev] [PATCH v3 " Anatoly Burakov
2019-07-05 17:22         ` [dpdk-dev] [PATCH v3 1/1] timer: fix resource leak in finalize Anatoly Burakov
2019-07-05 22:06           ` Thomas Monjalon
2019-07-05 13:20       ` [dpdk-dev] [PATCH v2 " Anatoly Burakov
2019-06-25 16:11     ` [dpdk-dev] [PATCH 1/2] eal: add internal locks for timer lib into EAL Anatoly Burakov
2019-06-27 18:41       ` Carrillo, Erik G
2019-07-04  9:09       ` David Marchand
2019-07-04 10:44         ` Burakov, Anatoly
2019-06-25 16:11     ` [dpdk-dev] [PATCH 2/2] timer: fix resource leak in finalize Anatoly Burakov
2019-06-27 18:48       ` Carrillo, Erik G
2019-07-04  9:10       ` David Marchand
2019-07-04 10:45         ` Burakov, Anatoly
2019-07-04 10:50           ` David Marchand

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=BE54F058557D9A4FAC1D84E2FC6D875723405E77@fmsmsx115.amr.corp.intel.com \
    --to=erik.g.carrillo@intel.com \
    --cc=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    --cc=rsanford@akamai.com \
    --cc=thomas@monjalon.net \
    /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).