From patchwork Tue Jul 17 13:51:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 142146 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp3690804ljj; Tue, 17 Jul 2018 06:52:30 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcNcsE13q8Pm/jD/PP8FTHZ9VGO49halFbUZk0pQ5Pxy4TkIzeYG99tF2IGJtQ2X3pvlcss X-Received: by 2002:a63:b43:: with SMTP id a3-v6mr1698761pgl.50.1531835550699; Tue, 17 Jul 2018 06:52:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531835550; cv=none; d=google.com; s=arc-20160816; b=I0i0vGJqpEVux5R/c/qXJvK+YcZkFepjeVT2zlEv74zAkObcie8wisSgJJSx6jaMvv +v8f34MVR2QClH2vo0fiFat8GnzYVAdEAmgzFqn4azKnQdGZmrL+Xm9PuE9mbmEbGq1M foPuv0BOXeaJbrJ079ONIdtG7SkU9sKORzfXrlUk3BkoBY5gzd1Yzk/yamfb4vAQcugT e+2Mi0nJaxkPqdWoVChuvwOg+Gzk4vzfp760gH3aAhH3bBHx5WhMqsRbY+hJJNwjJLVk 6UvJSpDus54FHdMsBOik/Zn1oME6uN2wi0ASdBPEJYWOT94w4iwCGzj3wiGPdmOeZ+NG jP+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=hYhffGxQF7EK5r30Rj3ATb7KvaUzDa56PeaCrHKLjrY=; b=Rvf7Mubi3AkwzqIubdVofxYXxuo6BEiIfdC17IMhhOlCBqtA6jEM4IkJWmSsZjxF1n eTU263u4C0nZcj918na9Tib2uNf92oE/gcw0XsUxRX6frhX05Wr14Uj+m2cm5Ws6LbYJ I9coWzBOgn96lPuoQDeFUhdfJqJI7BZzVDaoAl3FTG5sQk5sDKFCHHGYwxEzdK8ESCbz OhSaXKCurW60fQvZKb4rHvXLsz/QeMH5IOjoeNUIAQw550OL2fjgGtJ+Qh1EenAyHR6y SOo14FtretCfOjC5P7T2wBy4Imxr7vC5mTc6bXTRyavrHEQ/oH7BkUkSzTMqT6VZeUXa a3YA== 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 l128-v6si1006244pfc.129.2018.07.17.06.52.30; Tue, 17 Jul 2018 06:52:30 -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 S1731813AbeGQOZO (ORCPT + 31 others); Tue, 17 Jul 2018 10:25:14 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:33873 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731429AbeGQOZM (ORCPT ); Tue, 17 Jul 2018 10:25:12 -0400 Received: from wuerfel.lan ([46.223.138.35]) by mrelayeu.kundenserver.de (mreue103 [212.227.15.145]) with ESMTPA (Nemesis) id 0MLRLO-1ffycT0ujy-000fPL; Tue, 17 Jul 2018 15:51:39 +0200 From: Arnd Bergmann To: akpm@linux-foundation.org, Ingo Molnar , Peter Zijlstra Cc: Arnd Bergmann , Stephen Rothwell , Johannes Weiner , linux-kernel@vger.kernel.org Subject: [PATCH] psi-pressure-stall-information-for-cpu-memory-and-io-fix-fix-fix Date: Tue, 17 Jul 2018 15:51:24 +0200 Message-Id: <20180717135133.3627980-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K1:jj1uu/rTj+NwAbNdTvS4L+gxg869CVzAXc8wFPQYRW2UTmWxYbq UTGrPu0of13zLoTo9V8jLT0x0F8bh1Y5shasNd5RLRNT5BzELTDYaMU1Y0NNb1qZKrNWh9N IBvSOV7NAnWVsNJhCX9mFbjQi+DdEJCpDNMJcy/A46HhhECos6Dfmlpl8KdP57djPE1bBF/ me1bI4bIwr9UTRm9NNHSw== X-UI-Out-Filterresults: notjunk:1; V01:K0:kKa+3XTbCyM=:ErTvi28O1uT3sv7yYU2uGT ZMtHcKVT0ULbr4upvczbTemltSY6Mi62j3w7U4x4YzGdQEpgHoLjzBcQvJbaCqOkZRuhTVZ3x rXD4XMVrh1fah2/I5moVVpHJEsVmgjm1cieunPTJFyaCvWNza7kYmFw5qzFu7UhrwDe3B9aRW 1bh2GbbVZMrzndC9oH+9LyKmq0FaBi0gMV4L44O1Bd96eefJTwggGNWxXQPdzpHPSpK0eAFLe jT0zPD3SEHqIErzqTWIU5Yl65klf2ZeHdE/57bsENSVtNo32Gwv/S/YWl7a1r57rNVcWiAWbW WW3ZoOwN7TBGOSh79jqWKMIoVUWXNlqRGWSnZknq4Gjy4Jad2RI+kFsGGJjF84htEBNkPo0OU cARBkifb5IyEc5SDK8SaKg5QPAnSmGObn4/QmjJwmC91abGJlvfL5DVz/I809bknQvykat1cb r2kqGDwX/gDKckFM4JVMcRwLxlWj48dJ5CdxPP9Z6yErkfTv88rEqLaZQ4YDuRms8LvfLh6oN l2RQ98PozZodGOZ9SlaktXj893PYO4QAxgu7mLGsve9KAD4kbUftVj52EC1rGDXpJAjozgEKY EQOetpINZ6QII6tRyzY0ddL2FnFEJmeCBv35Rm6L/nDLAv5p4zRx6Xe8yDkFweIzF77ebQKcq txv0hovJJ9iII70nsnWY9P76GrwWSxok2A3H5oOVcDLYp/pw3NR4/C1NhH+2Q4hpUJ6U= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The addition of do_div() did not do the right thing, as it assigned the result of the multiplication to an 'unsigned long', which truncates it before the division. GCC warns in various ways about this depending on the architecuture, e.g. arch/arm/include/asm/div64.h:33:45: note: expected 'uint64_t *' {aka 'long long unsigned int *'} but argument is of type 'long unsigned int *' This uses div_u64() instead. This is probably still a bad idea since we should avoid 64-bit division altogether in the scheduler, but at least it does the correct calculation. Fixes: 13a67bcb35f5 ("psi-pressure-stall-information-for-cpu-memory-and-io-fix-fix") Signed-off-by: Arnd Bergmann --- Please fold into the fix --- kernel/sched/psi.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) -- 2.9.0 diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c index eefe988ea7ce..9c3255ff50df 100644 --- a/kernel/sched/psi.c +++ b/kernel/sched/psi.c @@ -173,11 +173,10 @@ void __init psi_init(void) static void calc_avgs(unsigned long avg[3], u64 time, int missed_periods) { - unsigned long pct; + u64 pct; /* Sample the most recent active period */ - pct = time * 100; - do_div(pct, psi_period); + pct = div_u64(time * 100, psi_period); pct *= FIXED_1; avg[0] = calc_load(avg[0], EXP_10s, pct); avg[1] = calc_load(avg[1], EXP_60s, pct);