From patchwork Tue Jan 17 23:16:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minchan Kim X-Patchwork-Id: 13105219 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 81285C38147 for ; Tue, 17 Jan 2023 23:16:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 77AC56B0074; Tue, 17 Jan 2023 18:16:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 703436B0075; Tue, 17 Jan 2023 18:16:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5A54B6B0078; Tue, 17 Jan 2023 18:16:44 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 448DA6B0074 for ; Tue, 17 Jan 2023 18:16:44 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 0EB53140BC0 for ; Tue, 17 Jan 2023 23:16:43 +0000 (UTC) X-FDA: 80365852728.22.E685980 Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) by imf22.hostedemail.com (Postfix) with ESMTP id 49A3AC0003 for ; Tue, 17 Jan 2023 23:16:42 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="pS/gUVrl"; spf=pass (imf22.hostedemail.com: domain of minchan.kim@gmail.com designates 209.85.216.50 as permitted sender) smtp.mailfrom=minchan.kim@gmail.com; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=kernel.org (policy=none) ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673997402; a=rsa-sha256; cv=none; b=yPkEtB12WZ8b610x3tZRC1Ifzvvzu2Qh2CmDdaesraP8uPEJ99tLZDymPtYLmYHs2m0ZVP wh4EIm3frI7xOlyBaIczdjYpWuVv4LYECeN9RSGorrd0N+O1W0VGsL5DAVAoIq9A/TJlwi YNaSQbktPFZ9yYCsWkIHjo8JIdUfg4Q= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="pS/gUVrl"; spf=pass (imf22.hostedemail.com: domain of minchan.kim@gmail.com designates 209.85.216.50 as permitted sender) smtp.mailfrom=minchan.kim@gmail.com; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=kernel.org (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1673997402; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=SMrwqounr0oUuG21W3XQfHvNf7os8CE1mar5f82JgxI=; b=KN/oqBZpLuB11EukzkQIMRlM3jpj35C9tiIfFM3HkYsiuSHG5C7wCo9wIrwxIAadv0xzu7 ZB9IhtjvYFi0pEuQ4DrjsebhkXygKMcFMFEDFGpojCTP3xlhaLl+NfsGDKLDSxmTqzHHWs u84XSE2wvlJ/h613k9sFAc1fUH8MCSE= Received: by mail-pj1-f50.google.com with SMTP id a14-20020a17090a70ce00b00229a2f73c56so468966pjm.3 for ; Tue, 17 Jan 2023 15:16:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=SMrwqounr0oUuG21W3XQfHvNf7os8CE1mar5f82JgxI=; b=pS/gUVrldsYuEvQWJem29eVikSvSY6AeGUnyAPPRx6JDLPalLF60OpyhtfbbhHVVNM blAGDRem/RXiBLYfhuMkVXlzQoEevYfTJApvZpXgxChB0zanFmX4sQTTir8d8RU7VdnS 5etir+xvETOpNvcIV9bzFP2EgZAASyCC2oVNPvv2pyP3VQB+zJ2eOPbHDGk9+TlUNMV+ f01T0BGb5Ozy++CKL4jWy5zgrnLZasNM3iqlSlU8yqlG08r7PqBbBHHQs2LU8plQM83n vdvOozKeSEhUDGgoZk0NuVQgif0pLhdH2EwrlcSLqO2NbFyZr5bBJ4WlwhLAcHJPGLkO cW2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=SMrwqounr0oUuG21W3XQfHvNf7os8CE1mar5f82JgxI=; b=1Gip+CFNvOyOv6ZNL3bzeo/cDgLatY4GpeGf3hW5/4Hfb2DgHnBp4eEPP5e1Ui75Zh gg+cdeYo4MWGBZpZifxG/Z4Kokr4B9MommweKhqzU2uiWEhwd15sqAaCNQB78ICI2fLs 32eG9+KIFxl8UuujAcGRqLWZvvKDXIbXPONgrn4SSYGOSUGrLOUusri9fpFjQE85B0cc jV0GZG2FougT4LZoOrhP2azyyGjT0lGbFp13LF/0p0iQWuMxydw1X1FusScfSyNoPj6t pDCAlPp4WL8OfKyLkrWTDIyYj1ASGJ+Y8DTKR4qr09p1dYcR8OuBHQ6VwKhWsY+yH5sP meig== X-Gm-Message-State: AFqh2kpubH7JyMsSK0AmV/q5PPqRu1wQe6LmMcVcNbs2oNMaLReA7kMW oh+O6vAI3dbjcdWdKPRTseE= X-Google-Smtp-Source: AMrXdXvqtSKvPavOcMP4zOcjlEw09DB95at5PzXmZy3YQqaMHkTZhaqtBL/dDhIgMMCEEiBr3o9T/A== X-Received: by 2002:a05:6a20:4e26:b0:b8:a148:63b5 with SMTP id gk38-20020a056a204e2600b000b8a14863b5mr4792999pzb.3.1673997401048; Tue, 17 Jan 2023 15:16:41 -0800 (PST) Received: from bbox-1.mtv.corp.google.com ([2620:15c:211:201:27ce:97b5:ee13:dbfe]) by smtp.gmail.com with ESMTPSA id c24-20020aa79538000000b0057447bb0ddcsm5180965pfp.49.2023.01.17.15.16.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 15:16:40 -0800 (PST) From: Minchan Kim To: Andrew Morton Cc: Suren Baghdasaryan , Matthew Wilcox , linux-mm , LKML , Michal Hocko , SeongJae Park , Minchan Kim Subject: [PATCH 3/3] mm: add vmstat statistics for madvise_[cold|pageout] Date: Tue, 17 Jan 2023 15:16:32 -0800 Message-Id: <20230117231632.2734737-3-minchan@kernel.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20230117231632.2734737-1-minchan@kernel.org> References: <20230117231632.2734737-1-minchan@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: 49A3AC0003 X-Rspamd-Server: rspam01 X-Stat-Signature: f7a585jj4zca888hxrwi9n1jbhceu8xf X-HE-Tag: 1673997402-330454 X-HE-Meta: U2FsdGVkX18jANKQfjf6GylTCFPWm0whG0ZLK4SNDpZGrpzcU9EF6A1D1pCDoiFg77i1DNuyX00l83Lye4ciYPeqw1WTwLT6oBRHd9pC6yFJl5uWPc2WdbOZHEyW0TyFVd8zGO4iZ25QN1EVr/BPx/o1G2MSzYfzs4Dpd9afOUXaKiOZltLgB7UyAIDF32RPAAd3/sFqP21haQNZpxBcLoJLTJNMRbYQnKrnnbpnzxm5OjioR80ifB8dYJ3cK4eU31p2p/UzyEuHCG/47nLI9LqLzID5B8kRUgEOphe05a1ocwYSw8VnyOqR9VaLH+UlKAxTKzwKQl/C6vcsGd4/OukS71Xi4NU5XBrDLQ2pQa1DlA0XHR6iwdWzxg0zLYCN54O82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linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: madvise LRU manipulation APIs need to scan address ranges to find present pages at page table and provides advice hints for them. Likewise pg[scan/steal] count on vmstat, madvise_pg[scanned/hinted] shows the proactive reclaim efficiency so this patch addes those two statistics in vmstat. Signed-off-by: Minchan Kim --- include/linux/vm_event_item.h | 2 ++ mm/madvise.c | 19 +++++++++++++++---- mm/vmstat.c | 2 ++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/include/linux/vm_event_item.h b/include/linux/vm_event_item.h index 3518dba1e02f..8b9fb2e151eb 100644 --- a/include/linux/vm_event_item.h +++ b/include/linux/vm_event_item.h @@ -49,6 +49,8 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT, PGSCAN_FILE, PGSTEAL_ANON, PGSTEAL_FILE, + MADVISE_PGSCANNED, + MADVISE_PGHINTED, #ifdef CONFIG_NUMA PGSCAN_ZONE_RECLAIM_FAILED, #endif diff --git a/mm/madvise.c b/mm/madvise.c index a4a03054ab6b..0e58545ff6e9 100644 --- a/mm/madvise.c +++ b/mm/madvise.c @@ -334,6 +334,8 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd, spinlock_t *ptl; struct page *page = NULL; LIST_HEAD(page_list); + unsigned int nr_scanned = 0; + unsigned int nr_hinted = 0; if (fatal_signal_pending(current)) return -EINTR; @@ -343,6 +345,7 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd, pmd_t orig_pmd; unsigned long next = pmd_addr_end(addr, end); + nr_scanned += HPAGE_PMD_NR tlb_change_page_size(tlb, HPAGE_PMD_SIZE); ptl = pmd_trans_huge_lock(pmd, vma); if (!ptl) @@ -396,11 +399,15 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd, list_add(&page->lru, &page_list); } } else - deactivate_page(page); + if (deactivate_page(page)) + nr_hinted += HPAGE_PMD_NR; huge_unlock: spin_unlock(ptl); if (pageout) - paging_out(&page_list); + nr_hinted += paging_out(&page_list); + + count_vm_events(MADVISE_PGSCANNED, nr_scanned); + count_vm_events(MADVISE_PGHINTED, nr_hinted); return 0; } @@ -414,6 +421,7 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd, arch_enter_lazy_mmu_mode(); for (; addr < end; pte++, addr += PAGE_SIZE) { ptent = *pte; + nr_scanned++; if (pte_none(ptent)) continue; @@ -485,14 +493,17 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd, list_add(&page->lru, &page_list); } } else - deactivate_page(page); + if (deactivate_page(page)) + nr_hinted++; } arch_leave_lazy_mmu_mode(); pte_unmap_unlock(orig_pte, ptl); if (pageout) - paging_out(&page_list); + nr_hinted += paging_out(&page_list); cond_resched(); + count_vm_events(MADVISE_PGSCANNED, nr_scanned); + count_vm_events(MADVISE_PGHINTED, nr_hinted); return 0; } diff --git a/mm/vmstat.c b/mm/vmstat.c index b2371d745e00..0139feade854 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -1280,6 +1280,8 @@ const char * const vmstat_text[] = { "pgscan_file", "pgsteal_anon", "pgsteal_file", + "madvise_pgscanned", + "madvise_pghinted", #ifdef CONFIG_NUMA "zone_reclaim_failed",