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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A1760C433F5 for ; Thu, 10 Feb 2022 15:08:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2F0916B0071; Thu, 10 Feb 2022 10:08:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 29FB96B0074; Thu, 10 Feb 2022 10:08:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 11ABF6B0075; Thu, 10 Feb 2022 10:08:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0207.hostedemail.com [216.40.44.207]) by kanga.kvack.org (Postfix) with ESMTP id 0190F6B0071 for ; Thu, 10 Feb 2022 10:08:44 -0500 (EST) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id AE18B180AD837 for ; Thu, 10 Feb 2022 15:08:44 +0000 (UTC) X-FDA: 79127202168.26.FB08235 Received: from mail-io1-f53.google.com (mail-io1-f53.google.com [209.85.166.53]) by imf30.hostedemail.com (Postfix) with ESMTP id 39A4B80006 for ; Thu, 10 Feb 2022 15:08:44 +0000 (UTC) Received: by mail-io1-f53.google.com with SMTP id 9so7688368iou.2 for ; Thu, 10 Feb 2022 07:08:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=Hp7QvZlzzROYEH5efuLIQi3BV5UCPx6fV4t5giE2B0o=; b=eWMjiv3DIgoG+N319e9OUDVFWv3MK5uB+VgCQTlN12e4mXc7WeyBQcF06s568P/rQA 8uw/HPq2j3DMLGqxHhvR5dALW4Ralubr6nG0CgpSSJFFdsP26xkYzc8qJn6DXXISwztz b4zAguaGaFg1RQXJMmCzyBQIzYb9jhjOKV6js= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Hp7QvZlzzROYEH5efuLIQi3BV5UCPx6fV4t5giE2B0o=; b=epJJ2z0CaKWg4nfxnzq/8UBMSnegS2GwuU/P81+0Obb7SUvObjZ5PF6EXNsHUhbtQ4 EXmtpsvTPiYMQ2EB0XMWTOBQ7zI8lVQYCjKtO8DCZLclKlxk02pouo7LW0EX6ZeTKmvH bKzNU5bD6LnptD9yzXrwYUrV7wXdJ8GfsPH84FBRsMEK1SfHXVIRVkxG04zGgaOpzIDR NvwJwkIKJVTAhixrS+3y0wUNTwJvUE4AFUPiXet3NBI8ysyxXSJryFSVOiIMUW6L3f/3 oZt+IQyO9Nt5ralCfRL769xr7Sr8vgh8RHhjF0BartFEuuEkwCn5gJtcKqdH2ega2bFv 7eHw== X-Gm-Message-State: AOAM532qpgPpDTe7GyI1h/RLZy/in2FeCASdCNsVNWXRRmNteIbZiEnK LD/dsbklw0Two9E7vag7rInZCuwX9hl5DQ== X-Google-Smtp-Source: ABdhPJwYK2ZTmK1mhm9ma5UmVH97aL8K2bUMDn8CEL5pw4CYaefr1l1mSN35amtlhqC5HZ+cT5n2ng== X-Received: by 2002:a05:6602:492:: with SMTP id y18mr3922007iov.95.1644505723189; Thu, 10 Feb 2022 07:08:43 -0800 (PST) Received: from [192.168.1.128] ([71.205.29.0]) by smtp.gmail.com with ESMTPSA id v4sm8269910ilc.21.2022.02.10.07.08.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 10 Feb 2022 07:08:42 -0800 (PST) Subject: Re: [PATCH] selftest/vm: Use correct PAGE_SHIFT value for ppc64 To: Aneesh Kumar K V , linux-mm@kvack.org, akpm@linux-foundation.org Cc: mpe@ellerman.id.au, linuxppc-dev@lists.ozlabs.org, Shuah Khan , Shuah Khan , linux-kselftest@vger.kernel.org References: <20220209154301.42024-1-aneesh.kumar@linux.ibm.com> <84508bb4-9400-f429-e6d2-d8b05a1e8368@linuxfoundation.org> <87zgmz9x7e.fsf@linux.ibm.com> From: Shuah Khan Message-ID: Date: Thu, 10 Feb 2022 08:08:42 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US X-Stat-Signature: sofmzu8qyr4913px77epzw1nahgwoxep X-Rspam-User: Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=linuxfoundation.org header.s=google header.b=eWMjiv3D; dmarc=pass (policy=none) header.from=linuxfoundation.org; spf=pass (imf30.hostedemail.com: domain of skhan@linuxfoundation.org designates 209.85.166.53 as permitted sender) smtp.mailfrom=skhan@linuxfoundation.org X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 39A4B80006 X-HE-Tag: 1644505724-312716 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 2/10/22 8:03 AM, Aneesh Kumar K V wrote: > On 2/10/22 20:09, Shuah Khan wrote: >> On 2/9/22 9:12 PM, Aneesh Kumar K.V wrote: >>> Shuah Khan writes: >>> >>>> On 2/9/22 8:43 AM, Aneesh Kumar K.V wrote: >>>>> Keep it simple by using a #define and limiting hugepage size to 2M. >>>>> This keeps the test simpler instead of dynamically finding the page= size >>>>> and huge page size. >>>>> >>>>> Without this tests are broken w.r.t reading /proc/self/pagemap >>>>> >>>>> =C2=A0=C2=A0=C2=A0=C2=A0if (pread(pagemap_fd, ent, sizeof(ent), >>>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 = (uintptr_t)ptr >> (PAGE_SHIFT - 3)) !=3D sizeof(ent)) >>>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 err(2, "read pagemap"); >>>>> >>>>> Cc: Shuah Khan >>>>> Signed-off-by: Aneesh Kumar K.V >>>>> --- >>>>> =C2=A0=C2=A0 tools/testing/selftests/vm/ksm_tests.c=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 | 8 ++++++++ >>>>> =C2=A0=C2=A0 tools/testing/selftests/vm/transhuge-stress.c | 8 ++++= ++++ >>>>> =C2=A0=C2=A0 2 files changed, 16 insertions(+) >>>>> >>>>> diff --git a/tools/testing/selftests/vm/ksm_tests.c b/tools/testing= /selftests/vm/ksm_tests.c >>>>> index 1436e1a9a3d3..8200328ff018 100644 >>>>> --- a/tools/testing/selftests/vm/ksm_tests.c >>>>> +++ b/tools/testing/selftests/vm/ksm_tests.c >>>>> @@ -22,8 +22,16 @@ >>>>> =C2=A0=C2=A0 #define KSM_MERGE_ACROSS_NODES_DEFAULT true >>>>> =C2=A0=C2=A0 #define MB (1ul << 20) >>>>> +#ifdef __powerpc64__ >>>>> +#define PAGE_SHIFT=C2=A0=C2=A0=C2=A0 16 >>>>> +/* >>>>> + * This will only work with radix 2M hugepage size >>>>> + */ >>>>> +#define HPAGE_SHIFT 21 >>>>> +#else >>>>> =C2=A0=C2=A0 #define PAGE_SHIFT 12 >>>>> =C2=A0=C2=A0 #define HPAGE_SHIFT 21 >>>>> +#endif >>>>> =C2=A0=C2=A0 #define PAGE_SIZE (1 << PAGE_SHIFT) >>>>> =C2=A0=C2=A0 #define HPAGE_SIZE (1 << HPAGE_SHIFT) >>>>> diff --git a/tools/testing/selftests/vm/transhuge-stress.c b/tools/= testing/selftests/vm/transhuge-stress.c >>>>> index 5e4c036f6ad3..f04c8aa4bcf6 100644 >>>>> --- a/tools/testing/selftests/vm/transhuge-stress.c >>>>> +++ b/tools/testing/selftests/vm/transhuge-stress.c >>>>> @@ -16,8 +16,16 @@ >>>>> =C2=A0=C2=A0 #include >>>>> =C2=A0=C2=A0 #include >>>>> +#ifdef __powerpc64__ >>>>> +#define PAGE_SHIFT=C2=A0=C2=A0=C2=A0 16 >>>>> +/* >>>>> + * This will only work with radix 2M hugepage size >>>>> + */ >>>>> +#define HPAGE_SHIFT 21 >>>> >>>> Why not have this is in common code? >>> >>> Can you suggest where I can move that. We also have helper functions >>> like allocate_transhuge() duplicated between tests. I didn't find >>> libutil.a or anything similar supported by the selftets build. >>> >>>> >> >> I noticed that HPAGE_SHIFT is defined in #ifdef __powerpc64__ block >> as well as #else. I am asking is it necessary to be part of both >> blocks. >> >> +#ifdef __powerpc64__ >> +#define PAGE_SHIFT=C2=A0=C2=A0=C2=A0 16 >> +/* >> + * This will only work with radix 2M hugepage size >> + */ >> +#define HPAGE_SHIFT 21=C2=A0 --- this one >> +#else >> =C2=A0=C2=A0 #define PAGE_SHIFT 12 >> =C2=A0=C2=A0 #define HPAGE_SHIFT 21=C2=A0=C2=A0 --- this one >> +#endif >> >=20 >=20 > The reason I did that was to add the comment which is relevant only for= ppc64. ppc64 supports two hugepage sizes, 2M and 16M. The test won't wor= k correctly with 16M hugepage size. We do have other tests in selftest/vm= / with similar restrictions. >=20 >=20 Right. You don't have to duplicate code for the comment. You can add the comment and then clarify in the comment that it is only relevant to ppc64= . This way the comment is clear and we can avoid duplicate code that makes = it hard to maintain in the future. thanks, -- Shuah