Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp4849097rwb; Mon, 8 Aug 2022 08:02:07 -0700 (PDT) X-Google-Smtp-Source: AA6agR6SSC2gUlUjq2Gvn/btyTGyA4HdIwV0/kCwC3q1SSXg+jSYPqyNEGdJm6uFtibRqmN6AGll X-Received: by 2002:a17:907:1df1:b0:730:b058:ef95 with SMTP id og49-20020a1709071df100b00730b058ef95mr13915495ejc.600.1659970927091; Mon, 08 Aug 2022 08:02:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659970927; cv=none; d=google.com; s=arc-20160816; b=NtvXJ1gyOTXovB7Fyg/bzgV7Nv9MWJNiCUB3sYNNIrnVr3ixYrzEosVqz9ygp2jR9B M7+heAGFu0gqq3Gz5DJJZ/1vLt1gDf3JJhJ/ctalCmmMONXwXjcr97z8ZMOaG6aczpKw HspMMFl2pqUhgNYv8wqmgDCUPdz1nZdGsA/Sr6eyw37osd8Lw3P6459ZLYWwt8dBASCi PbmDtA2sL9JoOmC0L58zwKGncwfBM1TT5Ng3lkpNz5p1/VE9oHWQiJaI6GpGDI5Gl8FF mA9GwAPF+OcaJ5ncKcpIs0r1rO4N993urRt+PX5DqpG+cFGF4rz1qZLlQN+sWEk4vh/n +OPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4sjYT3O5jxo/Il99ccyLPXTojDjaSm017zCPZ9M62xc=; b=V+PM2Mhs2RUMLa1nbT27P7iJ4hIAMLleTsEKUhWDOGADYGJM+QgPhKGIFEkwKWO+3F jkOneifEnRI3u1SM39udI5aqSYfKMNVc07w7KX1D7MKwQ153yKIRg6af08aVBEOxmtRs Oa/KUPoRmX2o0fvQOWAgQZ1YuewqAQ67TLeiTJtnH7KbcDd54JSuxr+7o+y7GvRGIZj+ 1+SnZhLr5PPJc8YHUB6tj2YO5pTR4sDrjqULwMAoFMbwumK+e1ZOY3Z6ntCnEz/mNB81 TzeubaixNaqYhs7TptdqMZtBttCsFtbkNico5aXzsHRbVcVIlRrYS41mAM/kaLuZUN2M pVcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=G64yTYy2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hz4-20020a1709072ce400b007308b785be6si10016017ejc.823.2022.08.08.08.01.41; Mon, 08 Aug 2022 08:02:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=G64yTYy2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243680AbiHHO6D (ORCPT + 99 others); Mon, 8 Aug 2022 10:58:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243491AbiHHO5i (ORCPT ); Mon, 8 Aug 2022 10:57:38 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E47C12AFB for ; Mon, 8 Aug 2022 07:57:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1659970658; x=1691506658; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZZZmTi+uFgSNOrvmXUlZxD/TTF+6bac/va5jAJ+uc90=; b=G64yTYy21LHIDNCfx+gwPiYL4fH29r2I1AnFaNGob5hReZPjYPbSzVNZ oJCl5dIGVXLdG3znuIm4UFqjDQdAijAe5anj8XEEWzKsfLEZYiQCCBQxE f/El11b4FcsqkCmmhzn8Dll0u8DThPQA2Zi0z2l3qnbC5TRHHgkwc9sJG u2bMa06up4HXr/8inGP94F3yS4uR4xP7x5AFIYV8R49MgtQ6cPt6OW/FF MB6Bp3osRoGm9Ne0Y6BEVrPve7U/zGEDXQUP1enDnb1ukaPwhN61KbTEP AoYtc4pdHJzM6LaRm1sFb6xTNQjurslb18Ql+9qXWaCLvkHy8SprQv7/t A==; X-IronPort-AV: E=McAfee;i="6400,9594,10433"; a="270996892" X-IronPort-AV: E=Sophos;i="5.93,222,1654585200"; d="scan'208";a="270996892" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Aug 2022 07:57:38 -0700 X-IronPort-AV: E=Sophos;i="5.93,222,1654585200"; d="scan'208";a="663980513" Received: from ziqianlu-desk2.sh.intel.com ([10.238.2.76]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Aug 2022 07:57:36 -0700 From: Aaron Lu To: Dave Hansen , Rick Edgecombe Cc: Song Liu , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH 3/4] x86/mm/cpa: add merge event counter Date: Mon, 8 Aug 2022 22:56:48 +0800 Message-Id: <20220808145649.2261258-4-aaron.lu@intel.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220808145649.2261258-1-aaron.lu@intel.com> References: <20220808145649.2261258-1-aaron.lu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Like split event counter, this patch add counter for merge event. Signed-off-by: Aaron Lu --- arch/x86/mm/pat/set_memory.c | 19 +++++++++++++++++++ include/linux/vm_event_item.h | 2 ++ mm/vmstat.c | 2 ++ 3 files changed, 23 insertions(+) diff --git a/arch/x86/mm/pat/set_memory.c b/arch/x86/mm/pat/set_memory.c index fea2c70ff37f..1be9aab42c79 100644 --- a/arch/x86/mm/pat/set_memory.c +++ b/arch/x86/mm/pat/set_memory.c @@ -105,6 +105,23 @@ static void split_page_count(int level) direct_pages_count[level - 1] += PTRS_PER_PTE; } +static void merge_page_count(int level) +{ + if (direct_pages_count[level] < PTRS_PER_PTE) { + WARN_ON_ONCE(1); + return; + } + + direct_pages_count[level] -= PTRS_PER_PTE; + if (system_state == SYSTEM_RUNNING) { + if (level == PG_LEVEL_4K) + count_vm_event(DIRECT_MAP_LEVEL1_MERGE); + else if (level == PG_LEVEL_2M) + count_vm_event(DIRECT_MAP_LEVEL2_MERGE); + } + direct_pages_count[level + 1]++; +} + void arch_report_meminfo(struct seq_file *m) { seq_printf(m, "DirectMap4k: %8lu kB\n", @@ -875,6 +892,8 @@ static void merge_splitted_mapping(struct page *pgt, int level) __ClearPageSplitpgt(pgt); __free_page(pgt); + + merge_page_count(level); } static pgprot_t pgprot_clear_protnone_bits(pgprot_t prot) diff --git a/include/linux/vm_event_item.h b/include/linux/vm_event_item.h index 404024486fa5..00a9a435af49 100644 --- a/include/linux/vm_event_item.h +++ b/include/linux/vm_event_item.h @@ -143,6 +143,8 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT, #ifdef CONFIG_X86 DIRECT_MAP_LEVEL2_SPLIT, DIRECT_MAP_LEVEL3_SPLIT, + DIRECT_MAP_LEVEL1_MERGE, + DIRECT_MAP_LEVEL2_MERGE, #endif NR_VM_EVENT_ITEMS }; diff --git a/mm/vmstat.c b/mm/vmstat.c index 373d2730fcf2..1a4287a4d614 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -1403,6 +1403,8 @@ const char * const vmstat_text[] = { #ifdef CONFIG_X86 "direct_map_level2_splits", "direct_map_level3_splits", + "direct_map_level1_merges", + "direct_map_level2_merges", #endif #endif /* CONFIG_VM_EVENT_COUNTERS || CONFIG_MEMCG */ }; -- 2.37.1