From patchwork Mon Dec 7 22:09:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Zhao X-Patchwork-Id: 11956969 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=-11.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 C9670C4361B for ; Mon, 7 Dec 2020 22:10:03 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4A48723977 for ; Mon, 7 Dec 2020 22:10:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4A48723977 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 5A5498D0002; Mon, 7 Dec 2020 17:10:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 556688D0001; Mon, 7 Dec 2020 17:10:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 46C5A8D0002; Mon, 7 Dec 2020 17:10:02 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0018.hostedemail.com [216.40.44.18]) by kanga.kvack.org (Postfix) with ESMTP id 308748D0001 for ; Mon, 7 Dec 2020 17:10:02 -0500 (EST) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id E48CD181AEF09 for ; Mon, 7 Dec 2020 22:10:01 +0000 (UTC) X-FDA: 77567879802.26.music60_4d08871273e1 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin26.hostedemail.com (Postfix) with ESMTP id AD5871804B667 for ; Mon, 7 Dec 2020 22:10:01 +0000 (UTC) X-HE-Tag: music60_4d08871273e1 X-Filterd-Recvd-Size: 5196 Received: from mail-qv1-f74.google.com (mail-qv1-f74.google.com [209.85.219.74]) by imf34.hostedemail.com (Postfix) with ESMTP for ; Mon, 7 Dec 2020 22:10:01 +0000 (UTC) Received: by mail-qv1-f74.google.com with SMTP id i11so12746221qvo.11 for ; Mon, 07 Dec 2020 14:10:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=NUUwU6TjT3HyGB9RueCAB8d5pAXhZlLPodEuPtCiIe8=; b=ObBnEqLPiYhcG3Hu24F75+fiSoOlISDP8AEk2dEwKw8DXQ2no8vwQphsjQeaa8mU21 G+yKnsK8H36RdkvZb5ZvjmAshF+j4wymnXefNW9l9NdApT5qh98jXb+mUhSRDMm74EuU c1O+CEyT+xnb6q8cT5uAWvK4n4q7wOzJ37bh0YGWmnTPqM5kT6uzAo7FsYi5HOgAz4T2 z6PlOZIbDSdoSTUeLIxCW8gmDH3D8r4jD1JgCUtq5x4vrHj+GL+Al/csWuzsaZw8T7jx J+ue+XHUU7/u8AKvM6jiEDmf+ukbvucUb5gd8qLAFXXtvUjV1s4MW6SpIyrJm4z1jwxo PxfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=NUUwU6TjT3HyGB9RueCAB8d5pAXhZlLPodEuPtCiIe8=; b=nIx3Io26NXZBJ7Xv9TzEiwUK++ETIt9Ccp85O8Ut460ud3jWbsdNzEI4qGsQZMGwCC CzUtsNR/TxBYPI9a0ZEIKa87d0cZPdjDflRacwTMoUj3EDPQNMuDiT7kvOSMQTuUKBdP Kt5Y+7K4VgfG7xdzvEGSe1+7XdwCI5yX36YISvfwYPKp1DcfaizWd6JbtTDbv3KOJTLY D0iWjQqwXYmXZ0Ejgj9x291bLLQUGisLRqD0oCNN9OloPVIjwMpTz+L1TIbLDO+6gtGQ 595Hr2xBiavjwSk6jJBvJ5Kpo0nnzdh0xz1bMNZ8hBJPBzaTTPDUEM9py8oqkrVGhL9i Yq8A== X-Gm-Message-State: AOAM532ZHrD66mNQGZsFH4mP0wqOQsujJhi5hW2pIrRWG/nh0FtS0JGy CvNiv6CGkExqyIjwkKTEgTpgqoSBITE= X-Google-Smtp-Source: ABdhPJz/8T3IWmeavAxHk+jT7Vw7keSUWRVyXIHJJZI58G9AGi4sgKu7k1sqhZHkTpGeUv/BTJtvpMp4wPU= X-Received: from yuzhao.bld.corp.google.com ([2620:15c:183:200:7220:84ff:fe09:2d90]) (user=yuzhao job=sendgmr) by 2002:a0c:f809:: with SMTP id r9mr23244783qvn.17.1607379000338; Mon, 07 Dec 2020 14:10:00 -0800 (PST) Date: Mon, 7 Dec 2020 15:09:38 -0700 Message-Id: <20201207220949.830352-1-yuzhao@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.29.2.576.ga3fc446d84-goog Subject: [PATCH 00/11] mm: lru related cleanups From: Yu Zhao To: Andrew Morton , Hugh Dickins , Alex Shi Cc: Michal Hocko , Johannes Weiner , Vladimir Davydov , Roman Gushchin , Vlastimil Babka , Matthew Wilcox , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yu Zhao 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: The cleanups are intended to reduce the verbosity in lru list operations and make them less error-prone. A typical example would be how the patches change __activate_page(): static void __activate_page(struct page *page, struct lruvec *lruvec) { if (!PageActive(page) && !PageUnevictable(page)) { - int lru = page_lru_base_type(page); int nr_pages = thp_nr_pages(page); - del_page_from_lru_list(page, lruvec, lru); + del_page_from_lru_list(page, lruvec); SetPageActive(page); - lru += LRU_ACTIVE; - add_page_to_lru_list(page, lruvec, lru); + add_page_to_lru_list(page, lruvec); trace_mm_lru_activate(page); There are a few more places like __activate_page() and they are unnecessarily repetitive in terms of figuring out which list a page should be added onto or deleted from. And with the duplicated code removed, they are easier to read, IMO. Patch 1 to 5 basically cover the above. Patch 6 and 7 make code more robust by improving bug reporting. Patch 8, 9 and 10 take care of some dangling helpers left in header files. Patch 11 isn't strictly a clean-up patch, but it seems still relevant to include it here. Yu Zhao (11): mm: use add_page_to_lru_list() mm: shuffle lru list addition and deletion functions mm: don't pass "enum lru_list" to lru list addition functions mm: don't pass "enum lru_list" to trace_mm_lru_insertion() mm: don't pass "enum lru_list" to del_page_from_lru_list() mm: add __clear_page_lru_flags() to replace page_off_lru() mm: VM_BUG_ON lru page flags mm: fold page_lru_base_type() into its sole caller mm: fold __update_lru_size() into its sole caller mm: make lruvec_lru_size() static mm: enlarge the "int nr_pages" parameter of update_lru_size() include/linux/memcontrol.h | 10 +-- include/linux/mm_inline.h | 115 ++++++++++++++------------------- include/linux/mmzone.h | 2 - include/linux/vmstat.h | 6 +- include/trace/events/pagemap.h | 11 ++-- mm/compaction.c | 2 +- mm/memcontrol.c | 10 +-- mm/mlock.c | 3 +- mm/swap.c | 50 ++++++-------- mm/vmscan.c | 21 ++---- 10 files changed, 91 insertions(+), 139 deletions(-)