Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp693859ybc; Tue, 12 Nov 2019 07:50:24 -0800 (PST) X-Google-Smtp-Source: APXvYqz8RZcEOrn9/cKOLezOFdqB8IWCAHyNbPxd18R9ZmbVIPjGEgaRjIl+SyY35lpapbIH/a9K X-Received: by 2002:a50:88a6:: with SMTP id d35mr33890588edd.111.1573573824125; Tue, 12 Nov 2019 07:50:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573573824; cv=none; d=google.com; s=arc-20160816; b=C6HLJ4rmGUrRtpV5FzkI3h5q8xSSMqSM+VsvnK+sBfQRu0+yVcQdnU5TrbTb+fsKoT ifDigOZdWDBQ5GY7q+/dXVEIj2qE/oY/6kcc3/W/WxZNdnE4QxH0C4wjDRV97NzIHOyD sDlfiSZjwXw+i6jJ0EJfmp587b9WVkSnpBgN7DIF+ntuY3sZ5ab8T3DCHom95mcLs1sc ZzK6h/8223Jv2fWu+AG6sVAyPtQ7DBThS0uL3rM4BrT8pYxib2oJMulN729qrXRQIVli 1x0co0hgAU7gy7ZJWRq2KSFoRXXxbT6kUeU1+69Xm4p9XxoG2bdlpZ2PFPlhHSjvc07T CaLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=oX2RUUJ5hbLNK76X6QyX6ezOGkko2VCAlxrvKipPj6A=; b=AHYE9oKitRW6vuLBuBBdrHvBeNk7DTSjdLZx7t8Yk9hy+0Wll9QotCvD3oJp5hDxPR j9x0r9uAS0iSsk0WwPG+TgEF4daQ+jHnX1FHjS3XHuAw5tikbg/ng1ak0kuqobuCTLeU +BxCwHsg5uaUy89rnak+8U6dgRb4R2Ksa6Uv0VtjtW43D7LuGfxwN5XnI+dh2fFlkj9S fIKnf7LVHtux0GFetTwqmno5/DV2K0M5ftka5aJ3aYiiQ3ZdHZmLLW0lMTmZ1e1bErXT qVPXcPq/w7W+jtzZNOB3syIC+N+vZegBh6dPdEuqgjgkZpU/hWbyb9VLBDJZ0F0S1dqS 40jQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b="y5/nTQrs"; 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 l15si12943337edb.81.2019.11.12.07.49.59; Tue, 12 Nov 2019 07:50:24 -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="y5/nTQrs"; 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 S1726976AbfKLPsr (ORCPT + 99 others); Tue, 12 Nov 2019 10:48:47 -0500 Received: from mail-qt1-f195.google.com ([209.85.160.195]:33748 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726659AbfKLPsr (ORCPT ); Tue, 12 Nov 2019 10:48:47 -0500 Received: by mail-qt1-f195.google.com with SMTP id y39so20271860qty.0 for ; Tue, 12 Nov 2019 07:48:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=oX2RUUJ5hbLNK76X6QyX6ezOGkko2VCAlxrvKipPj6A=; b=y5/nTQrsRZXlN/SmnUnPqpq3yRbtQBn2KCJNT1eHTmPHrmYb27+rxnFkfwE4F60Q4Y eLfm7ZJbIXi3/4PEpAnGT1PERPNa826HjgOmVbRFJEyHK43yPoRan+L2eb6S8Bj/BPnN y49fftyBwZbA8xUK1XMlaZwchSADEOx/rRp2JAc2LcHULcfJFnXU8R2h7TDMfA6/3AX+ 2mmV7d+Ou3ZKSn4bxnyEJ5JIeETsr/RZzmJAdm8ply3by/YTsmC893CCW3az9iBvgcXe qAXs9LEUs6UWJpGvs2HBA6wZ3+EkS3eVz+b3ZfCY5TLMOjhUErMDiYovPl57H8HZIKrM thaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=oX2RUUJ5hbLNK76X6QyX6ezOGkko2VCAlxrvKipPj6A=; b=ZKWInZQeRAzaaxrmvODUYLJU8ErJsvK0EGewm3j4HFwfHlvkMgUKDHuPASieGBybal IaapAhBbjLWOqXfxy+BIBrFpII6s7dKqLdJ9jFsvLMjFvcZAnH03ZovhF6wcae5Veezt Iy97vdoD/hpagdRMUuRX0S0p08qE5L06Vu+0GoGEOEFJoBN9ucUfBfmsF2YGMznD5IDn RUriNFdjIuR9VFQ4oMZxSr6ED17vTxa9MtJkKWiE9I290yrxs2Dr/DW7o8dQo37EjEdT VL3T6OEbfL7+hrimu+2KKSFhIwGdfObmdu7Icog8/unN5jwvQ/TGo4WFCgnINm2sB/0g BSew== X-Gm-Message-State: APjAAAU6LwMj/SgaFPwudgjHLuSRCwUggaRbasMyZzWw84dBXC4rqpR1 3tvE7q3vn3ZtQ8gFkQcDaM/aHQ== X-Received: by 2002:aed:3ef2:: with SMTP id o47mr32988985qtf.107.1573573726084; Tue, 12 Nov 2019 07:48:46 -0800 (PST) Received: from localhost ([2620:10d:c091:500::aa8c]) by smtp.gmail.com with ESMTPSA id w15sm11040648qtk.43.2019.11.12.07.48.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Nov 2019 07:48:45 -0800 (PST) Date: Tue, 12 Nov 2019 10:48:44 -0500 From: Johannes Weiner To: tim Cc: Ingo Molnar , Peter Zijlstra , linux-kernel@vger.kernel.org, Suren Baghdasaryan Subject: Re: [PATCH] psi:fix divide by zero in psi_update_stats Message-ID: <20191112154844.GD168812@cmpxchg.org> References: <20191112154144.GC168812@cmpxchg.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191112154144.GC168812@cmpxchg.org> User-Agent: Mutt/1.12.2 (2019-09-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 12, 2019 at 10:41:46AM -0500, Johannes Weiner wrote: > On Fri, Nov 08, 2019 at 03:33:24PM +0800, tim wrote: > > 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 > > This is legit. When we stop the periodic averaging worker due to an > idle CPU, the period after restart can be much longer than the ~4 sec > in the lower 32 bits. See the missed_periods logic in update_averages. Argh, that's not right. Of course I notice right after hitting send. missed_periods are subtracted out of the difference between now and the last update, so period should be not much bigger than 2s. Something else is going on here.