From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2DC58C433DF for ; Wed, 20 May 2020 23:26:17 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D711220899 for ; Wed, 20 May 2020 23:26:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=cmpxchg-org.20150623.gappssmtp.com header.i=@cmpxchg-org.20150623.gappssmtp.com header.b="ztU73FgX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D711220899 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cmpxchg.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 31D588000F; Wed, 20 May 2020 19:26:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 27FD18000A; Wed, 20 May 2020 19:26:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 11EA58000F; Wed, 20 May 2020 19:26:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0179.hostedemail.com [216.40.44.179]) by kanga.kvack.org (Postfix) with ESMTP id E0F6C8000A for ; Wed, 20 May 2020 19:26:12 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 96E6F180AD81A for ; Wed, 20 May 2020 23:26:12 +0000 (UTC) X-FDA: 76838682984.18.car70_190cec452bc57 X-HE-Tag: car70_190cec452bc57 X-Filterd-Recvd-Size: 4879 Received: from mail-qv1-f68.google.com (mail-qv1-f68.google.com [209.85.219.68]) by imf07.hostedemail.com (Postfix) with ESMTP for ; Wed, 20 May 2020 23:26:12 +0000 (UTC) Received: by mail-qv1-f68.google.com with SMTP id z9so2227795qvi.12 for ; Wed, 20 May 2020 16:26:11 -0700 (PDT) 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=k1mJyFxqpgpRzCt8CICzuJvDAagkfPR/HMnvDC6JCyY=; b=ztU73FgX01oSp/NMDzA3s6wLAWqemke1edTHLBlfwK9d2FVAn7pD+tArAISYdGoz7L Ypfr5EHdNe9un0Ie+AMD5IE3dm8h3CGusgw8hsPu9ZUkXVG8A51EaAffxsk5T8iiWFAe xtiaaL5aQURwIyCVnz5CyGKiPgfPVsamum8BJ2c5ofoLUyoiXENrOdR+1uWnUSbKXPBg Ff0B+cycL5NqIdYQs2aD/eFO88CRg0vYo1gIEcjYRcGHPnKueMcv/yv5jd7nRU09os5u t7ma1B4qYkHr6/J8Qjog9NU4MXUf45aePH1niFKtNgTZxnfzY31ZKSQajZ0tIwE3Rbat lHDA== 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=k1mJyFxqpgpRzCt8CICzuJvDAagkfPR/HMnvDC6JCyY=; b=Cs9cZoXYO45PV8D/2iiU3GiKCmsKGiAkOBBCbEmRqvzn211Qzofexeca15h8Qzbdsn 5FP8R+iL/6RcNc7jipCs3Ojx/6NmwUMfGpjPXXyu8gJTJCgVfuQZkKE03SkMsxC5OUOF YU4jJZ2sYRI+FLgZDe8DCY4+jnAvayJujTJEstK824GsXilwE2c7qhK0JwPRfrHYWvXP swkb3qkWbMjOx88X5/zWqgLvuJVgAdb7LfN81mqnfTtEGjMBs+M0iswDl+v2Sx5jZU1u z6t4+w8AtfYzSg9YjK4K+QHWXp6v+U6lXOdtFNUXiR7K3SVGIp+o2QDpTukDiS8hmlwN dDxQ== X-Gm-Message-State: AOAM5320yobUZu0OxwwiIOjlkV/L4JOufX7td9cmLFk4VhwHM2nr/4Bk 0IQsK2JJ6U5do4Hn3r/CW8ZOKGsOo4w= X-Google-Smtp-Source: ABdhPJwIoVni4xkak/KSGtFyIkrBv+2cj6B2hO1dZHEdUPHsdcUxiqPFz+TFg6pubttpAcmk8zKYXQ== X-Received: by 2002:a0c:f407:: with SMTP id h7mr7159580qvl.116.1590017170707; Wed, 20 May 2020 16:26:10 -0700 (PDT) Received: from localhost ([2620:10d:c091:480::1:4708]) by smtp.gmail.com with ESMTPSA id j36sm3921691qta.71.2020.05.20.16.26.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 May 2020 16:26:10 -0700 (PDT) From: Johannes Weiner To: linux-mm@kvack.org Cc: Rik van Riel , Minchan Kim , Michal Hocko , Andrew Morton , Joonsoo Kim , linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 07/14] mm: vmscan: drop unnecessary div0 avoidance rounding in get_scan_count() Date: Wed, 20 May 2020 19:25:18 -0400 Message-Id: <20200520232525.798933-8-hannes@cmpxchg.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200520232525.798933-1-hannes@cmpxchg.org> References: <20200520232525.798933-1-hannes@cmpxchg.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: When we calculate the relative scan pressure between the anon and file LRU lists, we have to assume that reclaim_stat can contain zeroes. To avoid div0 crashes, we add 1 to all denominators like so: anon_prio =3D swappiness; file_prio =3D 200 - anon_prio; [...] /* * The amount of pressure on anon vs file pages is inversely * proportional to the fraction of recently scanned pages on * each list that were recently referenced and in active use. */ ap =3D anon_prio * (reclaim_stat->recent_scanned[0] + 1); ap /=3D reclaim_stat->recent_rotated[0] + 1; fp =3D file_prio * (reclaim_stat->recent_scanned[1] + 1); fp /=3D reclaim_stat->recent_rotated[1] + 1; spin_unlock_irq(&pgdat->lru_lock); fraction[0] =3D ap; fraction[1] =3D fp; denominator =3D ap + fp + 1; While reclaim_stat can contain 0, it's not actually possible for ap + fp to be 0. One of anon_prio or file_prio could be zero, but they must still add up to 200. And the reclaim_stat fraction, due to the +1 in there, is always at least 1. So if one of the two numerators is 0, the other one can't be. ap + fp is always at least 1. Drop the + 1. Signed-off-by: Johannes Weiner --- mm/vmscan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 43f88b1a4f14..6cd1029ea9d4 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2348,7 +2348,7 @@ static void get_scan_count(struct lruvec *lruvec, s= truct scan_control *sc, =20 fraction[0] =3D ap; fraction[1] =3D fp; - denominator =3D ap + fp + 1; + denominator =3D ap + fp; out: for_each_evictable_lru(lru) { int file =3D is_file_lru(lru); --=20 2.26.2