Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, igt-dev@lists.freedesktop.org
Cc: Intel-gfx@lists.freedesktop.org
Subject: Re: [Intel-gfx] [igt-dev] [PATCH i-g-t] i915/perf_pmu: Fix perf fd leak
Date: Tue, 13 Oct 2020 11:34:11 +0100	[thread overview]
Message-ID: <209839f0-10d9-75a0-abba-2c64e57407c0@linux.intel.com> (raw)
In-Reply-To: <160258345334.2946.10818279953482792145@build.alporthouse.com>


On 13/10/2020 11:04, Chris Wilson wrote:
> Quoting Tvrtko Ursulin (2020-10-13 10:46:12)
>> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>>
>> As it turns out opening the perf fd in group mode still produces separate
>> file descriptors for all members of the group, which in turn need to be
>> closed manually to avoid leaking them.
> 
> Hmm. That caught me by surprise, but yes while close(group) does call
> free_event() on all its children [aiui], it will not remove the fd and
> each event does receive its own fd. And since close(child) will call
> into perf_event_release, we do have to keep the fd alive until the end.
>   
>> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>> ---
>>   tests/i915/perf_pmu.c | 130 +++++++++++++++++++++++++-----------------
>>   1 file changed, 78 insertions(+), 52 deletions(-)
>>
>> diff --git a/tests/i915/perf_pmu.c b/tests/i915/perf_pmu.c
>> index 873b275dca6b..6f8bec28d274 100644
>> --- a/tests/i915/perf_pmu.c
>> +++ b/tests/i915/perf_pmu.c
>> @@ -475,7 +475,8 @@ busy_check_all(int gem_fd, const struct intel_execution_engine2 *e,
>>   
>>          end_spin(gem_fd, spin, FLAG_SYNC);
>>          igt_spin_free(gem_fd, spin);
>> -       close(fd[0]);
>> +       for (i = 0; i < num_engines; i++)
>> +               close(fd[i]);
> 
> close_group(fd, num_engines) ?

I am not too keen on that since there is local open_group which does not 
operate on the fd array. Making open_group manage the array and count 
crossed my mind but it felt a bit too much.

Regards,

Tvrtko


_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2020-10-13 10:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-13  9:46 [Intel-gfx] [PATCH i-g-t] i915/perf_pmu: Fix perf fd leak Tvrtko Ursulin
2020-10-13  9:52 ` Tvrtko Ursulin
2020-10-13  9:54 ` [Intel-gfx] [PATCH i-g-t v2] " Tvrtko Ursulin
2020-10-13 10:04 ` [Intel-gfx] [igt-dev] [PATCH i-g-t] " Chris Wilson
2020-10-13 10:34   ` Tvrtko Ursulin [this message]
2020-10-13 10:40     ` Chris Wilson

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=209839f0-10d9-75a0-abba-2c64e57407c0@linux.intel.com \
    --to=tvrtko.ursulin@linux.intel.com \
    --cc=Intel-gfx@lists.freedesktop.org \
    --cc=chris@chris-wilson.co.uk \
    --cc=igt-dev@lists.freedesktop.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