From patchwork Fri Jan 22 22:05:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Zhao X-Patchwork-Id: 12040719 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.6 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 20ED1C433E0 for ; Fri, 22 Jan 2021 22:06:06 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 903A623B1A for ; Fri, 22 Jan 2021 22:06:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 903A623B1A 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 DB5006B0005; Fri, 22 Jan 2021 17:06:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D65AD6B0007; Fri, 22 Jan 2021 17:06:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C7C1E6B0008; Fri, 22 Jan 2021 17:06:04 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0231.hostedemail.com [216.40.44.231]) by kanga.kvack.org (Postfix) with ESMTP id B34A16B0005 for ; Fri, 22 Jan 2021 17:06:04 -0500 (EST) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 4F88418215EFC for ; Fri, 22 Jan 2021 22:06:04 +0000 (UTC) X-FDA: 77734794648.04.road91_3610a282756f Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin04.hostedemail.com (Postfix) with ESMTP id 2BCDA80212D2 for ; Fri, 22 Jan 2021 22:06:04 +0000 (UTC) X-HE-Tag: road91_3610a282756f X-Filterd-Recvd-Size: 5063 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf07.hostedemail.com (Postfix) with ESMTP for ; Fri, 22 Jan 2021 22:06:03 +0000 (UTC) Received: by mail-yb1-f201.google.com with SMTP id u14so6861620ybu.9 for ; Fri, 22 Jan 2021 14:06:03 -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=v825TuBJU359gqimRLyU0L4kx6zR5e87EOsaxQ3/+pY=; b=vX1/VB6OOOfUKCNJCysnx2cH3bEfyD11W9g28UBKgMxrU+mRNFPZVqAkpplFzOdE74 5q5Ht10jKYI1z43rwA7vx/VUajqbwddShlGhUWcGEFtYslzjALozvAzzq78DZN8Cy8Vi NziDfiYZLpiXANXhIjZlCLxHLgMpAG0wpjefHOOvx+hKzbeQEeGCkzM/hhfU4KWfYJIX IeMWn/h81ShrunphLQOlPmlFo9LaJP7PUABjBre4jDlA2+r3Lok0rtZtJdQvP9LikCyP B7dEojxmXoRiDSSGjGwxXgqOsTLaDksKqiiwDERgNNJ+N30jq3w4UufK/juMzcDgrQOv +5GA== 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=v825TuBJU359gqimRLyU0L4kx6zR5e87EOsaxQ3/+pY=; b=nyfx4GwSan65x5nUpSSJvlj1/w9AguxIjIz/9UqEpwgCLafaqgtA75xJQMQCSgZ3tx a0guHbrrENG3aHSJRohFTbq6eWgGya+v4ikSe7CSdT2n0jyRV2lVlihN2xrRjS+imj2e Gv6+71u6p5Nj3FuOmD/780jbpZ1gKPwwIc2d+pa4npsVPy5cXVCe99AZqLN8zX9/f2Zy MSLjh3ZRb9pC+sV9u3r9TB7OBajyCAffL3ia7RHZISCjYX29/okFXwfCLTrVW3JzykI0 CipJvkQYwAKFBNoAc/00/qRcckd0fNCs3MzL5/RFtMSlH0d11h+FLfhmhQ3aTq237z2G MDdQ== X-Gm-Message-State: AOAM533vnoZQXeXJ1EGVLf7hqJK667PrnHE5LT5tRecQxfLsy+Vyg3hi dkq/mdJyTBhp57lOx5+EaZh1O8Aa0YY= X-Google-Smtp-Source: ABdhPJzizdI1Pctd47HT9kYj/ZlA3ro/gwt1sqn9CT7+iZLcmBgO8kcRrbRVt7fvr1U0zz7GrnIzqknqmnA= X-Received: from yuzhao.bld.corp.google.com ([2620:15c:183:200:5129:9a91:ef0e:c1a9]) (user=yuzhao job=sendgmr) by 2002:a25:2a86:: with SMTP id q128mr10168393ybq.387.1611353162833; Fri, 22 Jan 2021 14:06:02 -0800 (PST) Date: Fri, 22 Jan 2021 15:05:50 -0700 Message-Id: <20210122220600.906146-1-yuzhao@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.30.0.280.ga3ce27912f-goog Subject: [PATCH v2 00/10] 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. v1 -> v2: dropped the last patch in this series based on the discussion here: https://lore.kernel.org/patchwork/patch/1350552/#1550430 Yu Zhao (10): 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 include/linux/mm_inline.h | 113 ++++++++++++++------------------- include/linux/mmzone.h | 2 - include/trace/events/pagemap.h | 11 ++-- mm/compaction.c | 2 +- mm/mlock.c | 3 +- mm/swap.c | 50 ++++++--------- mm/vmscan.c | 21 ++---- 7 files changed, 77 insertions(+), 125 deletions(-)