Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp2107903ybx; Thu, 7 Nov 2019 23:34:18 -0800 (PST) X-Google-Smtp-Source: APXvYqzmaFQ28OCmv0+eiCNVXh4+XtBkmiAR1/v5LexMSjjs9eYtEGQ4to4kVVOvbIsCJgwWS/oO X-Received: by 2002:a17:906:2ada:: with SMTP id m26mr7332195eje.87.1573198458895; Thu, 07 Nov 2019 23:34:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573198458; cv=none; d=google.com; s=arc-20160816; b=TMFb0HGP8aYabTowf9AM01dle2zfrbrp2HWianxwCM3UUGDb1mlJznRuOmXm6qfT9O rwY2BO+qOLdY6TWbVEljseOdtUN8Gb5LvvyxqnOY/ayfL3bDd3AzEwJxkNTn7n60jV26 5767BqlwMQpO+YmH0Qstd1dPjm4djaZA4kj1Koqigq2eJ0PLmLYjQA9sMobWQgNYcj8A TNEN3mfIhXuySvPYQU6IMj0U/+AFbRW3a1Fs2Y6ylSyHQUuulPdFjAJgxb3jdpm5wwIq 7y/xsfCeBnJunnGLUvkeBiO6cFFksDsQNIocc31Pp72hkQT81QzBfm0R8w8/tjlScwez AP4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :thread-topic:message-id:cc:to:from:subject:date:user-agent; bh=JY9tqkkDd2yms9h8lNqEQue/wrgl5/qZQoCBsePuzMk=; b=ROku8F4E+cgdSIytj2L9AzOqF6A5Bm8ftZnuzcghQTLeun1sQ/6SYcirc3MCr2nhuP B3YzVWFOOfiYkSP+vlsPVdwrr2biZpX/Ez0p+0GS2mpS8kEIW3XCSFLNI1KHT9PgZ1kE rV/tCZG/tphBuvd8xAaAUldjC+8fL0ZIvn8T01Q+IdwBsKs/pfbUQ3fznBg1XVlRpJT7 4X0u+5AXoX48VfTJYqtoQoWGL1owYGivbXkbx2zYAnaDp4obllp/UevPBn5F4H7iI11x 8iZZdhNq/0AOx5tA0EOx6Hceh90/XJDQmZ8DNESqwV7mCu9S96CkZdIDR9g7L6l2HtxV zUUQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q44si3611799eda.242.2019.11.07.23.33.55; Thu, 07 Nov 2019 23:34:18 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729770AbfKHHdP (ORCPT + 99 others); Fri, 8 Nov 2019 02:33:15 -0500 Received: from out30-56.freemail.mail.aliyun.com ([115.124.30.56]:48524 "EHLO out30-56.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725900AbfKHHdP (ORCPT ); Fri, 8 Nov 2019 02:33:15 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R201e4;CH=green;DM=||false|;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e07417;MF=xiejingfeng@linux.alibaba.com;NM=1;PH=DS;RN=4;SR=0;TI=SMTPD_---0ThU0D.W_1573198392; Received: from 30.5.113.47(mailfrom:xiejingfeng@linux.alibaba.com fp:SMTPD_---0ThU0D.W_1573198392) by smtp.aliyun-inc.com(127.0.0.1); Fri, 08 Nov 2019 15:33:13 +0800 User-Agent: Microsoft-MacOutlook/10.1f.0.191103 Date: Fri, 08 Nov 2019 15:33:24 +0800 Subject: [PATCH] psi:fix divide by zero in psi_update_stats From: tim To: Johannes Weiner , Ingo Molnar , Peter Zijlstra CC: Message-ID: Thread-Topic: [PATCH] psi:fix divide by zero in psi_update_stats Mime-version: 1.0 Content-type: text/plain; charset="UTF-8" Content-transfer-encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In psi_update_stats, it is possible that period has value like 0xXXXXXXXX00000000 where the lower 32 bit is 0, then it calls div_u64 which truncates u64 period to u32, results in zero divisor. Use div64_u64() instead of div_u64() if the divisor is u64 to avoid truncation to 32-bit on 64-bit platforms. Signed-off-by: xiejingfeng --- kernel/sched/psi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c index 517e3719027e..399d6f106de5 100644 --- a/kernel/sched/psi.c +++ b/kernel/sched/psi.c @@ -291,7 +291,7 @@ static void calc_avgs(unsigned long avg[3], int missed_periods, } /* Sample the most recent active period */ - pct = div_u64(time * 100, period); + pct = div64_u64(time * 100, period); pct *= FIXED_1; avg[0] = calc_load(avg[0], EXP_10s, pct); avg[1] = calc_load(avg[1], EXP_60s, pct); -- 2.14.4.44.g2045bb