mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Liav Rehana <liavr@mellanox.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"john.stultz@linaro.org" <john.stultz@linaro.org>,
	Noam Camus <noamca@mellanox.com>,
	Elad Kanfi <eladkan@mellanox.com>
Subject: RE: [PATCH] Fix chance of sign extension to nsec after its msb is set during calculation.
Date: Sun, 4 Sep 2016 11:01:51 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.20.1609041057540.5647@nanos> (raw)
In-Reply-To: <VI1PR0501MB2461D0661B3417EC9251703AC5E70@VI1PR0501MB2461.eurprd05.prod.outlook.com>

On Sun, 4 Sep 2016, Liav Rehana wrote:

Please do not top post and trim your reply.

> The root of the problem is that in case the multiplication of delta and
> tkr->mult in the line that I've changed is too big that the MSB of the
> result is set, then the shift will cause an unwanted sign extension.

I completely understand that, but as I said before:

> > This typecast is just a baindaid. What happens if you double the
> > suspend time?  The multiplication will simply overflow. So the proper
> > fix is to sanity check delta and do multiple conversions if delta is
> > big enough.  Preferrably this happens somewhere at the call site and
> > not in this hotpath function.

> That sign extension will be avoided completely if the variable nsec was
> unsigned (u64 instead of s64), so I think the correct solution for this
> is to change the type of nsec to u64.

That's a different story and its not a solution for the general problem of

       delta * mult >= (1 << 31) or delta * mult >= (1 << 32)

Thanks,

	tglx

  reply	other threads:[~2016-09-04  9:04 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-01 11:14 Liav Rehana
2016-09-02  8:49 ` Thomas Gleixner
2016-09-02 18:30   ` Thomas Gleixner
2016-09-02 18:47     ` Thomas Gleixner
2016-09-04  6:40     ` Liav Rehana
2016-09-04  9:01       ` Thomas Gleixner [this message]
2016-09-04 10:03         ` Liav Rehana
2016-09-04 10:39           ` Thomas Gleixner
2016-09-07  3:22     ` John Stultz
2016-09-11  6:31       ` Liav Rehana
2016-09-21 21:12         ` John Stultz
2016-09-21 12:52       ` Liav Rehana

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=alpine.DEB.2.20.1609041057540.5647@nanos \
    --to=tglx@linutronix.de \
    --cc=eladkan@mellanox.com \
    --cc=john.stultz@linaro.org \
    --cc=liavr@mellanox.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=noamca@mellanox.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®