Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp74183ybk; Fri, 8 May 2020 14:24:44 -0700 (PDT) X-Google-Smtp-Source: APiQypLf2R7z8e1eqJOZA6B5EswNT0ObB7xTDE4BgWv/yLzZVb6Os7coV6lx+dm+43byB1TlLcXl X-Received: by 2002:aa7:d4c3:: with SMTP id t3mr3840537edr.191.1588973083949; Fri, 08 May 2020 14:24:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588973083; cv=none; d=google.com; s=arc-20160816; b=Wbm8zvPiT2SxiGiwaSNmDptvOKIWhSi3DVOCKj/v0835j4acrkcPyn/CVEK0YauWSb ldici/HUOCWijmyrKT56fZ3dQ19f7bGRKbJgT0FSCcwwL2nFAh7c+Tl9pZ98dKHeKA0F 49ui37y/W0qdV3GEhvPt6Pw2LKdq+1dfq+0pDUv+/XhorB/BMA+odwrMZL+LbyQOKMX1 FsMSXmHOtSddpJZveB7pHknWdGsRavjEj9tlVez977h3OPjyyqIy+C1Db0N83ub4LEfR LYJ6EP31fcqrM00jHiQ1Jg3LNIOHQ+onjA2bzbR8o1A5MBwPL6wkmbbspAJnHz3JOJHz TV+w== 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:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=WB4fh0ll1orLfT6cXNAXpIF6IJgnNIJAflmvuUUH6tI=; b=BGvIH6hP1JoGQnOIHEJCt5oJKHLmj7Nl8OS+d4vym7aGMJHmtBzXkTqPyxgO2yN/ek MegY5QMza1GbGlGK0SGI+mioqlUN4aTxWk9imwU19uyUQ9FUV//AP4d0g5pHe+OtAxwb loc52h13M9v5T/OG2R82wFnAjc551Pnu+bfjWWKA6eQV9PwC1ZhzPEdPMCwY+ru8b6wF c3W+jzlzcFYlJO8wh6peE2d8lNl1BOCkJqZ1UeWaJeK4LBnKiJbiAS9+NXQ/D6HbGr3L ZElv00UinpBoXPQct2O6YBV/c1ZbbTswJ4beO01OaVnQiDZP3KqolKNfCds+NE8car74 NIYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ljlb+5Jo; 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 h11si1579928ejc.416.2020.05.08.14.24.21; Fri, 08 May 2020 14:24:43 -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=ljlb+5Jo; 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 S1727940AbgEHVWh (ORCPT + 99 others); Fri, 8 May 2020 17:22:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727787AbgEHVWh (ORCPT ); Fri, 8 May 2020 17:22:37 -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 13732C061A0C for ; Fri, 8 May 2020 14:22:37 -0700 (PDT) Received: by mail-pf1-x44a.google.com with SMTP id b13so3051346pfp.2 for ; Fri, 08 May 2020 14:22:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=WB4fh0ll1orLfT6cXNAXpIF6IJgnNIJAflmvuUUH6tI=; b=ljlb+5JoPOLhwCwo/9ooaMm5dNWWqB4RKavWnR1bMTb4L6DZlaJkSQfWkg3sAAEQ0X UMnUuP9OvKrvFO2Zf1tnvuK0HExsQ2dYx49Deh2BpHI0OnP5ZatGHYAs8ZTI/yxrils3 xzpe4ILlD48aErissngz/JZQjPXUgLkKPbNMlhHbgVIt6JvI2Qqhq9LILj81H24qLUpd 2GqNHMP6geeEqMap9slI4hgNGU5PWE9SdVjpN1ZygLe6+JYzxYDnJcgw76g8ZJaiwYbx XGaBJ2xHrlPcPEipfB3nycm7Y2ZiWhkuNvSYmpS4fjdgG5Kmdhl2nIvXnPOUcLCgKgr5 47gQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=WB4fh0ll1orLfT6cXNAXpIF6IJgnNIJAflmvuUUH6tI=; b=Yd7Ddnolv66K/NwMbqQ5bB9ezxYGMPJ/XrCEfHjcuFzot1DaSFruBpX7U3edrg+l+Y nSWUWm4ZC0UwpmGHcotIr2j8EahRtMy9ySoMCZWv0svKm0zZTT2Li2w/7TnPxgghkXL4 LxUCFgAV+lUdZmD57pAtgsxd1MBiNWrirns624mk7tT2pJUmm1yotugN6OzjzIwDRXw9 8ngMBJ8eLi9bkKNZPeyJ148PpQcgOGR2YPQ2Ii1WnjjsaLJ0OX2gi/y/DnDvolyg002N w/jVmMN42tB+2OWO+AiPDJl3BdtMvWqDr0Zy/y029i32PZBIeYx89GSZfFToWNqWCbyl XJHw== X-Gm-Message-State: AGi0Puai5Ln6FqCPaFaOg9As8BdVJxPtBF4DTv2NUjN5nC6AxX6tbpUi VaQwwBDSD19tAcZ5GQlOuR9cyKMKNDMZZg== X-Received: by 2002:a17:90a:6f22:: with SMTP id d31mr7728053pjk.14.1588972956538; Fri, 08 May 2020 14:22:36 -0700 (PDT) Date: Fri, 8 May 2020 14:22:14 -0700 In-Reply-To: <20200508212215.181307-1-shakeelb@google.com> Message-Id: <20200508212215.181307-2-shakeelb@google.com> Mime-Version: 1.0 References: <20200508212215.181307-1-shakeelb@google.com> X-Mailer: git-send-email 2.26.2.645.ge9eca65c58-goog Subject: [PATCH 2/3] mm: swap: memcg: fix memcg stats 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 The commit 2262185c5b28 ("mm: per-cgroup memory reclaim stats") added PGLAZYFREE, PGACTIVATE & PGDEACTIVATE stats for cgroups but missed couple of places and PGLAZYFREE missed huge page handling. Fix that. Also for PGLAZYFREE use the irq-unsafe function to update as the irq is already disabled. Fixes: 2262185c5b28 ("mm: per-cgroup memory reclaim stats") Signed-off-by: Shakeel Butt --- mm/swap.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/mm/swap.c b/mm/swap.c index 3dbef6517cac..4eb179ee0b72 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -278,6 +278,7 @@ static void __activate_page(struct page *page, struct lruvec *lruvec, if (PageLRU(page) && !PageActive(page) && !PageUnevictable(page)) { int file = page_is_file_lru(page); int lru = page_lru_base_type(page); + int nr_pages = hpage_nr_pages(page); del_page_from_lru_list(page, lruvec, lru); SetPageActive(page); @@ -285,7 +286,8 @@ 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_events(PGACTIVATE, hpage_nr_pages(page)); + __count_vm_events(PGACTIVATE, nr_pages); + __count_memcg_events(lruvec_memcg(lruvec), PGACTIVATE, nr_pages); update_page_reclaim_stat(lruvec, file, 1); } } @@ -540,8 +542,10 @@ static void lru_deactivate_file_fn(struct page *page, struct lruvec *lruvec, __count_vm_events(PGROTATED, nr_pages); } - if (active) + if (active) { __count_vm_events(PGDEACTIVATE, nr_pages); + __count_memcg_events(lruvec_memcg(lruvec), PGDEACTIVATE, nr_pages); + } update_page_reclaim_stat(lruvec, file, 0); } @@ -551,13 +555,15 @@ static void lru_deactivate_fn(struct page *page, struct lruvec *lruvec, if (PageLRU(page) && PageActive(page) && !PageUnevictable(page)) { int file = page_is_file_lru(page); int lru = page_lru_base_type(page); + int nr_pages = hpage_nr_pages(page); del_page_from_lru_list(page, lruvec, lru + LRU_ACTIVE); ClearPageActive(page); ClearPageReferenced(page); add_page_to_lru_list(page, lruvec, lru); - __count_vm_events(PGDEACTIVATE, hpage_nr_pages(page)); + __count_vm_events(PGDEACTIVATE, nr_pages); + __count_memcg_events(lruvec_memcg(lruvec), PGDEACTIVATE, nr_pages); update_page_reclaim_stat(lruvec, file, 0); } } @@ -568,6 +574,7 @@ static void lru_lazyfree_fn(struct page *page, struct lruvec *lruvec, if (PageLRU(page) && PageAnon(page) && PageSwapBacked(page) && !PageSwapCache(page) && !PageUnevictable(page)) { bool active = PageActive(page); + int nr_pages = hpage_nr_pages(page); del_page_from_lru_list(page, lruvec, LRU_INACTIVE_ANON + active); @@ -581,8 +588,8 @@ static void lru_lazyfree_fn(struct page *page, struct lruvec *lruvec, ClearPageSwapBacked(page); add_page_to_lru_list(page, lruvec, LRU_INACTIVE_FILE); - __count_vm_events(PGLAZYFREE, hpage_nr_pages(page)); - count_memcg_page_event(page, PGLAZYFREE); + __count_vm_events(PGLAZYFREE, nr_pages); + __count_memcg_events(lruvec_memcg(lruvec), PGLAZYFREE, nr_pages); update_page_reclaim_stat(lruvec, 1, 0); } } -- 2.26.2.645.ge9eca65c58-goog