Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1543816ybk; Thu, 14 May 2020 11:31:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwWmTDgyf/wf6AdoZFKpYPNeplGmuVeacHXa/6Kko4/JUXGMoCrzgO46uj974sxlG4/+a7i X-Received: by 2002:a50:e711:: with SMTP id a17mr5228259edn.369.1589481116827; Thu, 14 May 2020 11:31:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589481116; cv=none; d=google.com; s=arc-20160816; b=jIEtH0dvKDJhuk6z564jlE6Sdd4gAEQpEFT6pSECwL8BdefIfPOdRTeB85NgGrxrOD vqGxpjAniWvVuleuypgKtN58x3TWW/G8jyGJq7PiAbzsCMYCIKqN72BTh7OfF5pfF3YI ZPZjHmiqXcTXO6C9eIEjVwuay7wqS5dBpcufO5txiAGpfBYyQb/8AuQ7vTnyDdAkX9Lr d1YEGHD3vYXC7Fh1lQKuZ2j20lHADBn3LuWMYV+vXQnV5cQeDj30Jef4VB553MURj9Ek 8j+TGdZ/RQb/KnnP1LPEOXsT3OLR191BEIQeVfwpGVjpoSxMbpv37eQxMtUpfyVAnX+Z Cerg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=it1oMCn8dC/MVjc5q48LqltF3VvVRaM29QWnpwrpMPU=; b=CSggEDmixpHn7qOCvhvTUznL9wVsv8AD7iIdj0kjZNYHGdpTDRiQCMKWxg7KR3jAPR Dd0N1HuNLk3/34cQuQuPtF5Kow3OU4hAI/ELOjlSGlzpeYN64CXUPdtN40c1SSANaNwZ NfE8mpTSRXG7MBs0ZW3DxQatLFPolKoAhnqDh4c0AvlG9ARrLAkY53uf3Zah8YmlB8jq ZAvwMLrYR3exrw6PglWra/OMoFvoqijJ8dgJuNNNi5spXS4oU4n/bjfddljWJJa0SK68 X4CUNMSeRmMAJeKRSZNTiFdbQdQts0YUa5mr7U9c5EEgh4VPojDSw8Og3nCSpOkUmp7T owlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=maNq0y5Y; 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=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bz10si956512ejc.507.2020.05.14.11.31.24; Thu, 14 May 2020 11:31:56 -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=@nvidia.com header.s=n1 header.b=maNq0y5Y; 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=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726667AbgENS3Z (ORCPT + 99 others); Thu, 14 May 2020 14:29:25 -0400 Received: from hqnvemgate24.nvidia.com ([216.228.121.143]:3075 "EHLO hqnvemgate24.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726165AbgENS3Y (ORCPT ); Thu, 14 May 2020 14:29:24 -0400 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate24.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Thu, 14 May 2020 11:27:06 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Thu, 14 May 2020 11:29:24 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Thu, 14 May 2020 11:29:24 -0700 Received: from [10.2.88.73] (172.20.13.39) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 14 May 2020 18:29:23 +0000 Subject: Re: [RFC] mm/vmstat: Add events for THP migration without split To: Anshuman Khandual , CC: Andrew Morton , "Kirill A. Shutemov" , Zi Yan , References: <1589257372-29576-1-git-send-email-anshuman.khandual@arm.com> X-Nvconfidentiality: public From: John Hubbard Message-ID: <8be2c517-ba87-400b-dfbe-461bd6065c2d@nvidia.com> Date: Thu, 14 May 2020 11:29:23 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <1589257372-29576-1-git-send-email-anshuman.khandual@arm.com> X-Originating-IP: [172.20.13.39] X-ClientProxiedBy: HQMAIL107.nvidia.com (172.20.187.13) To HQMAIL107.nvidia.com (172.20.187.13) Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1589480826; bh=it1oMCn8dC/MVjc5q48LqltF3VvVRaM29QWnpwrpMPU=; h=X-PGP-Universal:Subject:To:CC:References:X-Nvconfidentiality:From: Message-ID:Date:User-Agent:MIME-Version:In-Reply-To: X-Originating-IP:X-ClientProxiedBy:Content-Type:Content-Language: Content-Transfer-Encoding; b=maNq0y5YePD1L5K6yg2TWQLsywK0aC25HynSPI6O9f0sjCsx4L2Oa9+Qxa9O3mV4T Ry7b4v8DsqRsYHklDhMI5s3DskEPxObgCgotbGrE4D5gFItHlR4z7V5wTuNiIpHYs+ MJiX03W+gL0YpzRZAhCuiUfizQ57uwiZkCdhkN7cDVmGdWOVHqT7C3bwXf20RSt3BK hsJRYRqizKAMZ1T0tW0dWSNnZmEJMxNp+rnep7U9TQlK33VA8fux0YY83Vu0fQy9Bi uzEX35ZbUcFnpZCnsqDI9QkfeQYhUz81TYveX5hi6o3wbc1Z4MFsRHH4psTiHmeYS6 i18QVPz0x2lew== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-05-11 21:22, Anshuman Khandual wrote: > Add the following new trace events which will help in validating migration > events involving PMD based THP pages. > > 1. THP_PMD_MIGRATION_ENTRY_SET > 2. THP_PMD_MIGRATION_ENTRY_REMOVE > > There are no clear method to confirm whether a THP migration happened with > out involving it's split. These trace events along with PGMIGRATE_SUCCESS > and PGMIGRATE_FAILURE will provide additional insights. After this change, > Hi Anshuman, It's very nice to see this work, and I think that reporting a bit more about THP migration stats is going to make development and performance debugging a lot more efficient (and pleasant). > A single 2M THP (2K base page) when migrated > > 1. Without split > > ................ > pgmigrate_success 1 > pgmigrate_fail 0 > ................ > thp_pmd_migration_entry_set 1 > thp_pmd_migration_entry_remove 1 > ................ > I do think we should decouple the trace event name(s) just a *little* more, from the mechanisms used to migrate THPs. In other words, let's report the number of THP migration successes, and name it accordingly--rather than "set" and "remove", which are pretty low-level and furthermore depend on today's exact code. Maybe Zi Yan's recommended name is exactly right, in fact: THP_PMD_MIGRATION_SUCCESS thanks, -- John Hubbard NVIDIA > 2. With split > > ................ > pgmigrate_success 512 > pgmigrate_fail 0 > ................ > thp_pmd_migration_entry_set 0 > thp_pmd_migration_entry_remove 0 > ................ > > pgmigrate_success as 1 instead of 512, provides a hint for possible THP > migration event. But then it gets mixed with normal page migrations over > time. These additional trace events provide required co-relation. > > Cc: Andrew Morton > Cc: "Kirill A. Shutemov" > Cc: Zi Yan > Cc: linux-mm@kvack.org > Cc: linux-kernel@vger.kernel.org > Signed-off-by: Anshuman Khandual > --- > This is an indirect way for counting PMD migrations without split. Is there > a better method possible ? Just request for comments at the moment. > > include/linux/vm_event_item.h | 4 ++++ > mm/migrate.c | 1 + > mm/rmap.c | 1 + > mm/vmstat.c | 4 ++++ > 4 files changed, 10 insertions(+) > > diff --git a/include/linux/vm_event_item.h b/include/linux/vm_event_item.h > index ffef0f279747..4b25102cf3ad 100644 > --- a/include/linux/vm_event_item.h > +++ b/include/linux/vm_event_item.h > @@ -91,6 +91,10 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT, > THP_ZERO_PAGE_ALLOC_FAILED, > THP_SWPOUT, > THP_SWPOUT_FALLBACK, > +#ifdef CONFIG_ARCH_ENABLE_THP_MIGRATION > + THP_PMD_MIGRATION_ENTRY_SET, > + THP_PMD_MIGRATION_ENTRY_REMOVE, > +#endif > #endif > #ifdef CONFIG_MEMORY_BALLOON > BALLOON_INFLATE, > diff --git a/mm/migrate.c b/mm/migrate.c > index 7160c1556f79..8d50d55cbe97 100644 > --- a/mm/migrate.c > +++ b/mm/migrate.c > @@ -228,6 +228,7 @@ static bool remove_migration_pte(struct page *page, struct vm_area_struct *vma, > if (!pvmw.pte) { > VM_BUG_ON_PAGE(PageHuge(page) || !PageTransCompound(page), page); > remove_migration_pmd(&pvmw, new); > + count_vm_event(THP_PMD_MIGRATION_ENTRY_REMOVE); > continue; > } > #endif > diff --git a/mm/rmap.c b/mm/rmap.c > index f79a206b271a..3c1fe3f45cb5 100644 > --- a/mm/rmap.c > +++ b/mm/rmap.c > @@ -1418,6 +1418,7 @@ static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma, > VM_BUG_ON_PAGE(PageHuge(page) || !PageTransCompound(page), page); > > set_pmd_migration_entry(&pvmw, page); > + count_vm_event(THP_PMD_MIGRATION_ENTRY_SET); > continue; > } > #endif > diff --git a/mm/vmstat.c b/mm/vmstat.c > index 96d21a792b57..a5254b7ee531 100644 > --- a/mm/vmstat.c > +++ b/mm/vmstat.c > @@ -1274,6 +1274,10 @@ const char * const vmstat_text[] = { > "thp_zero_page_alloc_failed", > "thp_swpout", > "thp_swpout_fallback", > +#ifdef CONFIG_ARCH_ENABLE_THP_MIGRATION > + "thp_pmd_migration_entry_set", > + "thp_pmd_migration_entry_remove", > +#endif > #endif > #ifdef CONFIG_MEMORY_BALLOON > "balloon_inflate", >