Pull in patch to avoid division-by-0.

This commit is contained in:
William Cohen 2018-11-02 14:51:31 -04:00
parent aae2d4600f
commit f46477a5c6
2 changed files with 49 additions and 1 deletions

43
papi-divzero.patch Normal file
View File

@ -0,0 +1,43 @@
commit 7a6ae407b62615d3ffa9b0d2ac17771b7fc63056
Author: Vince Weaver <vince@deater.net>
Date: Thu Sep 27 23:47:58 2018 -0400
perf_event: avoid floating point exception if running is 0
The perf_event interface isn't supposed to return 0 for running, but
it happens occasionally. So be sure not to divide by zero if this
happens. This makes the rdpmc code match the generic perf code in this
case.
This is in response to bitbucket issue #52
diff --git a/src/components/perf_event/perf_event.c b/src/components/perf_event/perf_event.c
index 7fd753ed..82b7d398 100644
--- a/src/components/perf_event/perf_event.c
+++ b/src/components/perf_event/perf_event.c
@@ -1099,14 +1099,23 @@ _pe_rdpmc_read( hwd_context_t *ctx, hwd_control_state_t *ctl,
count = mmap_read_self(pe_ctl->events[i].mmap_buf,
&enabled,&running);
- /* TODO: error checking? */
+ /* TODO: more error checking? */
/* Handle multiplexing case */
- if (enabled!=running) {
+ if (enabled == running) {
+ /* no adjustment needed */
+ }
+ else if (enabled && running) {
adjusted = (enabled * 128LL) / running;
adjusted = adjusted * count;
adjusted = adjusted / 128LL;
count = adjusted;
+ } else {
+ /* This should not happen, but we have had it reported */
+ SUBDBG("perf_event kernel bug(?) count, enabled, "
+ "running: %lld, %lld, %lld\n",
+ papi_pe_buffer[0],enabled,running);
+
}
pe_ctl->counts[i] = count;

View File

@ -8,13 +8,14 @@
Summary: Performance Application Programming Interface
Name: papi
Version: 5.6.0
Release: 7%{?dist}
Release: 8%{?dist}
License: BSD
Group: Development/System
Requires: papi-libs = %{version}-%{release}
URL: http://icl.cs.utk.edu/papi/
Source0: http://icl.cs.utk.edu/projects/papi/downloads/%{name}-%{version}.tar.gz
Patch1: papi-ldflags.patch
Patch2: papi-divzero.patch
BuildRequires: autoconf
BuildRequires: doxygen
BuildRequires: ncurses-devel
@ -77,6 +78,7 @@ the PAPI user-space libraries and interfaces.
%prep
%setup -q
%patch1 -p1 -b .ldflags
%patch2 -p1 -b .divzero
%build
%if %{without bundled_libpfm}
@ -159,6 +161,9 @@ chrpath --delete $RPM_BUILD_ROOT%{_libdir}/*.so*
%{_libdir}/*.a
%changelog
* Fri Nov 2 2018 Fedora Release Engineering <releng@fedoraproject.org> - 5.6.0-8
- Pull in patch to avoid division-by-0.
* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 5.6.0-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild