Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp5120785imm; Tue, 21 Aug 2018 06:39:35 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxdzLGjt4QFmIZzYCLioHJboUGsETJ9iDGINvWI0ulrITPQD58HDB+NRMDZ2WOrv+b68oC8 X-Received: by 2002:a17:902:8303:: with SMTP id bd3-v6mr49579263plb.329.1534858775645; Tue, 21 Aug 2018 06:39:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534858775; cv=none; d=google.com; s=arc-20160816; b=Jn2dskD3iNHM9QhiuduamMrAOaZbmVePRQxHGDHya0Ozt7fArIaK26eGWRTQD1u7CR K19Vw5AaBmGJl9xX+IRnGrRRzlE2foppNUFmpLXeztPvXD4+Oqdxh9USxn0jLOpQuOKK L/JZA+4xmhgcfblVvWAex105xHy6TUA2M77qpp+DhrmDQZJB211Vl4WyKVwBhEWXOhwT ZooT/w29uYTkO1f8p1Z7yC6Bq626R270P1ljsDWUVi8htKiyuJdVK6NY3wYTACzdp2z8 YtwONOsmGmHT0m0Icy3p/ypTkLPsbKc15TGpPyn6xBdNEeYj6Kh2NhHG2M+4ZpfVZG29 59Ug== 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=7Ik70fkhtA+i4KltCtBN9SUSTfc5ejDaxPea9qStIbA=; b=R0aWjayihK/uTx7xCOGIM4Q2Omf0cvDHUFGg+2EgEuDHai/I4s0swa0vLSZRW0sF2k 64NfaiIOk8gVWTaAaKImd3g0uzsabatnTy3W5X+Rkvx1fA3dYuv3siDEUfeOoUyUFMaw kStN865T2fZRUySneWW2QZgctFRi1fEJd2E+ozM11k6Fw06iFtJS4PU7+KL3K0BrRvOI VfT3r/4zP5vd3gn+/CYf2ptAIUzUlI+gN/mP2L2E9mAa4n0+CYo9yWV3A6VhXoSHqCAI ztbHOQDnb70fPJAgNAxLZTvvca7kF71H/SQ907NkNGY0PjJWueQsZioJOGu8N4VpPhEa E9ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=ZWaDg2wC; 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 l63-v6si6142411pgd.598.2018.08.21.06.39.20; Tue, 21 Aug 2018 06:39:35 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=ZWaDg2wC; 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 S1727467AbeHUQ4C (ORCPT + 99 others); Tue, 21 Aug 2018 12:56:02 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:49166 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727031AbeHUQ4C (ORCPT ); Tue, 21 Aug 2018 12:56:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=7Ik70fkhtA+i4KltCtBN9SUSTfc5ejDaxPea9qStIbA=; b=ZWaDg2wC+LxkW9laImhhzP38y GkhPlMprhLtnQAQgLDJwC57adGPqSJn/u289YPwlhanM9RtLwrXwkQqZeVTEDVAcqiSxUr06Nojyk urQ4Vpvu6+O9c7rzYXPDxSj02KsRNQieEQewO0DNBm/U0bqU9OqJhtLbXCUH/6yg3Trj3Wsh6kqV/ wV8pgm5NwbOGoy4jpBI7L14kkoxE8Rhuaq7E0O5TGhIBvJhrq7nYz0IgetaGophrserCWGuL+lDFW ztvig+5pt6Fd4I7q835OccQZBAQKvZd1xByQnTN9jvNDFn0kaRkDuS2YpwI3N6/p1gB3XoQqZmE/A 3t1Il5wEA==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fs6p3-0004Tf-Ad; Tue, 21 Aug 2018 13:35:49 +0000 Date: Tue, 21 Aug 2018 06:35:48 -0700 From: Matthew Wilcox To: Konstantin Khlebnikov Cc: Roman Gushchin , linux-mm@kvack.org, Linux Kernel Mailing List , kernel-team@fb.com, Andrew Morton , Johannes Weiner , Michal Hocko , Tejun Heo , Rik van Riel , Shaohua Li Subject: Re: [PATCH RFC] mm: don't miss the last page because of round-off error Message-ID: <20180821133548.GA10602@bombadil.infradead.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.9.2 (2017-12-15) 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. Shaohua added the div64 usage initially, adding him to the cc. > There is macro DIV_ROUND_UP in kernel.h Indeed there is.