Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1691027

Re: [PATCH v5 1/4]: perf/core: use rb trees for pinned/flexible groups

From Alexander Shishkin <alexander.shishkin@linux.intel.com>
Newsgroups linux.kernel
Subject Re: [PATCH v5 1/4]: perf/core: use rb trees for pinned/flexible groups
Date 2017-07-19 08:40 +0200
Message-ID <u4QOn-4Jj-29@gated-at.bofh.it> (permalink)
References <u1GBP-5sk-19@gated-at.bofh.it> <u4zNw-2nc-27@gated-at.bofh.it> <u4ATf-2Z9-17@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Alexey Budankov <alexey.budankov@linux.intel.com> writes:

>>> +static void
>>> +perf_event_groups_insert(struct perf_event_groups *groups,
>>> +		struct perf_event *event)
>>> +{
>>> +	struct rb_node **node;
>>> +	struct rb_node *parent;
>>> +	struct perf_event *node_event;
>>> +
>>> +	WARN_ON_ONCE(!groups || !event);
>> 
>> I'm pretty sure neither of these is plausible.
>
> Used that for debugging.

It's a bad practice to keep leftovers of debugging code in the
patches. In this particular case, as with most WARN*s that I've seen in
this patchset, it is completely useless, because the code goes ahead and
dereferences the pointers right after the assert, so there'd be an oops
and we'd see it anyway.

Normally, you'd use these assertions if you're actually handling the
undesired scenario, like

    /* Can't happen because XXX */
    if (WARN_ON_ONCE(!groups))
        return -EINVAL;

Also a comment justifying the WARN* is a good thing to have.

> Does it affect performance somehow?

It doesn't matter. Generally, we don't need an reason to remove code, we
need a reason to add code.

Regards,
--
Alex

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Re: [PATCH v5 1/4]: perf/core: use rb trees for pinned/flexible groups Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2017-07-18 14:30 +0200
  Re: [PATCH v5 1/4]: perf/core: use rb trees for pinned/flexible  groups Alexey Budankov <alexey.budankov@linux.intel.com> - 2017-07-18 15:40 +0200
    Re: [PATCH v5 1/4]: perf/core: use rb trees for pinned/flexible groups Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2017-07-19 08:40 +0200

csiph-web