From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-il1-f171.google.com (mail-il1-f171.google.com [209.85.166.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B8C3B2CA9 for ; Mon, 21 Oct 2024 22:43:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729550618; cv=none; b=HcVbCOGau2AGMBfXbOliIP9CiC87DeO7I4JZRwaNKZ5GzZcOFIxty6jvgqAqFclgRKo98TnopXDMAQ2AoYgQ9Al2GEHMgEApMaVHiavtz4qKePH53ENUDEYAbUCz6imdKGYoMz5U2IvwaZFvWxlLrZVyjwOSXcnBOMWciVrQp/Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729550618; c=relaxed/simple; bh=18SuxrItI+6f+tfrvR4g2u78bJrgXnBh0EqpwvVjrEg=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=P90cXZ3/XsxxpAGIVztAnsnW9kE5LpwhovxHaHk4bbopJM2IkdBY20TG8hFbLYHCC9eXKdhoGBTPq5QkaQmw+jHVua4x2Jop8cNmEtteEzBgALhGBSgK3FkgMHfj0/qPcSNJuuNNZglRCaHCNyIXv6quaPbfp9miAVY8FXQhYmg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=UWncrZaY; arc=none smtp.client-ip=209.85.166.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="UWncrZaY" Received: by mail-il1-f171.google.com with SMTP id e9e14a558f8ab-3a3bd5a273bso43855ab.1 for ; Mon, 21 Oct 2024 15:43:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729550615; x=1730155415; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=yovHp8/4KQS/SjRw8rzJ2RWtyZhJZCAGgSQbJZaDAus=; b=UWncrZaY9hUbvqNviMND55QvslQ7k3erHzT24fSS4U6U+PyeCjgO+fLTHuZR6Kb0JI pxBLjBuNKYeg+an90FewLvDzGSf4AlgE2kh5DmPp+VBYtyBUBDBnh2ZTkzn2gH84/MCG VELzUbJOBjcJiZwzj7Fa6CI+cJxccUcc9AlsEOFaLaSf4PFIV5mw4N9EkoiQzvpQlwj9 0OpRdCKJzH2RdPecKe5A0Z2xqTDaBGNLJlxQwqh/60xO40+40RXy75l+oxDoGEhcAtL3 +G1jzQlIEWUMOlj+hlJj31Qp5E7LGzzzF+GSO/sklNnTB+BFrC6zGKcBxdTdfIMjRIc6 I0UA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729550615; x=1730155415; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yovHp8/4KQS/SjRw8rzJ2RWtyZhJZCAGgSQbJZaDAus=; b=EyudJ1pge6K5oAFU4AdUapPES0a3hcORQCPB/lB04Q544r+hFg7nYi4A3l+6lAhuOF gqlWlzvPROh6xOYL+9Fk6ptzfeeIteqmmXF82kmH11Sh+gjL5Z/9Vuy5zTz1lqmUVMDD wCMGt+aTcQNy8eFq2bVHM89OMgdkTs5IXY2Afv47tZxESUSOzpo87Px8tFYil4NntwgV cMQaDK3TP0cN1Ui8JxwjoMBn0MYw8jkM5r0bL7KXIEgPWNKCSJBtnATusWxm3GC6KdSw G7DLum422EWNXK+9BG/7X5+LQtoe9Jao1/uAmPjljm0+A+hAHRVUZxrfR4rsRCb5B9PG MguA== X-Forwarded-Encrypted: i=1; AJvYcCUnrRWBGsbEbRPeHgNWR0dEPCYGApO2uKbcAgI7SaFTEFNV+NpwNj9p6Qgs1vK4K2IkgWYFXiTveNc=@vger.kernel.org X-Gm-Message-State: AOJu0Yw//SM2t9TJdEP3i/TAs4lRSh+DW2t+lgxNd63lUbl8qwM6On8g KxC7Bhc/YrBeoj/pOTuZB2rJ7JwtvRv9xrB5kTwrKNTNcsGpJvSzQQx8pwy+/UMEXHVQ5m2WnBw gyDMUyYmjTMle+p2tbBLM7lTXzX3FPHdUSMXH X-Google-Smtp-Source: AGHT+IH0HVg3fvyt1+QDr1YQLUpP3z4mO+u5A4ersGEMt75VHmDTieIO3qGEubKhoWD+zxsaZ/P7FpluFK6JQL6j+ro= X-Received: by 2002:a05:6e02:148d:b0:3a2:6d54:33f1 with SMTP id e9e14a558f8ab-3a4cc972f72mr1555125ab.16.1729550614610; Mon, 21 Oct 2024 15:43:34 -0700 (PDT) Precedence: bulk X-Mailing-List: workflows@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20241014213342.1480681-1-xur@google.com> <20241014213342.1480681-2-xur@google.com> In-Reply-To: From: Rong Xu Date: Mon, 21 Oct 2024 15:43:22 -0700 Message-ID: Subject: Re: [PATCH v4 1/6] Add AutoFDO support for Clang build To: Masahiro Yamada Cc: Alice Ryhl , Andrew Morton , Arnd Bergmann , Bill Wendling , Borislav Petkov , Breno Leitao , Brian Gerst , Dave Hansen , David Li , Han Shen , Heiko Carstens , "H. Peter Anvin" , Ingo Molnar , Jann Horn , Jonathan Corbet , Josh Poimboeuf , Juergen Gross , Justin Stitt , Kees Cook , "Mike Rapoport (IBM)" , Nathan Chancellor , Nick Desaulniers , Nicolas Schier , "Paul E. McKenney" , Peter Zijlstra , Sami Tolvanen , Thomas Gleixner , Wei Yang , workflows@vger.kernel.org, Miguel Ojeda , Maksim Panchenko , x86@kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Sriraman Tallam , Krzysztof Pszeniczny , Stephane Eranian Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thanks for the detailed suggestions! My comments are inlined below. Best regards, -Rong On Sun, Oct 20, 2024 at 9:33=E2=80=AFAM Masahiro Yamada wrote: > > On Tue, Oct 15, 2024 at 6:33=E2=80=AFAM Rong Xu wrote: > > > > +Customization > > +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > + > > +You can enable or disable AutoFDO build for individual file and direct= ories by > > +adding a line similar to the following to the respective kernel Makefi= le: > > > Perhaps, it might be worth mentioning that kernel space objects are > covered by default. > > Then, people would understand ':=3D y' will be less common than ':=3D n'. > Good point! How about I change to the following: " The default CONFIG_AUTOFDO_CLANG setting covers kernel space objects for AutoFDO builds. One can, however, enable or disable AutoFDO build for individual file and directories by adding a line similar to the following to the respective kernel Makefile ... > > > > > + > > +- For enabling a single file (e.g. foo.o) :: > > + > > + AUTOFDO_PROFILE_foo.o :=3D y > > + > > +- For enabling all files in one directory :: > > + > > + AUTOFDO_PROFILE :=3D y > > + > > +- For disabling one file :: > > + > > + AUTOFDO_PROFILE_foo.o :=3D n > > + > > +- For disabling all files in one directory :: > > + > > + AUTOFDO_PROFILE :=3D n > > + > > > > > > +3) Run the load tests. The '-c' option in perf specifies the sample > > + event period. We suggest using a suitable prime number, like 500009= , > > + for this purpose. > > + > > + - For Intel platforms:: > > + > > + $ perf record -e BR_INST_RETIRED.NEAR_TAKEN:k -a -N -b -c -o -- > > + > > + - For AMD platforms: For Intel platforms: > > > I guess this is a copy-paste mistake. > > > For AMD platforms: For Intel platforms: > > -> > > For AMD platforms: Thanks for catching this! Will fix this. > > > > > > > > + (https://github.com/google/autofdo), version v0.30.1 or later. > > > Please one space instead of two after the comma. > Will fix it. > > > > > > > > diff --git a/scripts/Makefile.autofdo b/scripts/Makefile.autofdo > > new file mode 100644 > > index 000000000000..1c9f224bc221 > > --- /dev/null > > +++ b/scripts/Makefile.autofdo > > @@ -0,0 +1,23 @@ > > +# SPDX-License-Identifier: GPL-2.0 > > + > > +# Enable available and selected Clang AutoFDO features. > > + > > +CFLAGS_AUTOFDO_CLANG :=3D -fdebug-info-for-profiling -mllvm -enable-fs= -discriminator=3Dtrue -mllvm -improved-fs-discriminator=3Dtrue > > + > > +# If CONFIG_DEBUG_INFO is not enabled, set -gmlt option. > > > Meaningless comment. It explains too obvious code. Will remove this line of comment. > > > > +ifndef CONFIG_DEBUG_INFO > > + CFLAGS_AUTOFDO_CLANG +=3D -gmlt > > +endif > > > > > > diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib > > index 01a9f567d5af..e85d6ac31bd9 100644 > > --- a/scripts/Makefile.lib > > +++ b/scripts/Makefile.lib > > @@ -191,6 +191,16 @@ _c_flags +=3D $(if $(patsubst n%,, \ > > -D__KCSAN_INSTRUMENT_BARRIERS__) > > endif > > > > +# > > +# Enable Clang's AutoFDO build flags for a file or directory depending= on > > +# variables AUTOFDO_PROFILE_obj.o and AUTOFDO_PROFILE. > > +# > > > This comment would give the wrong understanding that this flag is opt-in. > > > The comment for KASAN correctly describes that it is enabled by default, > and can be opted out using KASAN_SANITIZE_*. > I can change to use KASAN's expression: " # Enable Clang's AutoFDO build flags for kernel except some files or direct= ories # we don't want to enable (depends on variables AUTOFDO_PROFILE_obj.o and AUTOFDO_PROFILE) " > > > > > -- > Best Regards > > > Masahiro Yamada