patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Sunil Kumar Kori <skori@marvell.com>
To: David Marchand <david.marchand@redhat.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>,
	"stable@dpdk.org" <stable@dpdk.org>,
	Jerin Jacob Kollanukkaran <jerinj@marvell.com>
Subject: RE: [EXT] [PATCH 3/8] trace: fix leak with regexp
Date: Fri, 23 Sep 2022 07:37:03 +0000	[thread overview]
Message-ID: <CO6PR18MB386087C1D577774870317CC2B4519@CO6PR18MB3860.namprd18.prod.outlook.com> (raw)
In-Reply-To: <CAJFAV8wkDxm+O_d4fsCzV9+mu9W9+KzpNpS3RRALPtyKu8LeOw@mail.gmail.com>

> -----Original Message-----
> From: David Marchand <david.marchand@redhat.com>
> Sent: Friday, September 23, 2022 12:05 PM
> To: Sunil Kumar Kori <skori@marvell.com>
> Cc: dev@dpdk.org; stable@dpdk.org; Jerin Jacob Kollanukkaran
> <jerinj@marvell.com>
> Subject: Re: [EXT] [PATCH 3/8] trace: fix leak with regexp
> 
> On Thu, Sep 22, 2022 at 1:00 PM Sunil Kumar Kori <skori@marvell.com>
> wrote:
> > > @@ -210,15 +210,18 @@ rte_trace_regexp(const char *regex, bool
> enable)
> > >               return -EINVAL;
> > >
> > >       STAILQ_FOREACH(tp, &tp_list, next) {
> > > -             if (regexec(&r, tp->name, 0, NULL, 0) == 0) {
> > > -                     if (enable)
> > > -                             rc = rte_trace_point_enable(tp->handle);
> > > -                     else
> > > -                             rc = rte_trace_point_disable(tp->handle);
> > > -                     found = 1;
> > > +             if (regexec(&r, tp->name, 0, NULL, 0) != 0)
> > > +                     continue;
> > > +
> > > +             if (enable)
> > > +                     rc = rte_trace_point_enable(tp->handle);
> > > +             else
> > > +                     rc = rte_trace_point_disable(tp->handle);
> > > +             if (rc < 0) {
> > > +                     found = 0;
> > > +                     break;
> > >               }
> > > -             if (rc < 0)
> > > -                     return rc;
> > > +             found = 1;
> > >       }
> > >       regfree(&r);
> > >
> > > --
> >
> > I understand the problem addressed by this fix but may be following
> changes will be sufficient to fix it.
> > Please highlight, If I am missing. Just trying to reduce the line of changes.
> >
> > @@ -220,8 +220,10 @@ rte_trace_regexp(const char *regex, bool enable)
> >                                 rc = rte_trace_point_disable(tp->handle);
> >                         found = 1;
> >                 }
> > -               if (rc < 0)
> > -                       return rc;
> > +               if (rc < 0) {
> > +                       found = 0;
> > +                       break;
> > +               }
> >         }
> 
> 
> rc is compared against 0 for all non-matching tracepoints.
> This is unnecessary and fragile.
> 
> I can split this change in two: one for the fix, and one other where the loop is
> updated with a continue and an inverted matching condition like above.
> If going like this, I would update rte_trace_pattern() too, in the second patch.
> 
> WDYT?

