From patchwork Thu Mar 17 23:46:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 12784673 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 099AEC433F5 for ; Thu, 17 Mar 2022 23:46:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 704D78D0002; Thu, 17 Mar 2022 19:46:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6B4438D0001; Thu, 17 Mar 2022 19:46:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 555A58D0002; Thu, 17 Mar 2022 19:46:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0047.hostedemail.com [216.40.44.47]) by kanga.kvack.org (Postfix) with ESMTP id 418E98D0001 for ; Thu, 17 Mar 2022 19:46:29 -0400 (EDT) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id E2525A3EE7 for ; Thu, 17 Mar 2022 23:46:28 +0000 (UTC) X-FDA: 79255514856.24.20337B9 Received: from mail-ed1-f42.google.com (mail-ed1-f42.google.com [209.85.208.42]) by imf27.hostedemail.com (Postfix) with ESMTP id 89B7340015 for ; Thu, 17 Mar 2022 23:46:28 +0000 (UTC) Received: by mail-ed1-f42.google.com with SMTP id t1so8437788edc.3 for ; Thu, 17 Mar 2022 16:46:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id; bh=wJ9C3J6ldgMmWmiRZCUDyOYck90AMGbCNRCRpZ2WpEI=; b=eBF41fbYk76Hes3n3yt6hoMjNAovoV0umtBUs4Rn5sAl6NSBb4JfEqRFYzDICV8p38 Rjm+LSvimHNHh+Ltn36YsYci4TBSiuDW4O6RqJUAdXDdolPaC32nSHKaP91cH8q/ZLKD YlB9Dk3nv11CG2oOeOzRA5EMFGP0pblkE8GxoCOnwo0l6Gp3ixt+p4xEgYJ7twXoi2GR 0z6WaynJB2MPbIrgobcHhNaiX2unoNr6z8T2r4LAOqJims5Ax9T15JMI2zAGOrWDyecA qyInDz9Bf6E3ABOZtqDwHdkRADDWaBRinaCuWuN5mbfJ3IXNYXzcJ7PwoYKR/pnQO4zX CXHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=wJ9C3J6ldgMmWmiRZCUDyOYck90AMGbCNRCRpZ2WpEI=; b=fJBEpewomf6FhND8WstgseO8gKHt8ux2H7m1uscKscuK+apfsJmzrfEf21nwyGdEvp 6e2yAdQdXOD2oUjFzeqEBJUdRTttKEL2DreFlkxAu9UCPlliavHQdi81lbRPS4GoR+tr Pryxc+tY4wqNHjP4DnMdxWlJQAktS576KzoQ/08foDZj6wHhGB+NgMQ3+cnvh2cROPGl 6rkAO4VqAJdLwDWZ0HNvXSdYxXgHpjlfuIdet3744xq5TBg47ZFSATv3MPZM9oE8yu8X PmTbMc5dgYBDYrMzuMgjtk1vbUryrxOdIsVAzLQjDawGiT/3asb2idYvNzqeoIAGcNHZ Nztg== X-Gm-Message-State: AOAM532WG83yVKEDNIFox7YkozBcWbZKS4C0dGsSVUUdRHj51ezqF7Kx oCOPVKBYVJl6Yhja6ZmNgQU= X-Google-Smtp-Source: ABdhPJylMqpG/YnJT5xFDtXt899LoLU7cPojjVCIJ2CkoZo4cfr5iiUevjFBywdcVx6axlkZ43eHqA== X-Received: by 2002:a50:9d47:0:b0:40f:9d3d:97b6 with SMTP id j7-20020a509d47000000b0040f9d3d97b6mr6886879edk.392.1647560787129; Thu, 17 Mar 2022 16:46:27 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id oz10-20020a1709077d8a00b006dd5103bac9sm3006342ejc.107.2022.03.17.16.46.26 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Mar 2022 16:46:26 -0700 (PDT) From: Wei Yang To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, Wei Yang Subject: [PATCH] mm/vmscan: sc->reclaim_idx must be a valid zone index Date: Thu, 17 Mar 2022 23:46:24 +0000 Message-Id: <20220317234624.23358-1-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 X-Stat-Signature: 8a74f9z86dfh6b3ddpaezofy1un4d5by Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=eBF41fbY; spf=pass (imf27.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.208.42 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspam-User: X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 89B7340015 X-HE-Tag: 1647560788-232781 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000010, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Function lruvec_lru_size() is only used in get_scan_count(), so the only possible zone_idx is sc->reclaim_idx. Since sc->reclaim_idx is ensured to be a valid zone idex, we can remove the extra check for zone iteration. Signed-off-by: Wei Yang --- mm/vmscan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 6e4f0e1e9cea..443c75a9d092 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -586,7 +586,7 @@ unsigned long zone_reclaimable_pages(struct zone *zone) * lruvec_lru_size - Returns the number of pages on the given LRU list. * @lruvec: lru vector * @lru: lru to use - * @zone_idx: zones to consider (use MAX_NR_ZONES for the whole LRU list) + * @zone_idx: zones to consider (use MAX_NR_ZONES - 1 for the whole LRU list) */ static unsigned long lruvec_lru_size(struct lruvec *lruvec, enum lru_list lru, int zone_idx) @@ -594,7 +594,7 @@ static unsigned long lruvec_lru_size(struct lruvec *lruvec, enum lru_list lru, unsigned long size = 0; int zid; - for (zid = 0; zid <= zone_idx && zid < MAX_NR_ZONES; zid++) { + for (zid = 0; zid <= zone_idx; zid++) { struct zone *zone = &lruvec_pgdat(lruvec)->node_zones[zid]; if (!managed_zone(zone))