Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1665213ybl; Tue, 3 Dec 2019 10:41:23 -0800 (PST) X-Google-Smtp-Source: APXvYqwxQWxs9H5XVTl2wjkkoRylgP7p4yaLbRuHMwrVNEgAtYgzz8c4FwiOuMDxgs6MyLD2zIhY X-Received: by 2002:aca:a811:: with SMTP id r17mr4853465oie.59.1575398483567; Tue, 03 Dec 2019 10:41:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575398483; cv=none; d=google.com; s=arc-20160816; b=LVLKEWoV4/yEadUY/P/U3PdR0v2XJ378NwS5ygLRY7ZiRxu8VHRfHHbobLdwaiZskF nUxafWKFk+gZgqdhnhNHNFv+M9vY3DdJbXyXTNYzoAMKUvZ5eTX7rlMAV9P8I1vkXnjD vezHwhUXhuRF0K7Yctn6vt9YEr88jn0CKEd9GmEyqMwIGMACuzVpEzVIN/QQQd4COjXQ 7z1V1w0rp6wFn4u5e8g2hnhIUs4Yvh/ICIIEk6YMO84qHq5mW9plZX4jMWr6IAHYJqeG ply0KOydHiVPNbTWXLmdtgxTDCHu1QB9QwZ4eZO2qJkMGfGLGyFNoe97QLwhMsYRUx6M bsDQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=YOfocbvIxC0iu9uOHcUapzST4lCL7cP23eKj1vMSlro=; b=q+xStt6qB3YooSfLJye7v7hEdMoBwWuO+QrDU33jVrDjcAxfT37Ff7LWZmw1WSL6Zo gjklPTxHXEbGilmqqHDbx0FCZUQQGtKOsZQtKKPTJXkVnFOIc52uKx7r3RZHEZEN0hsI 9n1W6hYqXgl90mFlcGJnkjRUhJEjaeWqAawvd5Ins0SBaaKAJKmQD2zvWGqspLYZcDH0 V91JBOsaGg+McQ0vL+DvN3RzewUtbqFWtUeCZdtpF+nGhIH+c9eeJ32DX49NaUiax1An 9mjAninyjaH7n1k70z66SCtX4CENuvoAcqLmId682HzjasGyHTjB/T8et8wPBwzp8Ooi 7kNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=FmskHlzg; 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=cmpxchg.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p7si1790510otk.81.2019.12.03.10.41.02; Tue, 03 Dec 2019 10:41:23 -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; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=FmskHlzg; 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=cmpxchg.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726987AbfLCSfi (ORCPT + 99 others); Tue, 3 Dec 2019 13:35:38 -0500 Received: from mail-qt1-f196.google.com ([209.85.160.196]:38883 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726564AbfLCSfi (ORCPT ); Tue, 3 Dec 2019 13:35:38 -0500 Received: by mail-qt1-f196.google.com with SMTP id 14so4814668qtf.5 for ; Tue, 03 Dec 2019 10:35:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YOfocbvIxC0iu9uOHcUapzST4lCL7cP23eKj1vMSlro=; b=FmskHlzgPfYc9RuTSKhCb1dS/OuIvm1U1ED45iv8aC9CBBl5CaalVD2LOcKK2XR+tP W5s3zggyrlhZBVGP7rJHGlQ6u5DtBCrk8eT6SOXXEJXbKM+2+7TNFSOxEcMTCII7GEL3 +VIyLO2dQMMa2wRYUXRtXHUuBqgMkp/PLH35Sbp5WUEmefM6G6jTk0igw54lN53rRc+x Xy0YCezqKFjO5aOLkmi0vfWq8XF09PMhFyt7s344i+9M8BmShGzKQMnTFN5c48W925cV OAdoKdNcBmel2qHgYsxxtwEhWYoqjRoiC/W1SIZrtC7Y++zjE3Pg5AbC/WJQFchVBDTj irnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YOfocbvIxC0iu9uOHcUapzST4lCL7cP23eKj1vMSlro=; b=hpi+rqvLFywLI2ElVD2OfTkRdQNfq0R3CkPHMa5vkbffelToOuAZ63MQ6U3zraMMNa jqqKXWDG7WQj3nCU48npvmWCjpkUhIRDoFLZVcpXOIruBBCk10D6jUKpxwwVGy/dS/K9 iR7TQPZ8KhQjc2pwd92acUIeKNMxVShRSQr7t2XodHOKpHwEAfeoGLt76rSU7M02FJpv 8qZdia8YaM1j/b7zCt4x2QUF7EfL5UaN5yF6Gu+WfVs3VusrX9Uy7IG41pKORC2Oi9Sl RbBm2ZcbKQKohTozC1scMWp5gXN+9vn8b8HS6gvrzdZAOmAzI6SMaUKgpFSu177ZCuAp sorw== X-Gm-Message-State: APjAAAWB3xHJuddKbimydoHo+1Jem4Fo6fUsBBGJxVl2qN4ExkMOqrER cnOCO3rAeLyp4v3We9+SG+Yb5baJkYY= X-Received: by 2002:ac8:6f09:: with SMTP id g9mr6529852qtv.275.1575398137095; Tue, 03 Dec 2019 10:35:37 -0800 (PST) Received: from localhost ([2620:10d:c091:500::3:cbfe]) by smtp.gmail.com with ESMTPSA id d15sm2184192qti.69.2019.12.03.10.35.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2019 10:35:36 -0800 (PST) From: Johannes Weiner To: Peter Zijlstra Cc: Jingfeng Xie , Suren Baghdasaryan , linux-kernel@vger.kernel.org Subject: [PATCH 2/2] psi: fix a division error in psi poll() Date: Tue, 3 Dec 2019 13:35:24 -0500 Message-Id: <20191203183524.41378-3-hannes@cmpxchg.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191203183524.41378-1-hannes@cmpxchg.org> References: <20191203183524.41378-1-hannes@cmpxchg.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The psi window size is a u64 an can be up to 10 seconds right now, which exceeds the lower 32 bits of the variable. We currently use div_u64 for it, which is meant only for 32-bit divisors. The result is garbage pressure sampling values and even potential div0 crashes. Use div64_u64. Signed-off-by: Johannes Weiner Reviewed-by: Suren Baghdasaryan --- 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 970db4686dd4..ce8f6748678a 100644 --- a/kernel/sched/psi.c +++ b/kernel/sched/psi.c @@ -482,7 +482,7 @@ static u64 window_update(struct psi_window *win, u64 now, u64 value) u32 remaining; remaining = win->size - elapsed; - growth += div_u64(win->prev_growth * remaining, win->size); + growth += div64_u64(win->prev_growth * remaining, win->size); } return growth; -- 2.24.0