From patchwork Tue Apr 5 08:23:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 12801250 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 CAABDC433EF for ; Tue, 5 Apr 2022 08:24:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 126E86B0071; Tue, 5 Apr 2022 04:24:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0D6DE6B0073; Tue, 5 Apr 2022 04:24:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EE0156B0074; Tue, 5 Apr 2022 04:24:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0162.hostedemail.com [216.40.44.162]) by kanga.kvack.org (Postfix) with ESMTP id DF23D6B0071 for ; Tue, 5 Apr 2022 04:24:41 -0400 (EDT) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 9F546182B0301 for ; Tue, 5 Apr 2022 08:24:31 +0000 (UTC) X-FDA: 79322138784.27.72ECD92 Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) by imf30.hostedemail.com (Postfix) with ESMTP id 2845980002 for ; Tue, 5 Apr 2022 08:24:30 +0000 (UTC) Received: by mail-ej1-f50.google.com with SMTP id bq8so25032168ejb.10 for ; Tue, 05 Apr 2022 01:24:30 -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=7BiT/v9h8nJuCel6+Bx/8jYMLtLXBMPd6N+eIXP7hBw=; b=DC0tDBOEeGVXFVFSwC57+jBVHL0NoSxgiW+6j5YR85+D5Z43J3FaSCh2aqLrttc7uO A6Q8njAkAvSbnoWF+5h9RfL/HUovJC8SMk0HrYRm9oA0KQBoLhsOabfPiHQLjdnG7dDZ sihowPth50tsvXDssqjTCtWYhxUWw/Quu3pXT8Lc4EJ+XgA0vjTUOoj6saAD+IrHPqbU w/MdmYFUVxdo1n6IdKloJdS5MFFOMCD3WIMfinJCJ06TQa6dY24uYSyCXoigsv5Zw/xx pFa64uCJprfeCQCXpQIA7elGX0Aj0ZJ+4dKrub0oyFL20omTqO4IcqbXHJj0R0Y1JFCP /uuw== 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=7BiT/v9h8nJuCel6+Bx/8jYMLtLXBMPd6N+eIXP7hBw=; b=GVWDmfOCnUR0Sp/Vd85mLNl0K8ijgTbyb2dojcAe93lZC7DAS+IStTqW38Avu58fsg q5Bl1zB+dcsFsUdaGd3/hZi7wR9sslKbn7YvrEB5Hgm/T/oLdY58nBKbjqgRjSxmKIq0 Jy9JyNzja657uSC/D4L47PMmiHKdzj1ruUfJ9+8ZwYc9UHIc98itvrA86bUYIicJESa8 CuwdIH1hX+2J7aFBIqLeZmFXlzWB9ikR9UzdBNXekV68+sfiJcpuho+q3Riuh6opSp+E YifUHieY52hbJZXSKv3/QqZ8vyZ9zFJ71MSqXldAhfO3D/LH04sHZW4gII70ljSlPxxj jRhQ== X-Gm-Message-State: AOAM5300bpkMJWT3Awn9sNqQwUOI7g3y5mX825pPpN2x30wG+wIpoyo+ bZaajzotRdaQZeCpbGGVMXE= X-Google-Smtp-Source: ABdhPJzqmsuLFRyM/QN7UsWxBoGXKdtXlPoM82WjQBO0s4fCYve3XUFqXtvO2AXxEt5Urjp5OBZpRw== X-Received: by 2002:a17:907:9602:b0:6df:e82c:f84 with SMTP id gb2-20020a170907960200b006dfe82c0f84mr2366859ejc.590.1649147069735; Tue, 05 Apr 2022 01:24:29 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id ka6-20020a170907990600b006ce54c95e3csm5270625ejc.161.2022.04.05.01.24.29 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Apr 2022 01:24:29 -0700 (PDT) From: Wei Yang To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, Wei Yang , Johannes Weiner , Mel Gorman Subject: [PATCH] mm/vmscan: reorder scan_balance definition to simplify the scan type check Date: Tue, 5 Apr 2022 08:23:57 +0000 Message-Id: <20220405082357.22606-1-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 X-Rspam-User: Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=DC0tDBOE; spf=pass (imf30.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.218.50 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 2845980002 X-Stat-Signature: uhrrh5o1x5ammqfesxf4jp5xpmrc53hj X-HE-Tag: 1649147070-952976 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: Even is_file_lru() return bool type, we leverage it as an index for anon or file. With this in hand, after reorder scan_balance definition, we can compare directly between scan_balance and file to get the exclusive scan type. After this, the code looks more readable and save some instructions. Signed-off-by: Wei Yang CC: Johannes Weiner CC: Mel Gorman --- mm/vmscan.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 89745cf34386..0b7cc9309e70 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2638,10 +2638,10 @@ static bool inactive_is_low(struct lruvec *lruvec, enum lru_list inactive_lru) } enum scan_balance { - SCAN_EQUAL, - SCAN_FRACT, SCAN_ANON, SCAN_FILE, + SCAN_EQUAL, + SCAN_FRACT, }; /* @@ -2838,7 +2838,7 @@ static void get_scan_count(struct lruvec *lruvec, struct scan_control *sc, case SCAN_FILE: case SCAN_ANON: /* Scan one type exclusively */ - if ((scan_balance == SCAN_FILE) != file) + if (scan_balance != file) scan = 0; break; default: