From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F3121C4167B for ; Mon, 27 Nov 2023 14:54:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233606AbjK0OyZ (ORCPT ); Mon, 27 Nov 2023 09:54:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233485AbjK0OyX (ORCPT ); Mon, 27 Nov 2023 09:54:23 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0AD8C99 for ; Mon, 27 Nov 2023 06:54:30 -0800 (PST) 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 5F1AC2F4; Mon, 27 Nov 2023 06:55:17 -0800 (PST) Received: from [10.57.73.191] (unknown [10.57.73.191]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B814D3F6C4; Mon, 27 Nov 2023 06:54:26 -0800 (PST) Message-ID: <28bc0263-c297-4392-b70a-df8214ca1a67@arm.com> Date: Mon, 27 Nov 2023 14:54:25 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RESEND PATCH v7 10/10] selftests/mm/cow: Add tests for anonymous small-sized THP Content-Language: en-GB To: David Hildenbrand , Andrew Morton , Matthew Wilcox , Yin Fengwei , Yu Zhao , Catalin Marinas , Anshuman Khandual , Yang Shi , "Huang, Ying" , Zi Yan , Luis Chamberlain , Itaru Kitayama , "Kirill A. Shutemov" , John Hubbard , David Rientjes , Vlastimil Babka , Hugh Dickins , Kefeng Wang Cc: linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20231122162950.3854897-1-ryan.roberts@arm.com> <20231122162950.3854897-11-ryan.roberts@arm.com> <8dd0f52c-d261-4541-930f-bd4e5921be5b@arm.com> <13a2ce75-b1c0-4930-8911-36ded0b428a7@redhat.com> From: Ryan Roberts In-Reply-To: <13a2ce75-b1c0-4930-8911-36ded0b428a7@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 27/11/2023 14:50, David Hildenbrand wrote: > On 27.11.23 15:02, Ryan Roberts wrote: >> On 22/11/2023 16:29, Ryan Roberts wrote: >>> Add tests similar to the existing PMD-sized THP tests, but which operate >>> on memory backed by (PTE-mapped) small-sized THP. This reuses all the >>> existing infrastructure. If the test suite detects that small-sized THP >>> is not supported by the kernel, the new tests are skipped. >>> >>> Signed-off-by: Ryan Roberts >>> --- >>>   tools/testing/selftests/mm/cow.c | 71 +++++++++++++++++++++++++++++++- >>>   1 file changed, 70 insertions(+), 1 deletion(-) >>> >>> diff --git a/tools/testing/selftests/mm/cow.c b/tools/testing/selftests/mm/cow.c >>> index d03c453cfd5c..3efc395c7077 100644 >>> --- a/tools/testing/selftests/mm/cow.c >>> +++ b/tools/testing/selftests/mm/cow.c >>> @@ -29,15 +29,49 @@ >>>   #include "../../../../mm/gup_test.h" >>>   #include "../kselftest.h" >>>   #include "vm_util.h" >>> +#include "thp_settings.h" >>> >>>   static size_t pagesize; >>>   static int pagemap_fd; >>>   static size_t pmdsize; >>> +static int nr_thpsmallsizes; >>> +static size_t thpsmallsizes[20]; >> >> Off the back of some comments David made againt the previous patch [1], I'm >> proposing to rework this a bit so that ALL thp sizes are stored in this array, >> not just the non-PMD-sized sizes. This makes the changes overall a bit smaller >> and easier to understand, I think... >> >>>   static int nr_hugetlbsizes; >>>   static size_t hugetlbsizes[10]; >>>   static int gup_fd; >>>   static bool has_huge_zeropage; >>> >>> +static int sz2ord(size_t size) >>> +{ >>> +    return __builtin_ctzll(size / pagesize); >>> +} >>> + >>> +static int detect_smallthp_sizes(size_t sizes[], int max) >> >> This changes to detect_thp_sizes() and deposits all sizes in sizes[] > > Just what I wanted to propose :) Makes it simpler by removing the "small" > terminology and just detecting thp sizes. Great! All done and queued up for the next version. Just waiting for some feedback on the 2 crucial patches in this series (3 & 4) :)