Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2300830yba; Mon, 15 Apr 2019 08:52:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqxMhqj2vnlCoFbG0o5co+z9D2Tc+Ze2Cvts4Om77Df0e2rmE1oYV4AecZWDSDpHA/vcW3d+ X-Received: by 2002:a63:570d:: with SMTP id l13mr70649249pgb.55.1555343544549; Mon, 15 Apr 2019 08:52:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555343544; cv=none; d=google.com; s=arc-20160816; b=yPRzmUh2Ts6guVW/PPj9kx6MowGD6kjmMxw0Ohyh4chRF0XJ0PY9v8BYeAf0DJAujf ADR6tFb9MrNKOKWZlW69F4/iHALHpAfehR2y9RWxTvjc2HFVw4CbtiSZPG06kQNC2f8K e7floCAZj+YJ6y1my110rPjZp7UGuNVwfmQ6GROAOmnvoXIyPyduZrIYg4Gcz3+6fzIG 8p/GkSwBijDhyS/k9IzlCD1/NIEPnvnxZ4IRquwTk1IdjzpBYxLBC6xBMbRYX4opyeob SKM/ztCyK1DCyqEAhbeI3sHklMqKVMglMWHNZAlcCa94U/IdoAHGioc9/OGZJFAV3Gft Ck2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=F5hxhfY2IJ82A9FM5UucKTW8M9cmJHfV6z7P3d8fPw8=; b=eAE++gaL9BN8LEHQOkhDn/mU88RTAN+2LnuLqukfQnn8Gw/C9rB14ymkBPyqRn4elY OQBkBoAq1nP/dYteA4dTtVW24UwyHlBTph+ad7D6sg8/lEiVlj7PwiBj9iuoLSkN/fBc gK++hLTYMSRHnlv0672q7fowgZDVK/SfSFySxwxI594CX5wGOAm2uh87dNHmxpyFOyyS IrluipFPOEbq52oJ+v94yOVeEoC7FVlbFEqT3IAVo6n8TmumnwX+maDB5uIbmQZAFj3i IgKzU6S/EH9GbaWzxkGnNZt67MEC2JTk2SMOz5MLRk0KPDH0tIMDF85J1XeZubGadSc9 52Yg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q13si47348650pfi.208.2019.04.15.08.52.07; Mon, 15 Apr 2019 08:52:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727579AbfDOPvP (ORCPT + 99 others); Mon, 15 Apr 2019 11:51:15 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:34000 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726034AbfDOPvP (ORCPT ); Mon, 15 Apr 2019 11:51:15 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 5BDF17F7799A833B01C0; Mon, 15 Apr 2019 23:51:10 +0800 (CST) Received: from [127.0.0.1] (10.184.38.59) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.408.0; Mon, 15 Apr 2019 23:51:04 +0800 Subject: Re: [PATCH] sched/fair: Use 'unsigned long' for group_shares,group_runnable To: Peter Zijlstra CC: , , , , , "chengjian (D)" References: <20190413033234.30002-1-cj.chengjian@huawei.com> <20190415124617.GP11158@hirez.programming.kicks-ass.net> <20190415152549.GQ11158@hirez.programming.kicks-ass.net> From: "chengjian (D)" Message-ID: <8c8e96d0-226b-de46-d498-0d8a6947b4c9@huawei.com> Date: Mon, 15 Apr 2019 23:50:49 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.5.2 MIME-Version: 1.0 In-Reply-To: <20190415152549.GQ11158@hirez.programming.kicks-ass.net> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Originating-IP: [10.184.38.59] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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