Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp4679078imm; Mon, 20 Aug 2018 22:13:26 -0700 (PDT) X-Google-Smtp-Source: AA+uWPwL6/YpRORuklVEvuHbLm50EngoxK7LMHiqI6d7C0fichEspFbCunuLmQGK+NnHNFSWUhRM X-Received: by 2002:a63:1760:: with SMTP id 32-v6mr15599856pgx.31.1534828406749; Mon, 20 Aug 2018 22:13:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534828406; cv=none; d=google.com; s=arc-20160816; b=HPBuHqtTHnbf0Tbyzn9NX3AxrZIFx6zfAjQTj5+kNRs3wBtS7a/yP4ksgyam56r1y9 1mr7GckLhRocHMPbD9/k6xKCPt/hw1p7m5Uq67utKspe7zBn1+GHKe991zd//BH5kF0H iZJtZf1TOugoqsvlaKvbDWMxcsNLXKPjphHBBr1mBVNZaPn4S0LfpkjjkEOyAgw59Is1 /mWEUTQHKrfpDiVi1062JO+Vh9/CcUVH9iOOCkBTZoo+omud8ALJxpApWWJwnlaDkXR0 oAGHA50jAD85xaqsBcDE/ezryQF6V9VDd24QD+zmgW/du9wMwkIJEviV0zXfq2WsCx5T eV5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=u0nxW5SDhuR0cvWLvp9dYb5Hfu9HpYKt5PL/ZEZtZfA=; b=jQXfh8a9KuH4wZIFxM0B+jkATYP0uS4rHsv9M9qqeeKeQaifseAXJUwkazxzZ+6n8P d/j+OkeT/F+cHKyCZbUZmF7zKVXjj4R0eP9QyrpDZm+slNlPfm2yNM5Yvc6Q2fJ2pCZ2 hR1UIuua2sCaQ6NxsUyT9Lf96fCgCzQXDt82jlBjwSRnIzpJ2pA645qmea7o3LsrLV6x 8uHM9KCineIgnKCe2hecieSKEJVdvOZBJ0eyKmIARiAvMuaqF0/g2U+L17vHWGxjQwvU 0B9sMpk580DRMoi+9WQfb85TRb9ygC1lFfbEMLddgEuAgfEjKGqoal6lDo3XC5z1NPHb 29Ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rbD6F7at; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 33-v6si11855421plu.283.2018.08.20.22.13.11; Mon, 20 Aug 2018 22:13:26 -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=@gmail.com header.s=20161025 header.b=rbD6F7at; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726786AbeHUIaT (ORCPT + 99 others); Tue, 21 Aug 2018 04:30:19 -0400 Received: from mail-yb0-f195.google.com ([209.85.213.195]:37101 "EHLO mail-yb0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726628AbeHUIaT (ORCPT ); Tue, 21 Aug 2018 04:30:19 -0400 Received: by mail-yb0-f195.google.com with SMTP id f145-v6so3354773ybg.4 for ; Mon, 20 Aug 2018 22:11:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=u0nxW5SDhuR0cvWLvp9dYb5Hfu9HpYKt5PL/ZEZtZfA=; b=rbD6F7atGDmxMdCk2jaAHJPTfxPhtNeEBlP06bFLTIcEUjnRvJJsZUZrBoUN/4T2WQ wY9OaR0SfPtETJrdjblzyKy3sVv6fTzTWzl3K+3letCz3QPn81b12t81d4mxUE6PhPKm puOQSmPoOFiZqLky3GTNN/OxC6ki3EcNIPXywlh3MEf6JWL+5Ki4TUW9iGI3oHJs58xL WoGgug4SFY4buul5YJzN8kCi483lZqPYOmRM4kW+tGFSv/86eAePkUh1rH5zDyCSVJvE wZsKh7qVhmsJFH/y3Ce+PvBhtQCJigLf3Fu47OWiDOi1r0OgPDQN36OJeJiHEE2bA5Bl fsJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=u0nxW5SDhuR0cvWLvp9dYb5Hfu9HpYKt5PL/ZEZtZfA=; b=IDzoZIhMe6h+SA1RRHIX5vhN71Ru+FMM0s8Rv8WYgNMHaplz/7PA9EdTyI4uEYHDIq AMsmdS65hvvzdML2Bo/T9YYDPY39hXF2FrfoVZUtk8xtg38ojBdc6Cf34TffOvaB1mP4 mFJHVPYWxhk+DOzrLCOchZHPGL6r96DGJIsXdh/FuBd1TMVtsz6y43jAUA21M/0zbxT6 Pz6D6fpxHqKDV24hI6niIQlqvlWykuw28YiX9hPHNvQisiMl7tDPNkpOcgId/HlNEoWQ cC6SujCKhNPtkbDRH6LM6Phd6qtZUK47+gVc5xicD5OCXIFYjOUFuPV7BvW0gmXmkiNp T4EA== X-Gm-Message-State: AOUpUlFx5mGzOL7Wrc0kIWQe0L6JYdEPtkoRCDW5QAyZsRA1QUiyZNG5 15GTdHE9IX3PiZby+AwER3sRokDAiwxH6WJZUIk= X-Received: by 2002:a25:bdcf:: with SMTP id g15-v6mr3711493ybk.494.1534828305596; Mon, 20 Aug 2018 22:11:45 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a0d:c142:0:0:0:0:0 with HTTP; Mon, 20 Aug 2018 22:11:44 -0700 (PDT) In-Reply-To: <20180818012213.GA14115@bombadil.infradead.org> References: <20180817231834.15959-1-guro@fb.com> <20180818012213.GA14115@bombadil.infradead.org> From: Konstantin Khlebnikov Date: Tue, 21 Aug 2018 08:11:44 +0300 Message-ID: Subject: Re: [PATCH RFC] mm: don't miss the last page because of round-off error To: Matthew Wilcox 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. There is macro DIV_ROUND_UP in kernel.h