All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Antonov <alexander.antonov@linux.intel.com>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	Jiri Olsa <jolsa@redhat.com>, Andi Kleen <ak@linux.intel.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Ian Rogers <irogers@google.com>, Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>
Subject: Re: [PATCH v3 3/5] perf stat: Helper functions for PCIe root ports list in iostat mode
Date: Mon, 1 Feb 2021 20:55:42 +0300	[thread overview]
Message-ID: <01d8c8f5-da91-983d-dc3a-9c1c8c3633de@linux.intel.com> (raw)
In-Reply-To: <CAM9d7cgg1Xv1QhBPQBj_KR1i0yU3ci8-8DatdfC1+7+ZnJdTww@mail.gmail.com>


On 1/29/2021 11:26 AM, Namhyung Kim wrote:
> Hello,
>
> On Tue, Jan 26, 2021 at 5:06 PM Alexander Antonov
> <alexander.antonov@linux.intel.com> wrote:
>> Introduce helper functions to control PCIe root ports list.
>> These helpers will be used in the follow-up patch.
>>
>> Signed-off-by: Alexander Antonov <alexander.antonov@linux.intel.com>
>> ---
> [SNIP]
>> +static int iio_root_ports_list_insert(struct iio_root_ports_list *list,
>> +                                     struct iio_root_port * const rp)
>> +{
>> +       struct iio_root_port **tmp_buf;
>> +
>> +       if (list && rp) {
>> +               rp->idx = list->nr_entries++;
>> +               /* One more for NULL.*/
>> +               tmp_buf = realloc(list->rps,
>> +                                 (list->nr_entries + 1) * sizeof(*list->rps));
> Why is this +1 needed since you already have the number of
> entries in the list?
>
> Thanks,
> Namhyung

Hello,

My first approach for iteration through root ports list was using 
NULL-terminated array.
And seems like I just forgot to remove this code. I will fix it.

Thank you,
Alexander

>
>> +               if (!tmp_buf) {
>> +                       pr_err("Failed to realloc memory\n");
>> +                       return -ENOMEM;
>> +               }
>> +               tmp_buf[rp->idx] = rp;
>> +               tmp_buf[list->nr_entries] = NULL;
>> +               list->rps = tmp_buf;
>> +       }
>> +       return 0;
>> +}
>> --
>> 2.19.1
>>

  parent reply	other threads:[~2021-02-01 17:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-26  8:06 [PATCH v3 0/5] perf stat: Introduce iostat mode to provide I/O performance metrics Alexander Antonov
2021-01-26  8:06 ` [PATCH v3 1/5] perf stat: Add AGGR_PCIE_PORT mode Alexander Antonov
2021-01-26  8:06 ` [PATCH v3 2/5] perf stat: Basic support for iostat in perf Alexander Antonov
2021-01-26  8:06 ` [PATCH v3 3/5] perf stat: Helper functions for PCIe root ports list in iostat mode Alexander Antonov
     [not found]   ` <CAM9d7cgg1Xv1QhBPQBj_KR1i0yU3ci8-8DatdfC1+7+ZnJdTww@mail.gmail.com>
2021-02-01 17:55     ` Alexander Antonov [this message]
2021-01-26  8:06 ` [PATCH v3 4/5] perf stat: Enable iostat mode for x86 platforms Alexander Antonov
2021-01-26  8:06 ` [PATCH v3 5/5] perf: Update .gitignore file Alexander Antonov

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=01d8c8f5-da91-983d-dc3a-9c1c8c3633de@linux.intel.com \
    --to=alexander.antonov@linux.intel.com \
    --cc=acme@kernel.org \
    --cc=ak@linux.intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=irogers@google.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.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 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.