Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2999332ybk; Mon, 18 May 2020 13:12:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFOSvOdPDO0/GP4wxrS5+kWaiI/JS59Ixwh1hjaqeUusxQXEr1lLvqlq8y9peSJ4GDWyyt X-Received: by 2002:a50:eb0c:: with SMTP id y12mr2521915edp.165.1589832767952; Mon, 18 May 2020 13:12:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589832767; cv=none; d=google.com; s=arc-20160816; b=lPNfLoJDpCPI/FOHLPnTKQmKN6/sSp7ghx+wv3eqRD0+KTeOSquPRLPE2nE5dcoiIa piks+N97b0VGgiOCwNwfjbr04+07mu+4BREXM+BEM87nf+cAEjWnYAEJQ/WUWai3By+W Cx5AS9B9wThlbbqni/xg9FNr3d07D/6S+Pi8d2nmL3ynHWmkEebi3+LaBv/Cofty+MgQ jK+ON6RJX+vWzEYa7DxnhzBPxI3qecAo0YI+uyND5YmzNwn2PSifitDmyBMR7RocXcDV NnQ2wS71TyG2dfmjdoPGSjBFQde6C0Oxqu2MRMhE0pLIHawRC0BAiTBtZGBvSQYT05RH shwg== 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=1z6kses1IYzBnV/KtBizIk4pEwFasA/+isDtngaC6jU=; b=o1Vx4I1kJEqDACYdCj2aIm4tyIUHBbl+mkNDT3eSu5fsQeIk27jI7ZXIS9cJuZpF0n pQZAFCLGkpP7jgq1+tKJYSZdjXpr9oxWFtsS4x2AJ/ok9LiZGxKO8tiwQKYuhbjF1qON trBnpvaaNk7qBL8/QARijAqQLhyCPkEoN2gqtN/YcFjXjGwH8aiCW6pm+I3BcAsUaoPM VUkQx2Yy6GHCL6vCvKSO4XdVOoJBOOGID3H669ObhdPQGvkaO+MzwobnNNbYlO0O0MGC CtQeMCpoyWJBB9nhIvwNOJK4H5AOtSRIqbgspbqlZTlnQ1gBjczcn8UxVl+pmd/UZiXb X8NA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=Ujn3EHPg; 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 pw5si6611666ejb.354.2020.05.18.13.12.23; Mon, 18 May 2020 13:12:47 -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=Ujn3EHPg; 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 S1726388AbgERUKW (ORCPT + 99 others); Mon, 18 May 2020 16:10:22 -0400 Received: from hqnvemgate24.nvidia.com ([216.228.121.143]:14786 "EHLO hqnvemgate24.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726270AbgERUKW (ORCPT ); Mon, 18 May 2020 16:10:22 -0400 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate24.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Mon, 18 May 2020 13:07:59 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Mon, 18 May 2020 13:10:21 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Mon, 18 May 2020 13:10:21 -0700 Received: from [10.2.48.175] (10.124.1.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Mon, 18 May 2020 20:10:21 +0000 Subject: Re: [RFC V2] mm/vmstat: Add events for PMD based THP migration without split To: Anshuman Khandual , CC: Naoya Horiguchi , Zi Yan , Andrew Morton , References: <1589784156-28831-1-git-send-email-anshuman.khandual@arm.com> X-Nvconfidentiality: public From: John Hubbard Message-ID: <67be2597-c019-63c1-b551-d4571a44f1a5@nvidia.com> Date: Mon, 18 May 2020 13:10:20 -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: <1589784156-28831-1-git-send-email-anshuman.khandual@arm.com> X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) 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=1589832479; bh=1z6kses1IYzBnV/KtBizIk4pEwFasA/+isDtngaC6jU=; 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=Ujn3EHPgluHWuBnN1PL0JpJoP/orRUamQbJZFpQrwUwVWnSP4esAhc+l4kGF32gWP Ymca9YAT3fi9tnyUQrliR8I32n+fr6ZiSAl0PbmyrnTAC9C3WR4atGZGufWK4aGUX3 TWa0PqVJ4wMBDhH72CTMJyiVsxOerk2jFxZjE+iVnKaqorbEY/NxGcGTd+OX+7SOnf Wj/n5K0EF4L+3fPPTpH+6xq61lfAnx59EFAZZyeFYVwtOqwSL/BXzsSls5CwKB1saP WoOTWDHC2qG+WWNGYRYbsKtVnM0ubTBL6c+nNy381NyZllVW/fxvxShgddDEtqDs6K Xuxdf8/4IcNAw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-05-17 23:42, Anshuman Khandual wrote: ... > diff --git a/include/linux/vm_event_item.h b/include/linux/vm_event_item.h > index ffef0f279747..23d8f9884c2b 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 Hi Anshuman, These new events look great to me. I have some nits below, plus one lightly controversial suggestion which I'd really like to have someone more experienced weigh in on, which is: How about not being quite so granular on the THP config options, and just guarding these events with the overall CONFIG_TRANSPARENT_HUGEPAGE option, instead of the sub-option CONFIG_ARCH_ENABLE_THP_MIGRATION? I tentatively think it's harmless and not really misleading to have /proc/vmstat showing this in all THP-enabled configurations: thp_pmd_migration_success 0 thp_pmd_migration_failure 0 ...if THP is enabled, and *whether or not* _THP_MIGRATION is enabled. And this simplifies things a bit. Given how the .config options can get, I think simplifying would be nice. However, I'm ready to be corrected on that, if it's a bad idea for other API reasons perhaps. Can anyone please comment? > + THP_PMD_MIGRATION_SUCCESS, > + THP_PMD_MIGRATION_FAILURE, > +#endif > #endif > #ifdef CONFIG_MEMORY_BALLOON > BALLOON_INFLATE, > diff --git a/mm/migrate.c b/mm/migrate.c > index 7160c1556f79..5325700a3e90 100644 > --- a/mm/migrate.c > +++ b/mm/migrate.c > @@ -1170,6 +1170,18 @@ static int __unmap_and_move(struct page *page, struct page *newpage, > #define ICE_noinline > #endif > > +#ifdef CONFIG_ARCH_ENABLE_THP_MIGRATION > +static inline void thp_migration_success(bool success) I think this should be named thp_pmd_migration_success() , since that's what you're really counting. Or, you could name the events THP_MIGRATION_SUCCESS|FAILURE. Either way, just so the function name matches the events it's counting. > +{ > + if (success) > + count_vm_event(THP_PMD_MIGRATION_SUCCESS); > + else > + count_vm_event(THP_PMD_MIGRATION_FAILURE); > +} > +#else > +static inline void thp_migration_success(bool success) { } This whole ifdef clause would disappear if my suggestion above is accepted. However, if not, then I believe the convention for this kind of situation is: static inline void thp_migration_success(bool success) { } > +#endif > + > /* > * Obtain the lock on page, remove all ptes and migrate the page > * to the newly allocated page in newpage. > @@ -1232,6 +1244,8 @@ static ICE_noinline int unmap_and_move(new_page_t get_new_page, > * we want to retry. > */ > if (rc == MIGRATEPAGE_SUCCESS) { > + if (PageTransHuge(newpage)) > + thp_migration_success(true); > put_page(page); > if (reason == MR_MEMORY_FAILURE) { > /* > @@ -1474,6 +1488,7 @@ int migrate_pages(struct list_head *from, new_page_t get_new_page, > unlock_page(page); > if (!rc) { > list_safe_reset_next(page, page2, lru); > + thp_migration_success(false); > goto retry; > } > } > diff --git a/mm/vmstat.c b/mm/vmstat.c > index 96d21a792b57..e258c782fd3a 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_success", > + "thp_pmd_migration_failure", > +#endif > #endif > #ifdef CONFIG_MEMORY_BALLOON > "balloon_inflate", > thanks, -- John Hubbard NVIDIA