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 AE534C433EF for ; Mon, 7 Feb 2022 18:00:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 358F96B0074; Mon, 7 Feb 2022 13:00:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2E1876B0075; Mon, 7 Feb 2022 13:00:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 135316B0078; Mon, 7 Feb 2022 13:00:52 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0050.hostedemail.com [216.40.44.50]) by kanga.kvack.org (Postfix) with ESMTP id F17676B0074 for ; Mon, 7 Feb 2022 13:00:51 -0500 (EST) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id B0BAF97315 for ; Mon, 7 Feb 2022 18:00:51 +0000 (UTC) X-FDA: 79116749502.13.A1E1107 Received: from mail-il1-f180.google.com (mail-il1-f180.google.com [209.85.166.180]) by imf23.hostedemail.com (Postfix) with ESMTP id 3AB8C140011 for ; Mon, 7 Feb 2022 18:00:51 +0000 (UTC) Received: by mail-il1-f180.google.com with SMTP id b5so5411224ile.11 for ; Mon, 07 Feb 2022 10:00:50 -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=vAANZBXJ7sjdB6HJV8mdniD7XEYfQ+ohI4e6g+PRzDA=; b=b7VXqSPJlQilf3OxElTU4ZKiyU9lyp6MPPkBwL3AuC4i1t/FNz/Jjp2J9pCnwsQOFh wn7MaGFgiAcqPlfAb36NLajsoEJnZh84xdKMn9a02dgLgIbq7gCaCCARpHEsjDz/hDRZ 1NtPXaqXy+5I3ONdQazd/+U2JAUCjLtZfNiE8= 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=vAANZBXJ7sjdB6HJV8mdniD7XEYfQ+ohI4e6g+PRzDA=; b=G243cyVwslHs9dlD2p2HfkvHm5vl33C9+SH6p/KOEWXouPDckHMn0YIC6evVFctFvi 6RMJQfjZD7A3yXU829r+5h5LC2H+aCJ7R3lq+UErqY3PoEUg+JoE7tjEoDjD/+5+MG1d /5UV5GZW674qT1Q/X8X6BEq+ybxcveXolVgVi4zf1spsp5zWcMRxB9K3qscwr4gIsCCJ rUd0MU415IJX7fc6n6RKYSo/Vji66e2GZL08C0x0WPTnJg0qcSwCFUIIt2mKqbIM4ilo RONlHEXYEyCvFytReuaRc+Tc/KUHNhcbHYVr5uCqfovG2mE2aUTjXTP/9G5waKlMiVLu QpMg== X-Gm-Message-State: AOAM5302I36i8mO9QDhGfL769NOOpdO9HclTyQ89hI+Hq814yIa54uXc WAWd4LOWH5boIgx4XB9VmSWwsQ== X-Google-Smtp-Source: ABdhPJzzZ8fAEThnEB/DDtjGPIUo2pX8YgD7f8HKp+5pMhwDSyFZtkChRxqswvlKelWm0bvvUUeRmQ== X-Received: by 2002:a92:c5b1:: with SMTP id r17mr350950ilt.320.1644256850455; Mon, 07 Feb 2022 10:00:50 -0800 (PST) Received: from [192.168.1.128] ([71.205.29.0]) by smtp.gmail.com with ESMTPSA id c13sm2055151ilq.50.2022.02.07.10.00.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 07 Feb 2022 10:00:50 -0800 (PST) Subject: Re: [PATCH 0/3] selftests: Remove duplicate CPUID wrappers To: Reinette Chatre , shuah@kernel.org, linux-kselftest@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Dave Hansen , Ram Pai , Sandipan Das , Florian Weimer , "Desnes A. Nunes do Rosario" , Ingo Molnar , Thiago Jung Bauermann , Michael Ellerman , Michal Suchanek , linux-mm@kvack.org, "Chang S . Bae" , Borislav Petkov , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, Andy Lutomirski , Shuah Khan References: <81df8c0e-fde6-f3b8-f988-b539f193635b@linuxfoundation.org> From: Shuah Khan Message-ID: <3787aee3-064a-dce7-1ab1-0dcabd56a100@linuxfoundation.org> Date: Mon, 7 Feb 2022 11:00:49 -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-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 3AB8C140011 X-Rspam-User: nil Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=linuxfoundation.org header.s=google header.b=b7VXqSPJ; dmarc=pass (policy=none) header.from=linuxfoundation.org; spf=pass (imf23.hostedemail.com: domain of skhan@linuxfoundation.org designates 209.85.166.180 as permitted sender) smtp.mailfrom=skhan@linuxfoundation.org X-Stat-Signature: 73b9bh19poo55ntojadpg4psu9rou89y X-HE-Tag: 1644256851-792912 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/4/22 5:11 PM, Reinette Chatre wrote: > Hi Shuah, >=20 > On 2/4/2022 3:39 PM, Shuah Khan wrote: >> On 2/4/22 12:17 PM, Reinette Chatre wrote: >>> A few tests that require running CPUID do so with a private >>> implementation of a wrapper for CPUID. This duplication of >>> the CPUID wrapper should be avoided but having one is also >>> unnecessary because of the existence of a macro that can >>> be used instead. >>> >>> This series replaces private CPUID wrappers with calls >>> to the __cpuid_count() macro from cpuid.h as made available >>> by gcc and clang/llvm. >>> >>> Cc: Dave Hansen >>> Cc: Ram Pai >>> Cc: Sandipan Das >>> Cc: Florian Weimer >>> Cc: "Desnes A. Nunes do Rosario" >>> Cc: Ingo Molnar >>> Cc: Thiago Jung Bauermann >>> Cc: Michael Ellerman >>> Cc: Michal Suchanek >>> Cc: linux-mm@kvack.org >>> Cc: Chang S. Bae >>> Cc: Borislav Petkov >>> Cc: Thomas Gleixner >>> Cc: Ingo Molnar >>> Cc: "H. Peter Anvin" >>> Cc: x86@kernel.org >>> Cc: Andy Lutomirski >>> >>> Reinette Chatre (3): >>> =C2=A0=C2=A0 selftests/vm/pkeys: Use existing __cpuid_count() macro >>> =C2=A0=C2=A0 selftests/x86/amx: Use existing __cpuid_count() macro >>> =C2=A0=C2=A0 selftests/x86/corrupt_xstate_header: Use existing __cpu= id_count() >>> =C2=A0=C2=A0=C2=A0=C2=A0 macro >>> >>> =C2=A0 tools/testing/selftests/vm/pkey-x86.h=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 | 22 +++--------------- >>> =C2=A0 tools/testing/selftests/x86/amx.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 | 23 +++++-------------- >>> =C2=A0 .../selftests/x86/corrupt_xstate_header.c=C2=A0=C2=A0=C2=A0=C2= =A0 | 17 ++------------ >>> =C2=A0 3 files changed, 11 insertions(+), 51 deletions(-) >>> >> >> I am all for this cleanup. However, I am not finding __cpuid_count() >> marco on my system with gcc: >> >> gcc --version >> gcc (Ubuntu 11.2.0-7ubuntu2) 11.2.0 >> >> My concern is regression on older gcc versions. >=20 > Please see this message from our earlier thread where you were able > to find it on your system: > https://lore.kernel.org/linux-kselftest/63293c72-55ca-9446-35eb-74aff4c= 8ba5d@linuxfoundation.org/ >=20 Right. After I sent off the response, I was thinking we discussed this before. Thanks for the refresh. > As mentioned in that thread, on my system it arrived via user space's > libgcc-dev package. This does not seem to be the first time including > files from this source - I did a quick check and from what I can tell > existing kselftest includes like stdarg.h, stdbool.h, stdatomic.h, > unwind.h, x86intrin.h ... arrive via libgcc-dev. >=20 This will work fine on newer versions of gcc/clang. However this could fail when mainline kselftest is used on stable releases on test rings and so on, especially if they have older versions of gcc/clang. We will have to find a solution for this. Instead of deleting the local define, let's keep it under ifndef __cpuid_count /usr/lib/gcc/x86_64-linux-gnu/11/include/cpuid.h #define __cpuid_count(level, count, a, b, c, d) \ __asm__ __volatile__ ("cpuid\n\t" = \ : "=3Da" (a), "=3Db" (b), "=3Dc" (c), "=3Dd" (d)= \ : "0" (level), "2" (count)) thanks, -- Shuah