All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anshuman Khandual <khandual@linux.vnet.ibm.com>
To: Michael Ellerman <mpe@ellerman.id.au>, linuxppc-dev@ozlabs.org
Cc: mikey@neuling.org, sukadev@linux.vnet.ibm.com, dja@axtens.net
Subject: Re: [4/5] powerpc/perf: Change name & type of 'pred' in power_pmu_bhrb_read
Date: Wed, 29 Jul 2015 13:43:40 +0530	[thread overview]
Message-ID: <55B88B34.1030808@linux.vnet.ibm.com> (raw)
In-Reply-To: <20150729032555.CE6CB140E41@ozlabs.org>

On 07/29/2015 08:55 AM, Michael Ellerman wrote:
> On Tue, 2015-30-06 at 08:20:30 UTC, Anshuman Khandual wrote:
>> > Branch record attributes 'mispred' and 'predicted' are single bit
>> > fields as defined in the perf ABI. Hence the data type of the field
>> > 'pred' used during BHRB processing should be changed from integer
>> > to bool. This patch also changes the name of the variable from 'pred'
>> > to 'mispred' making the logical inversion process more meaningful
>> > and readable.
> This whole function is a mess.
> 
> There's no good reason why we're doing the assignment to pred/mispred in two
> places to begin with, so if that was eliminated we wouldn't need a local for
> mispred to begin with.

Not sure whether I got this right. We are assigning mispred once with
the value (val & BHRB_PREDICTION) and then assigning mispred and it's
inversion to two different fields of the branch entry as required.

> 
> Then there's the type juggling, all of which probably works but is fishy and
> horrible.

With this patch and one more (2nd patch of the BHRB SW filter series)
patch, we are trying to make it better.

> 
> You take a u64, bitwise and it with a mask, assign that to a boolean, then take

So that any residual positive value after the "AND" operation will
become logical TRUE for the boolean. We dont use any shifting here
as BHRB_PREDICTION checks for the right most (least significant) bit
in the sequence.

> the boolean, *bitwise* negate that and assign the result to a single bit
> bitfield.

This is getting fixed with a subsequent patch (2nd patch of the BHRB
SW filter series) in a new function called insert_branch.

+static inline void insert_branch(struct cpu_hw_events *cpuhw,
+                       int index, u64 from, u64 to, bool mispred)
+{
+       cpuhw->bhrb_entries[index].from = from;
+       cpuhw->bhrb_entries[index].to = to;
+       cpuhw->bhrb_entries[index].mispred = mispred;
+       cpuhw->bhrb_entries[index].predicted = !mispred;
+}

  reply	other threads:[~2015-07-29  8:13 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-30  8:20 [PATCH 0/5] BHRB fixes, improvements and cleanups Anshuman Khandual
2015-06-30  8:20 ` [PATCH 1/5] powerpc/perf: Drop the branch sample when 'from' cannot be fetched Anshuman Khandual
2015-07-27  4:19   ` [1/5] " Michael Ellerman
2015-07-28  3:08     ` Anshuman Khandual
2015-09-30  9:03       ` Anshuman Khandual
2015-09-30 10:46         ` Michael Ellerman
2015-06-30  8:20 ` [PATCH 2/5] powerpc/perf: Change type of the bhrb_users variable Anshuman Khandual
2015-08-03  1:35   ` [2/5] " Michael Ellerman
2015-06-30  8:20 ` [PATCH 3/5] powerpc/perf: Replace last usage of get_cpu_var with this_cpu_ptr Anshuman Khandual
2015-07-27  5:15   ` [3/5] " Michael Ellerman
2015-07-28  3:37     ` Anshuman Khandual
2015-06-30  8:20 ` [PATCH 4/5] powerpc/perf: Change name & type of 'pred' in power_pmu_bhrb_read Anshuman Khandual
2015-07-29  3:25   ` [4/5] " Michael Ellerman
2015-07-29  8:13     ` Anshuman Khandual [this message]
2015-06-30  8:20 ` [PATCH 5/5] powerpc/perf: Re organize PMU branch filter processing on POWER8 Anshuman Khandual

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=55B88B34.1030808@linux.vnet.ibm.com \
    --to=khandual@linux.vnet.ibm.com \
    --cc=dja@axtens.net \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=mikey@neuling.org \
    --cc=mpe@ellerman.id.au \
    --cc=sukadev@linux.vnet.ibm.com \
    /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.