Sounds okay. You can proceed in either way. No hard opinion on it. 
> 
> 
> --
> David Marchand


  reply	other threads:[~2022-09-23  7:37 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20220921120359.2201131-1-david.marchand@redhat.com>
2022-09-21 12:03 ` [PATCH 1/8] trace: fix mode for new trace point David Marchand
2022-09-21 12:03 ` [PATCH 2/8] trace: fix mode change David Marchand
2022-09-21 12:03 ` [PATCH 3/8] trace: fix leak with regexp David Marchand
2022-09-22 11:00   ` [EXT] " Sunil Kumar Kori
2022-09-23  6:35     ` David Marchand
2022-09-23  7:37       ` Sunil Kumar Kori [this message]
2022-09-21 12:03 ` [PATCH 4/8] trace: fix dynamically enabling trace points David Marchand
2022-09-22 11:18   ` [EXT] " Sunil Kumar Kori
2022-09-23  6:36     ` David Marchand
2022-09-21 12:03 ` [PATCH 5/8] trace: fix race in debug dump David Marchand
2022-10-11 14:37   ` Jerin Jacob
2022-09-21 12:03 ` [PATCH 6/8] trace: fix metadata dump David Marchand
     [not found] ` <20221004094418.196544-1-david.marchand@redhat.com>
2022-10-04  9:44   ` [PATCH v2 1/9] trace: fix mode for new trace point David Marchand
2022-10-11 14:16     ` Jerin Jacob
2022-10-12  9:05     ` [EXT] " Sunil Kumar Kori
2022-10-04  9:44   ` [PATCH v2 2/9] trace: fix mode change David Marchand
2022-10-11 14:20     ` Jerin Jacob
2022-10-12  9:07     ` [EXT] " Sunil Kumar Kori
2022-10-04  9:44   ` [PATCH v2 3/9] trace: fix leak with regexp David Marchand
2022-10-11 14:21     ` Jerin Jacob
2022-10-12  9:10     ` [EXT] " Sunil Kumar Kori
2022-10-04  9:44   ` [PATCH v2 5/9] trace: fix dynamically enabling trace points David Marchand
2022-10-12  9:23     ` [EXT] " Sunil Kumar Kori
2022-10-12  9:57       ` David Marchand
2022-10-12 10:15         ` Sunil Kumar Kori
2022-10-04  9:44   ` [PATCH v2 6/9] trace: fix race in debug dump David Marchand
2022-10-12  9:25     ` [EXT] " Sunil Kumar Kori
2022-10-04  9:44   ` [PATCH v2 7/9] trace: fix metadata dump David Marchand
2022-10-12  9:28     ` [EXT] " Sunil Kumar Kori
     [not found] ` <20221012123112.2951802-1-david.marchand@redhat.com>
2022-10-12 12:31   ` [PATCH v3 1/9] trace: fix mode for new trace point David Marchand
2022-10-12 12:31   ` [PATCH v3 2/9] trace: fix mode change David Marchand
2022-10-12 12:31   ` [PATCH v3 3/9] trace: fix leak with regexp David Marchand
2022-10-12 12:31   ` [PATCH v3 5/9] trace: fix dynamically enabling trace points David Marchand
2022-10-13 14:53     ` [EXT] " Harman Kalra
2022-10-13 15:51       ` David Marchand
2022-10-13 17:07         ` Harman Kalra
2022-10-13 19:10           ` David Marchand
2022-10-14  4:26             ` Jerin Jacob
2022-10-14  8:19               ` David Marchand
2022-10-14  8:37                 ` Jerin Jacob
2022-10-12 12:31   ` [PATCH v3 6/9] trace: fix race in debug dump David Marchand
2022-10-12 12:31   ` [PATCH v3 7/9] trace: fix metadata dump David Marchand
     [not found] ` <20221018132654.3760561-1-david.marchand@redhat.com>
2022-10-18 13:26   ` [PATCH v4 01/11] trace: fix mode for new trace point David Marchand
2022-10-18 13:26   ` [PATCH v4 02/11] trace: fix mode change David Marchand
2022-10-18 13:26   ` [PATCH v4 03/11] trace: fix leak with regexp David Marchand
2022-10-18 13:26   ` [PATCH v4 05/11] trace: fix dynamically enabling trace points David Marchand
2022-10-18 13:26   ` [PATCH v4 06/11] trace: fix race in debug dump David Marchand
2022-10-18 13:26   ` [PATCH v4 07/11] trace: fix metadata dump 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=CO6PR18MB386087C1D577774870317CC2B4519@CO6PR18MB3860.namprd18.prod.outlook.com \
    --to=skori@marvell.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=jerinj@marvell.com \
    --cc=stable@dpdk.org \
    /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).