• X
    sched: fix a potential divide error · 216ca876
    Xie XiuQi 提交于
    hulk inclusion
    category: bugfix
    bugzilla: 4586
    CVE: NA
    
    We meet a divide error on product OS, error message as bellow:
    
    [499992.287996] divide error: 0000 [#1] SMP
    [499992.289337] kbox catch die event.
    [499992.293135] collected_len = 1035486, LOG_BUF_LEN_LOCAL = 1048576
    [499992.295187] kbox: notify die begin
    [499992.296483] kbox: no notify die func register. no need to notify
    [499992.297796] do nothing after die!
    [499992.299108] Modules linked in: signo_catch(O) macvlan binfmt_misc
    ip_set_hash_netport ip_set_hash_ipport vport_vxlan(OVE) ipt_REJECT
    xt_statistic xt_physdev xt_nat xt_recent xt_mark xt_comment
    ip_option(OVE) ct_limit(OVE) bum_extract(OVE) policy(OVE) bum(OVE)
    ip_set nfnetlink openvswitch(OVE) nf_defrag_ipv6 gre ipt_MASQUERADE
    nf_nat_masquerade_ipv4 iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4
    nf_nat_ipv4 xt_addrtype iptable_filter xt_conntrack nf_nat nf_conntrack
    bridge stp llc xfs dm_thin_pool dm_persistent_data dm_bio_prison
    dm_bufio libcrc32c loop kboxdriver(O) kbox(O) ppdev parport_pc pcspkr
    parport virtio_console virtio_balloon cirrus syscopyarea sysfillrect
    sysimgblt ttm drm_kms_helper drm i2c_piix4 i2c_core ip_tables ext4 jbd2
    mbcache ata_generic pata_acpi virtio_net virtio_blk crct10dif_pclmul
    [499992.308050]  crct10dif_common crc32_pclmul crc32c_intel
    ghash_clmulni_intel ata_piix aesni_intel lrw gf128mul glue_helper
    virtio_pci ablk_helper virtio_ring cryptd libata serio_raw virtio sunrpc
    dm_mirror dm_region_hash dm_log dm_mod scsi_transport_iscsi [last
    unloaded: signo_catch]
    [499992.312751] CPU: 8 PID: 23352 Comm: bash Tainted: G ----V-------   3.10.0.x86_64 #1
    [499992.314308] Hardware name: OpenStack Foundation OpenStack Nova, BIOS
    rel-1.9.1-0-gb3ef39f-20170329_185309-build9a64a246a231 04/01/2014
    [499992.317411] task: ffff880033fc9700 ti: ffff8807fed60000 task.ti:ffff8807fed60000
    [499992.318967] RIP: 0010:[<ffffffff810c15c2>]  [<ffffffff810c15c2>] task_numa_fault+0x1c2/0xbb0
    [499992.320515] RSP: 0000:ffff8807fed63d38  EFLAGS: 00010246
    [499992.322018] RAX: 0000002b7efd0000 RBX: ffff880033fc9700 RCX:0000000000000003
    [499992.323563] RDX: 0000000000000000 RSI: 0000000000000400 RDI:ffffffff81a80f60
    [499992.325052] RBP: ffff8807fed63db8 R08: ffffffff81a80f68 R09:0000000000000000
    [499992.326531] R10: ffff88083ffda000 R11: 0000000000000000 R12:0000000000000424
    [499992.327987] R13: 00000000002b7efd R14: 0000000000000000 R15:ffffea001ea42a00
    [499992.329420] FS:  00007fa01a3b7740(0000) GS:ffff88103ec00000(0000)knlGS:0000000000000000
    [499992.330866] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    [499992.332302] CR2: 0000000000ff1fb0 CR3: 00000007ff1d1000 CR4:00000000003407e0
    [499992.333763] DR0: 0000000000000000 DR1: 0000000000000000 DR2:0000000000000000
    [499992.335187] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7:0000000000000400
    [499992.336595] Stack:
    [499992.337974]  0000000000000000 00000001bc9598a8 ffffea001ea42a00 0000000100000001
    [499992.339374]  0000000300000001 0000000000000001 ffffea001ea42a00 ffff8807fed63db8
    [499992.340768]  0000000000000000 0000000000000000 00000000bc9598a8 0000000000000001
    [499992.342148] Call Trace:
    [499992.343494]  [<ffffffff8119ab62>] do_numa_page+0x162/0x1f0
    [499992.344831]  [<ffffffff8119bde7>] handle_mm_fault+0x627/0xf50
    [499992.346145]  [<ffffffff8164e486>] __do_page_fault+0x166/0x470
    [499992.347442]  [<ffffffff8164e853>] trace_do_page_fault+0x43/0x110
    [499992.348711]  [<ffffffff8164df29>] do_async_page_fault+0x29/0xe0
    [499992.349948]  [<ffffffff8164a9f8>] async_page_fault+0x28/0x30
    [499992.351149] Code: 00 3d 00 04 00 00 44 0f 4e d8 41 81 fb 00 04 00 00
    0f 84 67 07 00 00 4c 89 e8 49 83 c6 01 31 d2 48 c1 e0 10 49 83 c4 01 45
    31 c9 <49> f7 f6 48 c7 45 a8 00 00 00 00 48 c7 45 b0 00 00 00 00 49 89
    [499992.353707] RIP  [<ffffffff810c15c2>] task_numa_fault+0x1c2/0xbb0
    [499992.354927]  RSP <ffff8807fed63d38>
    [499992.358114] ---[ end trace 4f2465cac18ff65e ]---
    [499992.359304] Kernel panic - not syncing: Fatal exception
    
    sched_clock_cpu may not be consistent bwtwen cpus (never more than 2
    jiffies difference). So, if we meet *period < 0, (*period + 1) can't
    prevent divide error. In this patch, just prevent potential divide errors
    by ensuring that period is not less than 0.
    
    task_numa_placement:
      runtime = numa_get_avg_runtime(p, &period);
      f_weight = div64_u64(runtime << 16, period + 1);  // might trigger divide here
    Signed-off-by: NXie XiuQi <xiexiuqi@huawei.com>
    Reviewed-by: NCheng Jian <cj.chengjian@huawei.com>
    Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
    216ca876
fair.c 269.0 KB