Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp73860ybk; Fri, 8 May 2020 14:24:07 -0700 (PDT) X-Google-Smtp-Source: APiQypIN4dlnfvd4ndHU8CE32B8xmi2kqnDDVKNZwlB+FdnmyDcBYHk4Jlfo4IZakDFg7JcMIFFZ X-Received: by 2002:aa7:c492:: with SMTP id m18mr3962322edq.346.1588973047473; Fri, 08 May 2020 14:24:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588973047; cv=none; d=google.com; s=arc-20160816; b=ztHlxK8JZYbLkV2Rdh9L32JoA+2ISVosowpWOGGgCbosDuSVu4ucvbJLEwGZWdrYaO +Se9PFupxbzuBjd66LtfFbwrOcD7mF0tKiy9TwKbih+ImS1lBQr724QSi7Ig7G4ViJz/ IcBdq6mVn/Efs3SkHCVJa4UHSeOSSoDPNrhbaudT/Y1W38qPtIsOvFq0Zlo8pWKlPi/M 8O/89teauljdIo9qaxOJ2i8YxK3TYbGXtDhxe3DlT6G1kaw63fqf2rHM3mGiv+Z9uU0Y 0Jsfs3MsIPCye7tnINYZxQnEuNnSuhDH86N+tuklG5+nMDG/fDgIU3qGG7bYAUpOw2o0 Y+xQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:mime-version :message-id:date:dkim-signature; bh=H7ED1E6iU6GJrL2T+LX5Bj/uEQY3JnE8s7k3T/+egkg=; b=YP5y2lzb1DnNqfE3JF3jItwKkZkca7aQaAqdBeFRkiovHti++Ec3mMFR7TRyT3JgA4 9jjiEI8cC0s51pKienCtUIyrhmJqyJX0r9BjyIgdhCs0w7VebAiZBhWBmmckpM8lNLZ8 8yTgxjG8WC54wYVcVRDHWKXrahezCmopSG4GxSh/Sht1h3wXdqGLomqiebRjPDNzQe8L ECmIItyXKASdraAlPITaJvsLLJQssEVTDbAbKmuOkjDhTJvsdaROCK4N8YphKOIfUlky GEFRTw6pdWxfd/5iAvylwJlzZHIMc9+mugvlMqu9/HQAaruI6oAI/qA5uwb/IQH5RjZk EScw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=XY5On+Go; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i24si1803329edy.602.2020.05.08.14.23.43; Fri, 08 May 2020 14:24:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=XY5On+Go; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727893AbgEHVW1 (ORCPT + 99 others); Fri, 8 May 2020 17:22:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727787AbgEHVW0 (ORCPT ); Fri, 8 May 2020 17:22:26 -0400 Received: from mail-pf1-x44a.google.com (mail-pf1-x44a.google.com [IPv6:2607:f8b0:4864:20::44a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA49BC05BD43 for ; Fri, 8 May 2020 14:22:26 -0700 (PDT) Received: by mail-pf1-x44a.google.com with SMTP id r5so3020557pfh.12 for ; Fri, 08 May 2020 14:22:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=H7ED1E6iU6GJrL2T+LX5Bj/uEQY3JnE8s7k3T/+egkg=; b=XY5On+GozPMjP6G7zkPxPhW0eE2rp4+jjdvdyV+TE6avG+bX2A6pptdCo2RW+Rn3no KQU1jyKtWYfy9dkYUy4EImZ9+uEOAdDNPH0YwlyphH5/olIWRcFiT8PHrG0uYO6VgAgO E/dVasAEh4SuLPL7R9m2RQCh6iAMAIo8SZvlMpxpYiJTLphr4eSjp2MuwGrDq5yyaNzx 4N+w8pQqM2elRyzuI36Dqha8UAGJbBpiCNZBetFNyysG+bhxK79vAv6P6/dmFhDWQ0cZ 53BuMgiu5tPKdTehsHF+yErNAw9OFP+cGYZN4uCLlChZJodaZgBljzVYxcpHxpU3zoun Gm9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=H7ED1E6iU6GJrL2T+LX5Bj/uEQY3JnE8s7k3T/+egkg=; b=SiTgpESgsFuSGfGunnk9edXQ6fvNo9OgtcO+741Bh3W7WKK+Qv7SGcIqJR1MUSO6fP GfEhdqQymO7kvgSAQ6eA39/PnGky01JKrpNH06I31K14Adf2seseTI590Ozbe9kLqRvr e94uuly5MAmZcYCV4kCnUHKOxJnGUsqJCxhpXpesIVBBg/TX2xhFwUZfxkw0U4Vk/15D rPj9WDACeIt/15kClNPYSjNtonyyz/krjbju7ICwrs55if5YpeZ79Sq7YMkFIwRjzTWk nDRO9TwrIBSJRHmlvxRaNCLdErVCH7WEmQQiIi3ivV68K6r3wyIjilcoFUab1j8JoYeK FE4Q== X-Gm-Message-State: AGi0PuZTu8ZXU8Dd3Oe1Smwsrr+J5OxWiI9slqzvlrjwRP6umI0p1C8H /uy2BDG3T+111SWiTU9LMgKj1AScWLi8KQ== X-Received: by 2002:a17:90a:cb0b:: with SMTP id z11mr7520557pjt.62.1588972946092; Fri, 08 May 2020 14:22:26 -0700 (PDT) Date: Fri, 8 May 2020 14:22:13 -0700 Message-Id: <20200508212215.181307-1-shakeelb@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.26.2.645.ge9eca65c58-goog Subject: [PATCH 1/3] mm: swap: fix vmstats for huge pages From: Shakeel Butt To: Mel Gorman , Johannes Weiner , Roman Gushchin , Michal Hocko Cc: Andrew Morton , Yafang Shao , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, Shakeel Butt Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Many of the callbacks called by pagevec_lru_move_fn() do not correctly update the vmstats for huge pages. Fix that. Also __pagevec_lru_add_fn() use the irq-unsafe alternative to update the stat as the irqs are already disabled. Signed-off-by: Shakeel Butt --- mm/swap.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/mm/swap.c b/mm/swap.c index a37bd7b202ac..3dbef6517cac 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -225,7 +225,7 @@ static void pagevec_move_tail_fn(struct page *page, struct lruvec *lruvec, del_page_from_lru_list(page, lruvec, page_lru(page)); ClearPageActive(page); add_page_to_lru_list_tail(page, lruvec, page_lru(page)); - (*pgmoved)++; + (*pgmoved) += hpage_nr_pages(page); } } @@ -285,7 +285,7 @@ static void __activate_page(struct page *page, struct lruvec *lruvec, add_page_to_lru_list(page, lruvec, lru); trace_mm_lru_activate(page); - __count_vm_event(PGACTIVATE); + __count_vm_events(PGACTIVATE, hpage_nr_pages(page)); update_page_reclaim_stat(lruvec, file, 1); } } @@ -503,6 +503,7 @@ static void lru_deactivate_file_fn(struct page *page, struct lruvec *lruvec, { int lru, file; bool active; + int nr_pages = hpage_nr_pages(page); if (!PageLRU(page)) return; @@ -536,11 +537,11 @@ static void lru_deactivate_file_fn(struct page *page, struct lruvec *lruvec, * We moves tha page into tail of inactive. */ add_page_to_lru_list_tail(page, lruvec, lru); - __count_vm_event(PGROTATED); + __count_vm_events(PGROTATED, nr_pages); } if (active) - __count_vm_event(PGDEACTIVATE); + __count_vm_events(PGDEACTIVATE, nr_pages); update_page_reclaim_stat(lruvec, file, 0); } @@ -929,6 +930,7 @@ static void __pagevec_lru_add_fn(struct page *page, struct lruvec *lruvec, { enum lru_list lru; int was_unevictable = TestClearPageUnevictable(page); + int nr_pages = hpage_nr_pages(page); VM_BUG_ON_PAGE(PageLRU(page), page); @@ -966,13 +968,13 @@ static void __pagevec_lru_add_fn(struct page *page, struct lruvec *lruvec, update_page_reclaim_stat(lruvec, page_is_file_lru(page), PageActive(page)); if (was_unevictable) - count_vm_event(UNEVICTABLE_PGRESCUED); + __count_vm_events(UNEVICTABLE_PGRESCUED, nr_pages); } else { lru = LRU_UNEVICTABLE; ClearPageActive(page); SetPageUnevictable(page); if (!was_unevictable) - count_vm_event(UNEVICTABLE_PGCULLED); + __count_vm_events(UNEVICTABLE_PGCULLED, nr_pages); } add_page_to_lru_list(page, lruvec, lru); -- 2.26.2.645.ge9eca65c58-goog