Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1800323ybg; Thu, 4 Jun 2020 20:40:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxG96ThIeOtRgMQk9mBvJOl1dl8vW44IOTkpOLEyllfXDWeZyebbnslBGapBl2Sb4mFuxvG X-Received: by 2002:a17:906:3110:: with SMTP id 16mr6574851ejx.307.1591328414084; Thu, 04 Jun 2020 20:40:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591328414; cv=none; d=google.com; s=arc-20160816; b=iauM3AxKEWQdSxYc07R3v6X+XMePkYdBvX7pqQAiYBaxJC4aFIXCvr9jDkiislne6A y8O3r4ZYhBN+En7rQsn8H8z8jBvLVXEDXn+B1fh3021pJ8vMNIv+9h7+XF7XRZhXCxOW AXQ43+KsEnFHxve2AQhWwU7hZm4NK+n8WCBO4895fcg6NbI54hdx2ivsFJPW1lZitI7C wfBfK92QuSbfiv24mw0GDyEyFpWt/NTkOvEDd4gEn8371tFZs+NyBfXrjemIzrW5LVce BjWY/nnRRK5Sjc64f6CTvD5g7DCgqmCQgAlhCXvAyZKJi7AHf2BaPsPOLucS0ZcbtkAJ eTJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=AP+lpue7E4Qm5zXyvERDsgFJxLdMSg1bHHA3u5LNFfQ=; b=OOzjiR7pRowJuoJf5swX5AMJVgKFHX4RlqefrX5qbhjTA4IWZLB95KSplLbvjjsoiz tVkmSRQ7JWznv24NfUmZTVqRKfyoCejo47XlGbWrm4Pszx0UFTnukatAiRzouwhmOo9h IJ1QoK1Hm2F8zRnlvgTRa2ITKtqjPBMp8z5E/r6wXjNgsKcMb+uC4nf97ypt6RO+73Oz 7xCopGTHU01ZJ8OpEYNSu6BlqT+NKsmGYSpmvKBOOolrIQVBLv1Sz0WZkgFatfbNT1KO mrtOH2EHk1KToGSOaIINLtHHs24PJ/gXewpaMOWPigmoJrkiasgMH9FBpSnSvVniLItd cy5A== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o11si2715312edv.414.2020.06.04.20.39.50; Thu, 04 Jun 2020 20:40:14 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728407AbgFEDgF (ORCPT + 99 others); Thu, 4 Jun 2020 23:36:05 -0400 Received: from foss.arm.com ([217.140.110.172]:50340 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728398AbgFEDgF (ORCPT ); Thu, 4 Jun 2020 23:36:05 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 419201FB; Thu, 4 Jun 2020 20:36:04 -0700 (PDT) Received: from [10.163.77.89] (unknown [10.163.77.89]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 291A13F52E; Thu, 4 Jun 2020 20:36:00 -0700 (PDT) Subject: Re: [PATCH V2] mm/vmstat: Add events for THP migration without split To: Zi Yan , Matthew Wilcox Cc: linux-mm@kvack.org, hughd@google.com, daniel.m.jordan@oracle.com, Naoya Horiguchi , John Hubbard , Andrew Morton , linux-kernel@vger.kernel.org References: <1591243245-23052-1-git-send-email-anshuman.khandual@arm.com> <20200604113421.GU19604@bombadil.infradead.org> <20200604163657.GV19604@bombadil.infradead.org> <2735DD7E-0DBF-428B-AAD8-FC6DAAA9CB1E@nvidia.com> From: Anshuman Khandual Message-ID: <9e4acb98-c9fd-a998-03b3-38947cf61bd9@arm.com> Date: Fri, 5 Jun 2020 09:05:01 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <2735DD7E-0DBF-428B-AAD8-FC6DAAA9CB1E@nvidia.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/04/2020 10:19 PM, Zi Yan wrote: > On 4 Jun 2020, at 12:36, Matthew Wilcox wrote: > >> On Thu, Jun 04, 2020 at 09:51:10AM -0400, Zi Yan wrote: >>> On 4 Jun 2020, at 7:34, Matthew Wilcox wrote: >>>> On Thu, Jun 04, 2020 at 09:30:45AM +0530, Anshuman Khandual wrote: >>>>> +Quantifying Migration >>>>> +===================== >>>>> +Following events can be used to quantify page migration. >>>>> + >>>>> +- PGMIGRATE_SUCCESS >>>>> +- PGMIGRATE_FAIL >>>>> +- THP_MIGRATION_SUCCESS >>>>> +- THP_MIGRATION_FAILURE >>>>> + >>>>> +THP_MIGRATION_FAILURE in particular represents an event when a THP could not be >>>>> +migrated as a single entity following an allocation failure and ended up getting >>>>> +split into constituent normal pages before being retried. This event, along with >>>>> +PGMIGRATE_SUCCESS and PGMIGRATE_FAIL will help in quantifying and analyzing THP >>>>> +migration events including both success and failure cases. >>>> >>>> First, I'd suggest running this paragraph through 'fmt'. That way you >>>> don't have to care about line lengths. >>>> >>>> Second, this paragraph doesn't really explain what I need to know to >>>> understand the meaning of these numbers. When Linux attempts to migrate >>>> a THP, one of three things can happen: >>>> >>>> - It is migrated as a single THP >>>> - It is migrated, but had to be split >>>> - Migration fails >>>> >>>> How do I turn these four numbers into an understanding of how often each >>>> of those three situations happen? And why do we need four numbers to >>>> report three situations? >>>> >>>> Or is there something else that can happen? If so, I'd like that explained >>>> here too ;-) >>> >>> PGMIGRATE_SUCCESS and PGMIGRATE_FAIL record a combination of different events, >>> so it is not easy to interpret them. Let me try to explain them. >> >> Thanks! Very helpful explanation. >> >>> 1. migrating only base pages: PGMIGRATE_SUCCESS and PGMIGRATE_FAIL just mean >>> these base pages are migrated and fail to migrate respectively. >>> THP_MIGRATION_SUCCESS and THP_MIGRATION_FAILURE should be 0 in this case. >>> Simple. >>> >>> 2. migrating only THPs: >>> - PGMIGRATE_SUCCESS means THPs that are migrated and base pages >>> (from the split of THPs) that are migrated, >>> >>> - PGMIGRATE_FAIL means THPs that fail to migrate and base pages that fail to migrated. >>> >>> - THP_MIGRATION_SUCCESS means THPs that are migrated. >>> >>> - THP_MIGRATION_FAILURE means THPs that are split. >>> >>> So PGMIGRATE_SUCCESS - THP_MIGRATION_SUCCESS means the number of migrated base pages, >>> which are from the split of THPs. >> >> Are you sure about that? If I split a THP and each of those subpages >> migrates, won't I then see PGMIGRATE_SUCCESS increase by 512? > > That is what I mean. I guess my words did not work. I should have used subpages. > >> >>> When it comes to analyze failed migration, PGMIGRATE_FAIL - THP_MIGRATION_FAILURE >>> means the number of pages that are failed to migrate, but we cannot tell how many >>> are base pages and how many are THPs. >>> >>> 3. migrating base pages and THP: >>> >>> The math should be very similar to the second case, except that >>> a) from PGMIGRATE_SUCCESS - THP_MIGRATION_SUCCESS, we cannot tell how many are pages begin >>> as base pages and how many are pages begin as THPs but become base pages after split; >>> b) from PGMIGRATE_FAIL - THP_MIGRATION_FAILURE, an additional case, >>> base pages that begin as base pages fail to migrate, is mixed into the number and we >>> cannot tell three cases apart. >> >> So why don't we just expose PGMIGRATE_SPLIT? That would be defined as >> the number of times we succeeded in migrating a THP but had to split it >> to succeed. > > It might need extra code to get that number. Currently, the subpages from split > THPs are appended to the end of the original page list, so we might need a separate > page list for these subpages to count PGMIGRATE_SPLIT. Also what if some of the > subpages fail to migrate? Do we increase PGMIGRATE_SPLIT or not? Thanks Zi, for such a detailed explanation. Ideally, we should separate THP migration from base page migration in terms of statistics. PGMIGRATE_SUCCESS and PGMIGRATE_FAIL should continue to track statistics when migration starts with base pages. But for THP, we should track the following events. 1. THP_MIGRATION_SUCCESS - THP migration is successful, without split 2. THP_MIGRATION_FAILURE - THP could neither be migrated, nor be split 3. THP_MIGRATION_SPLIT_SUCCESS - THP got split and all sub pages migrated 4. THP_MIGRATION_SPLIT_FAILURE - THP got split but all sub pages could not be migrated THP_MIGRATION_SPLIT_FAILURE could either increment once for a single THP or number of subpages that did not get migrated after split. As you mentioned, this will need some extra code in the core migration. Nonetheless, if these new events look good, will be happy to make required changes.