From patchwork Mon Jan 9 07:22:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yin Fengwei X-Patchwork-Id: 13093094 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 B54B7C54EBD for ; Mon, 9 Jan 2023 07:19:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4F7588E0006; Mon, 9 Jan 2023 02:19:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4804C8E0001; Mon, 9 Jan 2023 02:19:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 286658E0006; Mon, 9 Jan 2023 02:19:42 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 124058E0001 for ; Mon, 9 Jan 2023 02:19:42 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id E475B402AB for ; Mon, 9 Jan 2023 07:19:41 +0000 (UTC) X-FDA: 80334410562.08.CD1C1CE Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by imf21.hostedemail.com (Postfix) with ESMTP id 152D31C0015 for ; Mon, 9 Jan 2023 07:19:39 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=KH8JLmQb; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf21.hostedemail.com: domain of fengwei.yin@intel.com designates 134.134.136.100 as permitted sender) smtp.mailfrom=fengwei.yin@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1673248780; h=from:from: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=izhV+qgtzIRXGhBId2iycUfWj/BcACJStsOaVUDWwxY=; b=k29ctR/bUROOCY4caxY/FEva1U+ngiyerX3iIB8ePU3akbkW0ZWZbkYpqMtO4Z0GwVQIQk 1/gpc2LkcXsYbj5rZodioASp5FRPRKxrBFga4gL0HsCHk2NLezzNxex2uWicTqGmV/4MDt 7o6w6oDZudIsEcVxBEVCKENUkrdBk6s= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=KH8JLmQb; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf21.hostedemail.com: domain of fengwei.yin@intel.com designates 134.134.136.100 as permitted sender) smtp.mailfrom=fengwei.yin@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673248780; a=rsa-sha256; cv=none; b=h2ausRH2yJh46zLuaMwiFUdBSAmx4clxl+hiGl2N3qP1jOUlxJQat6w3T1si2GFLT5Tp+2 8VHuSgpixlAMD5ObHjGRXPMKtnWHICUT0gOl+rEsrrNR1Kb12o3f1zq8f2lMslX8cIzR1F WEsEOO/znqBNIgNh0UP9swCLfekyf4M= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673248780; x=1704784780; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NPYBrBKpCMUBtZBYO+jWTHgO8ZQCDz+oPndyU4c9IhI=; b=KH8JLmQb0UD4QHbZ5C7q+VmiQ77GSgNjBL08zstkbDN9kqYL9GSH9e91 dlpCMyFt26E971pEGeoqKaSlgRLzM6ekpcRLxLNkWSs2kEs0MAA1OQCSR kSihwznN0+LBEU1ZGovr7m0pxdXYMKgqkVtu1fALnouJ4aietz/gs8jSL /eiVG2g2IUsfOErrGswU+VRpRVZZv2JS18APWF2c9dDnbxhIBjLqakCWA ycSmPTwZnIc2VTwL3LapzBPuv0KHyLbvU8ABtz5LZ2kkIS9VOp1YQN0ZC xBZTlOeDfksXKjwkzYMBi4E/xMNMriJZmPEGWSKI1aYsFeW+KdSuqClfE g==; X-IronPort-AV: E=McAfee;i="6500,9779,10584"; a="387260930" X-IronPort-AV: E=Sophos;i="5.96,311,1665471600"; d="scan'208";a="387260930" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jan 2023 23:19:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10584"; a="634112111" X-IronPort-AV: E=Sophos;i="5.96,311,1665471600"; d="scan'208";a="634112111" Received: from fyin-dev.sh.intel.com ([10.239.159.32]) by orsmga006.jf.intel.com with ESMTP; 08 Jan 2023 23:19:24 -0800 From: Yin Fengwei To: linux-mm@kvack.org, akpm@linux-foundation.org, jack@suse.cz, hughd@google.com, kirill.shutemov@linux.intel.com, mhocko@suse.com, ak@linux.intel.com, aarcange@redhat.com, npiggin@gmail.com, mgorman@techsingularity.net, willy@infradead.org, rppt@kernel.org, dave.hansen@intel.com, ying.huang@intel.com, tim.c.chen@intel.com Cc: fengwei.yin@intel.com Subject: [RFC PATCH 3/4] mcpage: add vmstat counters for mcpages Date: Mon, 9 Jan 2023 15:22:31 +0800 Message-Id: <20230109072232.2398464-4-fengwei.yin@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230109072232.2398464-1-fengwei.yin@intel.com> References: <20230109072232.2398464-1-fengwei.yin@intel.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 152D31C0015 X-Stat-Signature: eyoxdo1cxrefkp46du7heqx4u73r7coe X-HE-Tag: 1673248779-336675 X-HE-Meta: U2FsdGVkX1+UEBB+XyDfTUAqhiB3Y+zX2bUdfF9IlQdNQq0Y6dZPASn5EenhkaFkQOyxneaWjldu8u1GzPvvZZilUuJGXxBEbgWen4JAu52sOR5dx/3loIMHeIHMVMr9q769fisPGQk8UbZZ+F+A0/BP9ggspsv0mt50l97A9OZU/ZIkmA8YKrt2WQmiGeyObfIre5OBXaRGl+sEhwpxRkItsY+F4b5elkEDdXuF+bo2HQ6zWTUvRzeAN6ohpitfnK8WFJ9QzC4Jwd8itoIbjZ+13+xS+GeUf9tqYJkkJMVbEYCJRITxlwpmWNIfOr6erxLO6iQz+YdSgFEc6BOV75ukFpVC0Iqtcbt8pzFjtwPf7pJu0RJzlDbP+q9Mwsump2e5KdvAyWjax9oq0HDR/zVhZcj6YjQUx9gSpSk/ObKAqwIe5O021xtbW+4cSuKtwDHTP69A31zDTd03BiAOiGKdnaQ12QPUL+yPce6EkgPniz8VSAlQ7Aub8g45GfpTFNlLZqyYGxnVT+PDFLhclqteuME9sNPtVhufLwYFv3xe8Hb7//5tyot7njY5no9OLHqa1Kttft8tqFQJd1UkeJY6BSmLoyQyHAqLLB9DDPlp2wTUp9W+ei9KJiUcOZJjuDPfdOxDnCI6m80bkhpp2KZJWcqElv2q5YyvkfX3/Mpknt2sVUnm5NZlujzqPiROSuF1m41MlCVnXW0L4Pv0MUG7uOdamj/g0zM/s+pKRsY86grU9cbIB9Fsa210jUJx+MZhnz7CsqHSCppEMppJBJ2lFMmntlCtlK+FdRMjRWoB+/5EsTnVELvMVQnZpXcbz9I7NUBxQQ485a4IT3JUBcMdUi0O0RibotFezUQVkmRDyTbLJhhsPDggAqPXYnmU01/Rq0kAU4xpyALZJNsGdQ== 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: MCPAGE_ANON_FAULT_ALLOC: how many times mcpage is used for anonymous mapping. MCPAGE_ANON_FAULT_FALLBACK: how many times fallback to normal page for anonymous mapping. MCPAGE_ANON_FAULT_CHARGE_FAILED: how many times fallback because of memcg charge failure. MCPAGE_ANON_FAULT_PAGE_TABLE_POPULATED: how many times fallback because page table already populated. MCPAGE_ANON_FAULT_INSTABLE_ADDRESS_SPACE: how many times fallback because of unstable address space. Signed-off-by: Yin Fengwei --- include/linux/vm_event_item.h | 10 ++++++++++ mm/mcpage_memory.c | 6 ++++++ mm/memory.c | 1 + mm/vmstat.c | 7 +++++++ 4 files changed, 24 insertions(+) diff --git a/include/linux/vm_event_item.h b/include/linux/vm_event_item.h index 7f5d1caf5890..9c36bfc4c904 100644 --- a/include/linux/vm_event_item.h +++ b/include/linux/vm_event_item.h @@ -119,6 +119,13 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT, THP_SWPOUT, THP_SWPOUT_FALLBACK, #endif +#ifdef CONFIG_MCPAGE + MCPAGE_ANON_FAULT_ALLOC, + MCPAGE_ANON_FAULT_FALLBACK, + MCPAGE_ANON_FAULT_CHARGE_FAILED, + MCPAGE_ANON_FAULT_PAGE_TABLE_POPULATED, + MCPAGE_ANON_FAULT_INSTABLE_ADDRESS_SPACE, +#endif #ifdef CONFIG_MEMORY_BALLOON BALLOON_INFLATE, BALLOON_DEFLATE, @@ -159,5 +166,8 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT, #define THP_FILE_FALLBACK_CHARGE ({ BUILD_BUG(); 0; }) #define THP_FILE_MAPPED ({ BUILD_BUG(); 0; }) #endif +#ifndef CONFIG_MCPAGE +#define MCPAGE_ANON_FAULT_FALLBACK ({ BUILD_BUG(); 0; }) +#endif #endif /* VM_EVENT_ITEM_H_INCLUDED */ diff --git a/mm/mcpage_memory.c b/mm/mcpage_memory.c index ea4be2e25bce..e208cf818ebf 100644 --- a/mm/mcpage_memory.c +++ b/mm/mcpage_memory.c @@ -55,6 +55,7 @@ static vm_fault_t do_anonymous_mcpage(struct vm_fault *vmf, if (mem_cgroup_charge(page_folio(page), vma->vm_mm, GFP_KERNEL)) { ret = VM_FAULT_OOM; + count_vm_event(MCPAGE_ANON_FAULT_CHARGE_FAILED); goto oom; } @@ -71,12 +72,14 @@ static vm_fault_t do_anonymous_mcpage(struct vm_fault *vmf, if (!pte_none(*vmf->pte)) { ret = VM_FAULT_FALLBACK; update_mmu_cache(vma, addr, vmf->pte); + count_vm_event(MCPAGE_ANON_FAULT_PAGE_TABLE_POPULATED); goto release; } ret = check_stable_address_space(vma->vm_mm); if (ret) { ret = VM_FAULT_FALLBACK; + count_vm_event(MCPAGE_ANON_FAULT_INSTABLE_ADDRESS_SPACE); goto release; } @@ -120,6 +123,9 @@ vm_fault_t do_anonymous_mcpages(struct vm_fault *vmf, unsigned int order) break; } + if (i == nr) + count_vm_event(MCPAGE_ANON_FAULT_ALLOC); + while (i < nr) put_page(&page[i++]); diff --git a/mm/memory.c b/mm/memory.c index fb7f370f6c67..b3655be849ae 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4079,6 +4079,7 @@ static vm_fault_t do_anonymous_page(struct vm_fault *vmf) if (!(ret & VM_FAULT_FALLBACK)) return ret; + count_vm_event(MCPAGE_ANON_FAULT_FALLBACK); ret = 0; } diff --git a/mm/vmstat.c b/mm/vmstat.c index 1ea6a5ce1c41..c40e33dee1b1 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -1367,6 +1367,13 @@ const char * const vmstat_text[] = { "thp_swpout", "thp_swpout_fallback", #endif +#ifdef CONFIG_MCPAGE + "mcpage_anon_fault_alloc", + "mcpage_anon_fault_fallback", + "mcpage_anon_fault_charge_failed", + "mcpage_anon_fault_page_table_populated", + "mcpage_anon_fault_instable_address_space", +#endif #ifdef CONFIG_MEMORY_BALLOON "balloon_inflate", "balloon_deflate",