Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp5357750imm; Tue, 21 Aug 2018 10:19:03 -0700 (PDT) X-Google-Smtp-Source: AA+uWPyvik+iJtaEepfjnJYAyJc+t35I1RKbsumhM3qbtzMTbYVpC3a/5FKWZ93urFyTO5RMlUZq X-Received: by 2002:a17:902:9a48:: with SMTP id x8-v6mr22759226plv.72.1534871943841; Tue, 21 Aug 2018 10:19:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534871943; cv=none; d=google.com; s=arc-20160816; b=YtEmsvGnOUdeIAARg3n8azp/gJwO3i+dav6sNw6wEc24S/mEI2PC9CzwWejzJEf8II m+6Kb/9Y+snsYOBmUhWEZFTPIoOduLIJDRUExU54W6seCgfZwSm2+Un7xI45TOfIyggQ z07oStSlFwbzg362t9frHpzSFPab95/kghh582oYhJnD4nCXk9g0jvp+UBE6ujbrbDev hDfZjNbewu2XScd33ZLeaWUTHfx1As0V3ztnXmXZI+bQIIvRP3s10EMVsNUnPg7KySw4 kS2ucTQC9skt9ybozY9asP5lmm92ILuq44rc6iWPg7tkCn+d5lNvOkJck4S27Yiu8Dk3 fZVA== 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:arc-authentication-results; bh=f2ra5hNONeOO5tlyLnTi9ILGED9CQbxz6jS8y2pJFqM=; b=waiZNVa7MTVPgXYSuz/4oE4BYgcGNYPj9yRcN1viGjIya365kkYzlngs8jHqT4MZP3 JP9oVXBkCj3Iv/87ksi6QgQiTp9UDw8tV/cWOxUA3VTtyx3i6trmQMnASypKifFFRUyJ aYXpphHBTq4pokPzrrNk1B95R+Xa/f6TWRgjBHDGeWzJ0tUldroEpxSqSA95CeZnztBo LVLPYUwVVXLXJAtpIOldG4OeIxm1Xi/egsVAIF7RdCBA2kHfqr5RjrIc2n91awR58tCe iiwFIs32jde5BYrOH5eedW3RMtazezYNhWCxzQcwMQOHkE+Yg0Rq4oLttqVeMahBF2AK YLJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=qy1pvzwa; 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 r22-v6si7529721pls.131.2018.08.21.10.18.48; Tue, 21 Aug 2018 10:19:03 -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; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=qy1pvzwa; 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 S1727682AbeHUUhB (ORCPT + 99 others); Tue, 21 Aug 2018 16:37:01 -0400 Received: from mail-yb0-f196.google.com ([209.85.213.196]:38476 "EHLO mail-yb0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727624AbeHUUg7 (ORCPT ); Tue, 21 Aug 2018 16:36:59 -0400 Received: by mail-yb0-f196.google.com with SMTP id c1-v6so4579150ybq.5 for ; Tue, 21 Aug 2018 10:15:58 -0700 (PDT) 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=f2ra5hNONeOO5tlyLnTi9ILGED9CQbxz6jS8y2pJFqM=; b=qy1pvzwa987d9O3vBH9UY0JQ5MgHhUSUpuvxqdPK88Ged/IgwXSDTb0ZOJtHVLqfTp ymqHP1TZ50fyx/KN2s5EsKykSlgVsI8f3dvk0mIde2CTj4c9EMHqD02UsD4DDD/oLXMa PwiALRMMP8b/ra9Mg/6/54I2Gn1ckoUsCIs1xkzSUNNQqYpOoSffvtXlElqB77iJ3qZ/ 8UKUkvpn8/Q2bna+1H249G3LnsChvGWIFDZih59dIgFCa7cPQ7xvYgkERuDwPHaz9Usc rcwS+9c80s6plyeRkItdeNo8qeXAyyYi65wLNwEM3EBHG4papER+EnsxfmWc08RGW0Bd 9ncA== 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=f2ra5hNONeOO5tlyLnTi9ILGED9CQbxz6jS8y2pJFqM=; b=Yp5iCTMCSwTsRZGVCEq2xjncasV4amwNOF58ROh8OGtBZZU1OeG9QpVH5e+73Y/Q8C A0M0bTKdyojYWt2pdz6pV6mQCw4JN05uL186U47NOJizkmYCU5IL3Ev+AxT3xpGgfDj3 gVzmKzc9G3q8mpfaaToU/Gv/iW797C1ig2cFDTB7dWZmu+mUSnDZLQ+PNUW4vWSEsoG/ jemWXS5YrTV/Vyqe4DDCb4eLkpEIIATcfV7UPcCDCo6xh7fesuf1bFWSiMvLMVxGQfwg vY0BexaxhaPTvE8EBdgwIdhtdJNWeRdjw5mTsbKlL1mX1lAXt80tj2bepWsjmNxTQoqb /97A== X-Gm-Message-State: AOUpUlE0bnT8fwIptogRAPOuf7QBZO5bJTybCoublPvdy4uxlzVdkAbL b7+k+D7S+6h7UXGdewO+V5FwFg== X-Received: by 2002:a5b:287:: with SMTP id x7-v6mr27845337ybl.476.1534871758395; Tue, 21 Aug 2018 10:15:58 -0700 (PDT) Received: from localhost ([2620:10d:c091:200::3:17a0]) by smtp.gmail.com with ESMTPSA id c126-v6sm1543227ywa.104.2018.08.21.10.15.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Aug 2018 10:15:57 -0700 (PDT) Date: Tue, 21 Aug 2018 13:15:55 -0400 From: Johannes Weiner To: Konstantin Khlebnikov Cc: Matthew Wilcox , Roman Gushchin , linux-mm@kvack.org, Linux Kernel Mailing List , kernel-team@fb.com, Andrew Morton , Michal Hocko , Tejun Heo , Rik van Riel Subject: Re: [PATCH RFC] mm: don't miss the last page because of round-off error Message-ID: <20180821171555.GA16545@cmpxchg.org> References: <20180817231834.15959-1-guro@fb.com> <20180818012213.GA14115@bombadil.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 21, 2018 at 08:11:44AM +0300, Konstantin Khlebnikov wrote: > On Sat, Aug 18, 2018 at 4:22 AM, Matthew Wilcox wrote: > > On Fri, Aug 17, 2018 at 04:18:34PM -0700, Roman Gushchin wrote: > >> - scan = div64_u64(scan * fraction[file], > >> - denominator); > >> + if (scan > 1) > >> + scan = div64_u64(scan * fraction[file], > >> + denominator); > > > > Wouldn't we be better off doing a div_round_up? ie: > > > > scan = div64_u64(scan * fraction[file] + denominator - 1, denominator); > > > > although i'd rather hide that in a new macro in math64.h than opencode it > > here. > > All numbers here should be up to nr_pages * 200 and fit into unsigned long. > I see no reason for u64. If they overflow then u64 wouldn't help either. It is nr_pages * 200 * recent_scanned, where recent_scanned can be up to four times of what's on the LRUs. That can overflow a u32 with even small amounts of memory.