Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp802538pxj; Thu, 27 May 2021 11:59:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxpSjbifolbHsLducEVbZJHM5I8qI8MmHpAQo8RNaqtWkhyorcHafIs0PTcFs0dRu43O+S8 X-Received: by 2002:a17:906:17d8:: with SMTP id u24mr5597772eje.106.1622141995895; Thu, 27 May 2021 11:59:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622141995; cv=none; d=google.com; s=arc-20160816; b=ZfZXXOyh935bFjlUmc1xQwEr7hbpIgMGYArYFfX2B8qm1V7Los8l2kfuKTB6SHiAlb 99/FdNqDQnMaS3EZ+KKidj2GLLzKwp3R05QGNLv43tFF3euc1tzNXoUkKjqJDh5lef+D PtTJg6YEPwvvK3f5AuAMBlXv8r8g5r4MHAIgnrqoUbuOdMDWWERNc1yxzoPOtc+4shxM yrqqaAHpGit7gTHGhFKiFG+qj0RXBGTI0HZ1n7HqpnuIs34xEsnCmDTPSQfM+kKPGBYv x+R+ZZ22sjNe9nLXV1xv3yOMmSbuXltu5wdIhEGdup77FsXycoigxUzLlanHjXXHQmyK scmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=N0gYEi1stKxt/cXYd703mAsj9B01B+OKcQXgo1H4PUc=; b=eVDE1ndzdk7hjhCbK93bgk1KSE7DL436zZFAO246H0SVI+wsoI3e6cjoawgnjCvcd3 +BPum6HmiWQb7i8RqeNL8nD9QuMKgD4qHdNxFgxdHnh32z1DNU42XzXWTpi2QaZISM8O x5eqUwbVtQggjT0ZHARO/fXUMHS2obrIL0b68xOgo9U3S+DCw6Sj77GWMLi6MC/7aicJ 8Ifj4tpullrns/YePEDk+LOjAoiTFqna5odp2sf+2cwLB+z5V6b0OMi51Lj6O4u9CifA PQUAdUh7v5kBJC0tyJgQHi2L1f5sSvmAB+6HXU9j0sLRv91AdBnHGz1hBGbmDrwIXg5H 2nZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YcZEIuGk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gt26si3072374ejb.41.2021.05.27.11.59.32; Thu, 27 May 2021 11:59:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YcZEIuGk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236433AbhE0Qzd (ORCPT + 99 others); Thu, 27 May 2021 12:55:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:46938 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234803AbhE0Qzc (ORCPT ); Thu, 27 May 2021 12:55:32 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DA9E360D07; Thu, 27 May 2021 16:53:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1622134439; bh=WbSLA+038O8hNxB4Xk789D8nn0kmf/W99WEIFpZZzuU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=YcZEIuGkYUOmWATo6Q6MX11VLsD3QZ9Uwt9z6BX5WadB8Q1FCRUHz0mVzN81zFxki 9JGmsCOH885+nB04Suy9fwsuxIu2D85aDBEEw+OFJwVsA/7ISHZo6hnzOXfWsP8cMz 9IdHpL3dKF3oAAPhVcYkLLl8bH2/ZDQt5szs9z9Dg6R1/k+cDYNWSrYvPhwIOKExi5 H1GNZjot/WBu9tiAWY0IQXXUY+EaYhpJglj6l/2nX+1pzoGZw4GqntTDSAJyw48VDw TlxwgorqMEa4QT0nu05PwawrAEGQFXzr+fuYFANjmgI4AtWQV0LEtKv8vQ56OWE8i9 DzYZmTby+F6zA== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id A81844011C; Thu, 27 May 2021 13:53:56 -0300 (-03) Date: Thu, 27 May 2021 13:53:56 -0300 From: Arnaldo Carvalho de Melo To: Denys Zagorui Cc: jolsa@redhat.com, linux-kernel@vger.kernel.org, peterz@infradead.org, mingo@redhat.com, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, namhyung@kernel.org Subject: Re: [PATCH v8 2/3] perf tests: avoid storing an absolute path in perf binary Message-ID: References: <20210524111514.65713-1-dzagorui@cisco.com> <20210524111514.65713-2-dzagorui@cisco.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20210524111514.65713-2-dzagorui@cisco.com> X-Url: http://acmel.wordpress.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Mon, May 24, 2021 at 04:15:13AM -0700, Denys Zagorui escreveu: > python binding test uses PYTHONPATH definition to find python/perf.so > library. This definition is an absolute path that makes perf binary > unreproducible. This path can be found during runtime execution. > > Signed-off-by: Denys Zagorui > --- > tools/perf/tests/Build | 2 +- > tools/perf/tests/python-use.c | 25 ++++++++++++++++++++++--- > 2 files changed, 23 insertions(+), 4 deletions(-) > > diff --git a/tools/perf/tests/Build b/tools/perf/tests/Build > index 650aec19d490..a20098dcdbc4 100644 > --- a/tools/perf/tests/Build > +++ b/tools/perf/tests/Build > @@ -98,5 +98,5 @@ perf-$(CONFIG_DWARF_UNWIND) += dwarf-unwind.o > endif > > CFLAGS_attr.o += -DBINDIR="BUILD_STR($(bindir_SQ))" -DPYTHON="BUILD_STR($(PYTHON_WORD))" > -CFLAGS_python-use.o += -DPYTHONPATH="BUILD_STR($(OUTPUT)python)" -DPYTHON="BUILD_STR($(PYTHON_WORD))" > +CFLAGS_python-use.o += -DPYTHON="BUILD_STR($(PYTHON_WORD))" > CFLAGS_dwarf-unwind.o += -fno-optimize-sibling-calls > diff --git a/tools/perf/tests/python-use.c b/tools/perf/tests/python-use.c > index 98c6d474aa6f..32af71300aa3 100644 > --- a/tools/perf/tests/python-use.c > +++ b/tools/perf/tests/python-use.c > @@ -8,18 +8,37 @@ > #include > #include "tests.h" > #include "util/debug.h" > +#include "util/util.h" > +#include > +#include > +#include > > int test__python_use(struct test *test __maybe_unused, int subtest __maybe_unused) > { > char *cmd; > - int ret; > + int ret = -1; > + char *exec_path; > + char buf[PATH_MAX]; > + char *pythonpath; > + struct stat sb; > + > + perf_exe(buf, PATH_MAX); > + exec_path = dirname(buf); > + > + if (asprintf(&pythonpath, "%s/python", exec_path) < 0) > + return ret; > + > + if (stat(pythonpath, &sb) || !S_ISDIR(sb.st_mode)) > + pythonpath[0] = 0; > > if (asprintf(&cmd, "echo \"import sys ; sys.path.append('%s'); import perf\" | %s %s", > - PYTHONPATH, PYTHON, verbose > 0 ? "" : "2> /dev/null") < 0) > - return -1; > + pythonpath, PYTHON, verbose > 0 ? "" : "2> /dev/null") < 0) > + goto out; > > pr_debug("python usage test: \"%s\"\n", cmd); > ret = system(cmd) ? -1 : 0; > free(cmd); > +out: > + free(pythonpath); > return ret; > } > -- > 2.26.2.Cisco > I noticed this is failing the test, nothing is being appended. I'll investigate later. Can you try to reproduce this? I build perf with: alias m='perf stat -e cycles:u,instructions:u make -k CORESIGHT=1 BUILD_BPF_SKEL=1 PYTHON=python3 O=/tmp/build/perf -C tools/perf install-bin && perf test python' ⬢[acme@toolbox perf]$ perf test python 19: 'import perf' in python : FAILED! ⬢[acme@toolbox perf]$ perf test -v python Couldn't bump rlimit(MEMLOCK), failures may take place when creating BPF maps, etc 19: 'import perf' in python : --- start --- test child forked, pid 347155 python usage test: "echo "import sys ; sys.path.append(''); import perf" | '/usr/bin/python3' " Traceback (most recent call last): File "", line 1, in ModuleNotFoundError: No module named 'perf' test child finished with -1 ---- end ---- 'import perf' in python: FAILED! ⬢[acme@toolbox perf]$ git log --oneline -3 60cdbfd0586e53c3 (HEAD) perf tests: Avoid storing an absolute path in perf binary f7fc0d1c915a74ff perf inject: Do not inject BUILD_ID record if MMAP2 has it 0c3f7b38d72b9247 perf inject: Call dso__put() even if dso->hit is set ⬢[acme@toolbox perf]$