mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "chengjian (D)" <cj.chengjian@huawei.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: <huawei.libin@huawei.com>, <xiexiuqi@huawei.com>,
	<yangyingliang@huawei.com>, <mingo@redhat.com>,
	<linux-kernel@vger.kernel.org>,
	"chengjian (D)" <cj.chengjian@huawei.com>
Subject: Re: [PATCH] sched/fair: Use 'unsigned long' for group_shares,group_runnable
Date: Mon, 15 Apr 2019 23:50:49 +0800	[thread overview]
Message-ID: <8c8e96d0-226b-de46-d498-0d8a6947b4c9@huawei.com> (raw)
In-Reply-To: <20190415152549.GQ11158@hirez.programming.kicks-ass.net>


On 2019/4/15 23:25, Peter Zijlstra wrote:
> On Mon, Apr 15, 2019 at 11:20:31PM +0800, chengjian (D) wrote:
>> Hi, Peter
>>
>>
>> On 2019/4/15 20:46, Peter Zijlstra wrote:
>>
>> I write a demo about this, which I described it as overflow.
> I'm not saying there's no overflow, I'm saying there's nothing UB about
> it.
>

Yeah. I got it.

This may not be an undefined behavior,

but rather a bug or logic error caused by overflow.


```cpp


static long calc_group_shares(struct cfs_rq *cfs_rq)
{

     // ......

     shares = (tg_shares * load);   // 1048576 * 9144968455305  = 
-8857549630719655936 (OVERFLOW)
     if (tg_weight)                         // assume tg_weight is 3
         shares /= tg_weight;         //  0xd7068dd8c2daaaab shoule be 
0x2c5be32e18300000
}

```


It will cause `se->runnable_weight` to have an incorrect value in 
reweight_entity().


Thanks.

CHENG Jian



      reply	other threads:[~2019-04-15 15:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-13  3:32 Cheng Jian
2019-04-15 12:46 ` Peter Zijlstra
2019-04-15 15:20   ` chengjian (D)
2019-04-15 15:25     ` Peter Zijlstra
2019-04-15 15:50       ` chengjian (D) [this message]

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=8c8e96d0-226b-de46-d498-0d8a6947b4c9@huawei.com \
    --to=cj.chengjian@huawei.com \
    --cc=huawei.libin@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=xiexiuqi@huawei.com \
    --cc=yangyingliang@huawei.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®