From patchwork Thu Oct 31 23:36:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Kleen X-Patchwork-Id: 2004914 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=YCBYJUHF; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XfgQ12RQHz1xwc for ; Fri, 1 Nov 2024 10:37:13 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 707E23858401 for ; Thu, 31 Oct 2024 23:37:11 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) by sourceware.org (Postfix) with ESMTPS id E8FBD3858D26; Thu, 31 Oct 2024 23:36:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E8FBD3858D26 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Authentication-Results: sourceware.org; spf=none smtp.mailfrom=linux.intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E8FBD3858D26 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=198.175.65.19 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730417812; cv=none; b=wGEsoBSZDBUDyJnOXkwh4Xoo4z7X2BLUVho5JqabcRRkP3AuGs4B4F6sUG1z4t4HXoywCdqHO4jzrJmmxOGMXKYSILKgIyzXUSxvCjuwJFPC1OKyoXtU/jwN3AneL+aelGhyTyrTm6BLckOiIav9kYB9EcyyL3axgwB+iNTTPMc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730417812; c=relaxed/simple; bh=Cr4KZ7/7WFFG0p8JwTdOV3C3xZ38J2GmQpfiUfeTom8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=c9SOJLy/nm7L+pKj/emQ+mXczM5S7qoi5rY5izma2eJ7XRfnZc3uiOBdJXQIyKmKBjfCCxL0Xaq9PcNASiGjHnHXzxHipxd9mhqSERvzJbY8fNi+hVCbO2TyeGGb95II1aTd0UCN/A69sSXbOZ14Pb3Cvhxeihilmlf5T+bJryA= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1730417806; x=1761953806; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=Cr4KZ7/7WFFG0p8JwTdOV3C3xZ38J2GmQpfiUfeTom8=; b=YCBYJUHFOcVTFJBbalb2VWLfglwP/FkutlZwR/8O15iTu0Fv4sCaRac9 r+ooj6xOGqstg2g6toKBJzkfJnyxhIPs9hkensgTP0OcChXNQ7OL3esqv mz2bbvEblBx5cYW5RUN0JWpjz/9czMgdwts3W/wghH9kPC6cWcxK9w8a+ 8u0ak+fCsRP1s6t8fodDNp7WZgV8Vh/YpI88Qw9y23qj4nuW15bNrKzea u5x8O+OJ+Rij+/y04xVtbIazcoQKQwCy1lM2LbMc5jRTlcLkHMa3O8lFc kWuLe2FvUUMAkwMcllZXw1DGPEKikmdN6h7Ia8mNQhARxCyNLFneoCjxA g==; X-CSE-ConnectionGUID: 0QmckowpSgCSOXh9Y9A97w== X-CSE-MsgGUID: ikQR0UZPTiW8VDUG2OgxUA== X-IronPort-AV: E=McAfee;i="6700,10204,11222"; a="30041384" X-IronPort-AV: E=Sophos;i="6.11,199,1725346800"; d="scan'208";a="30041384" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Oct 2024 16:36:45 -0700 X-CSE-ConnectionGUID: xJJHRgFZTZ+/oI6ETpg2pA== X-CSE-MsgGUID: w2kdbat+QmuV1jVJmkx9AA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,248,1725346800"; d="scan'208";a="82894918" Received: from tassilo.jf.intel.com ([10.54.38.190]) by fmviesa009-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Oct 2024 16:36:44 -0700 From: Andi Kleen To: gcc-patches@gcc.gnu.org Cc: erozen@microsoft.com, Andi Kleen Subject: [PATCH] Update gcc-auto-profile / gen_autofdo_event.py Date: Thu, 31 Oct 2024 16:36:39 -0700 Message-ID: <20241031233639.3672032-1-ak@linux.intel.com> X-Mailer: git-send-email 2.46.2 MIME-Version: 1.0 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org From: Andi Kleen - Fix warnings with newer python versions about bad escapes by making all the python string raw. - Add a fallback for using the builtin perf event list if the CPU model number is unknown. - Regenerate the shipped gcc-auto-profile with the changes. contrib/ChangeLog: * gen_autofdo_event.py: Convert strings to raw. Add fallback to using builtin perf event list. gcc/ChangeLog: * config/i386/gcc-auto-profile: Regenerate. --- contrib/gen_autofdo_event.py | 36 ++++++++++++++++++-------------- gcc/config/i386/gcc-auto-profile | 21 ++++++++++++------- 2 files changed, 34 insertions(+), 23 deletions(-) diff --git a/contrib/gen_autofdo_event.py b/contrib/gen_autofdo_event.py index 4c201943b5c7..4e58a5320fff 100755 --- a/contrib/gen_autofdo_event.py +++ b/contrib/gen_autofdo_event.py @@ -112,7 +112,7 @@ for j in u: u.close() if args.script: - print('''#!/bin/sh + print(r'''#!/bin/sh # Profile workload for gcc profile feedback (autofdo) using Linux perf. # Auto generated. To regenerate for new CPUs run # contrib/gen_autofdo_event.py --script --all in gcc source @@ -152,22 +152,26 @@ case `grep -E -q "^cpu family\s*: 6" /proc/cpuinfo && for event, mod in eventmap.items(): for m in mod[:-1]: print("model*:\ %s|\\" % m) - print('model*:\ %s) E="%s$FLAGS" ;;' % (mod[-1], event)) - print('''*) + print(r'model*:\ %s) E="%s$FLAGS" ;;' % (mod[-1], event)) + print(r'''*) + if perf list br_inst_retired | grep -q br_inst_retired.near_taken ; then + E=br_inst_retired.near_taken:p + else echo >&2 "Unknown CPU. Run contrib/gen_autofdo_event.py --all --script to update script." - exit 1 ;;''') - print("esac") - print("set -x") - print('if ! perf record -e $E -b "$@" ; then') - print(' # PEBS may not actually be working even if the processor supports it') - print(' # (e.g., in a virtual machine). Trying to run without /p.') - print(' set +x') - print(' echo >&2 "Retrying without /p."') - print(' E="$(echo "${E}" | sed -e \'s/\/p/\//\')"') - print(' set -x') - print(' exec perf record -e $E -b "$@"') - print(' set +x') - print('fi') + exit 1 + fi ;;''') + print(r"esac") + print(r"set -x") + print(r'if ! perf record -e $E -b "$@" ; then') + print(r' # PEBS may not actually be working even if the processor supports it') + print(r' # (e.g., in a virtual machine). Trying to run without /p.') + print(r' set +x') + print(r' echo >&2 "Retrying without /p."') + print(r' E="$(echo "${E}" | sed -e \'s/\/p/\//\ -e s/:p//)"') + print(r' set -x') + print(r' exec perf record -e $E -b "$@"') + print(r' set +x') + print(r'fi') if cpufound == 0 and not args.all: sys.exit('CPU %s not found' % cpu) diff --git a/gcc/config/i386/gcc-auto-profile b/gcc/config/i386/gcc-auto-profile index 04f7d35dcc51..528b34e42400 100755 --- a/gcc/config/i386/gcc-auto-profile +++ b/gcc/config/i386/gcc-auto-profile @@ -82,17 +82,24 @@ model*:\ 126|\ model*:\ 167|\ model*:\ 140|\ model*:\ 141|\ -model*:\ 143|\ -model*:\ 207|\ model*:\ 106|\ -model*:\ 108) E="cpu/event=0xc4,umask=0x20/p$FLAGS" ;; +model*:\ 108|\ +model*:\ 173|\ +model*:\ 174) E="cpu/event=0xc4,umask=0x20/$FLAGS" ;; model*:\ 134|\ model*:\ 150|\ -model*:\ 156|\ -model*:\ 190) E="cpu/event=0xc4,umask=0xfe/p$FLAGS" ;; +model*:\ 156) E="cpu/event=0xc4,umask=0xfe/p$FLAGS" ;; +model*:\ 143|\ +model*:\ 207) E="cpu/event=0xc4,umask=0x20/p$FLAGS" ;; +model*:\ 190) E="cpu/event=0xc4,umask=0xc0/$FLAGS" ;; +model*:\ 190) E="cpu/event=0xc4,umask=0xfe/$FLAGS" ;; *) + if perf list br_inst_retired | grep -q br_inst_retired.near_taken ; then + E=br_inst_retired.near_taken:p + else echo >&2 "Unknown CPU. Run contrib/gen_autofdo_event.py --all --script to update script." - exit 1 ;; + exit 1 + fi ;; esac set -x if ! perf record -e $E -b "$@" ; then @@ -100,7 +107,7 @@ if ! perf record -e $E -b "$@" ; then # (e.g., in a virtual machine). Trying to run without /p. set +x echo >&2 "Retrying without /p." - E="$(echo "${E}" | sed -e 's/\/p/\//')" + E="$(echo "${E}" | sed -e \'s/\/p/\//\ -e s/:p//)" set -x exec perf record -e $E -b "$@" set +x