From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com [IPv6:2a00:1450:4864:20::234]) by sourceware.org (Postfix) with ESMTPS id 0102A3858D20 for ; Thu, 6 Jul 2023 06:23:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0102A3858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lj1-x234.google.com with SMTP id 38308e7fff4ca-2b700e85950so3663291fa.3 for ; Wed, 05 Jul 2023 23:23:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688624620; x=1691216620; 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=vvq+SO+ThKeypq292eHtLu+fTZZ86GQ6zIdaFklH/5A=; b=d7+uDmVG1HyOYRaVU09t4vhmB7ZJVfhmwoi19NEKIALJAOqd+S8/JCOpqUOW2+pCXM H0l08/C+ALUQob5miKM9qAauyND0mlA8dMIrRadbFvHEGkWebpHibqhxz+FIF8l86EJg S2tz4JwZ0Oo6ZBWItOINRWO+OyNXZ43h680vlRZEHmLfrY1/MA5tJxRaHSUkWnL8xlvH 9Ua+C7Lz5/s9EuA1uJnyAHmqGr3v5AHLArFx7r0fel46xk2h06nAv7u+WTqsKdOzU93O 1jC4hopZoojzjoAX9E2xWtMMOD8AcxPFMpLoC8nu5DAwU7uRiOWdrJtqkDYWZjE5XkS7 9DnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688624620; x=1691216620; 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=vvq+SO+ThKeypq292eHtLu+fTZZ86GQ6zIdaFklH/5A=; b=QK76e1tbjx0HKlcTKYhexfjc+64D0iqiYabm+83EYmh/SErrHCL5Fu9FIxD4RrGd5q D+8uRNEzihA5mcIFdxpNR02BfS7xuVtPUAYn2YmNmn1NY7qsAGWV9Kg8jqCDeWVgJ07L EAVZ83WgLSgHmtJbqv/6q1U1xd47M3IB9SAAUnDP8DspcLu4VbmzXaWQzVkF9SZg2qQj x3m7U5vWZnHGZTGSH5YBLyrVyKCy5KC3bBrmF/nHzay7+0HbudlEi9sCmwA5fM7hMiGy gM2SiX5xxqm7y5AXggkWNYo/zVBO9ZMoi5VhpYsW4dYKDifx2KH4IOtYpzj0Pq3tff1e qwJA== X-Gm-Message-State: ABy/qLYDtKDRLlEzC55PU+XKRtlIUBRqh5oNjIKLu+gUVT+FXzAE+iy2 ek3fQQliQzIe1IG95MoDaUe0NyfAbUeQEoc4pQU= X-Google-Smtp-Source: APBJJlHyCfiuKfsgChjeQ1gBmN8zRfUHBhg9VNKkkHf5wXKQTJzPMg6txR6kIsyH9Fhgm86mMCiFyfCW7n+ZjIJEaEg= X-Received: by 2002:a2e:99c8:0:b0:2b6:d48a:5dc3 with SMTP id l8-20020a2e99c8000000b002b6d48a5dc3mr540229ljj.39.1688624620025; Wed, 05 Jul 2023 23:23:40 -0700 (PDT) MIME-Version: 1.0 References: <87v8f51g0h.fsf@gentoo.org> In-Reply-To: From: Richard Biener Date: Thu, 6 Jul 2023 08:23:28 +0200 Message-ID: Subject: Re: [EXTERNAL] Re: [PATCH] Collect both user and kernel events for autofdo tests and autoprofiledbootstrap To: Eugene Rozenfeld Cc: Sam James , "gcc-patches@gcc.gnu.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Wed, Jul 5, 2023 at 11:15=E2=80=AFPM Eugene Rozenfeld wrote: > > There is no warning and perf /uk succeeds when kptr_restrict is set to 1 = and perf_event_paranoid set to 2. However, create_gcov may fail since it wo= n't be able to understand kernel addresses and it requires at least 95% of = events to be successfully mapped. OK, so I guess the patch is OK then given it can improve the situation in the right circumstances and doesn't hurt otherwise. Thanks, Richard. > If I set both kptr_restrict and perf_event_paranoid to 1, then I do get w= arnings from perf (but it still succeeds and exits with a 0 code). And, of = course create_gcov will also fail to map some events since it won't underst= and kernel addresses. > > WARNING: Kernel address maps (/proc/{kallsyms,modules}) are restricted, > check /proc/sys/kernel/kptr_restrict and /proc/sys/kernel/perf_event_para= noid. > > Samples in kernel functions may not be resolved if a suitable vmlinux > file is not found in the buildid cache or in the vmlinux path. > > Samples in kernel modules won't be resolved at all. > > If some relocation was applied (e.g. kexec) symbols may be misresolved > even with a suitable vmlinux or kallsyms file. > > Couldn't record kernel reference relocation symbol > Symbol resolution may be skewed if relocation was used (e.g. kexec). > Check /proc/kallsyms permission or run as root. > [ perf record: Woken up 2 times to write data ] > [ perf record: Captured and wrote 0.037 MB /home/erozen/gcc1_objdir/gcc/t= estsuite/gcc/indir-call-prof.perf.data (86 samples) ] > > Eugene > > -----Original Message----- > From: Richard Biener > Sent: Monday, July 3, 2023 12:47 AM > To: Eugene Rozenfeld > Cc: Sam James ; gcc-patches@gcc.gnu.org > Subject: Re: [EXTERNAL] Re: [PATCH] Collect both user and kernel events f= or autofdo tests and autoprofiledbootstrap > > On Sat, Jul 1, 2023 at 12:05=E2=80=AFAM Eugene Rozenfeld wrote: > > > > I also set /proc/sys/kernel/perf_event_paranoid to 1 instead of the def= ault 2. > > Does the perf attempt fail when the privileges are not adjusted and you s= pecify --all? I see it adds /uk as flags, when I do > > > perf record -e instructions//uk ./a.out > > it doesn't complain in any way with > > > cat /proc/sys/kernel/kptr_restrict > 1 > > cat /proc/sys/kernel/perf_event_paranoid > 2 > > so in case the 'kernel' side is simply ignored when profiling there isn't= permitted/possible then I guess the patch is OK? > > Can you confirm? > > Thanks, > Richard. > > > -----Original Message----- > > From: Gcc-patches > > On Behalf Of > > Eugene Rozenfeld via Gcc-patches > > Sent: Friday, June 30, 2023 2:44 PM > > To: Sam James ; Richard Biener > > > > Cc: gcc-patches@gcc.gnu.org > > Subject: RE: [EXTERNAL] Re: [PATCH] Collect both user and kernel > > events for autofdo tests and autoprofiledbootstrap > > > > I don't run this with elevated privileges but I set /proc/sys/kernel/kp= tr_restrict to 0. Setting that does require elevated privileges. > > > > If that's not acceptable, the only fix I can think of is to make that e= vent mapping threshold percentage a parameter to create_gcov and pass somet= hing low enough. 80% instead of the current threshold of 95% should work, a= lthough it's a bit fragile. > > > > Eugene > > > > -----Original Message----- > > From: Sam James > > Sent: Friday, June 30, 2023 1:59 AM > > To: Richard Biener > > Cc: Eugene Rozenfeld ; > > gcc-patches@gcc.gnu.org > > Subject: [EXTERNAL] Re: [PATCH] Collect both user and kernel events > > for autofdo tests and autoprofiledbootstrap > > > > [You don't often get email from sam@gentoo.org. Learn why this is > > important at https://aka.ms/LearnAboutSenderIdentification ] > > > > Richard Biener via Gcc-patches writes: > > > > > On Fri, Jun 30, 2023 at 7:28=E2=80=AFAM Eugene Rozenfeld via Gcc-patc= hes > > > wrote: > > >> > > >> When we collect just user events for autofdo with lbr we get some > > >> events where branch sources are kernel addresses and branch targets > > >> are user addresses. Without kernel MMAP events create_gcov can't > > >> make sense of kernel addresses. Currently create_gcov fails if it > > >> can't map at least 95% of events. We sometimes get below this thresh= old with just user events. The change is to collect both user events and ke= rnel events. > > > > > > Does this require elevated privileges? Can we instead "fix" create_g= cov here? > > > > Right, requiring privileges for this is going to be a no-go for a lot o= f builders. In a distro context, for example, it means we can't consider au= tofdo at all.