Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp5503281ybg; Tue, 22 Oct 2019 04:21:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqyTVRNXg7scWBj04MyTDd4LJo5Y2wdzr1z6K2Kf/2dCDbv8a3tvwP6HbLTPWOMUh/1A0xGz X-Received: by 2002:a05:6402:1519:: with SMTP id f25mr30844243edw.65.1571743265945; Tue, 22 Oct 2019 04:21:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571743265; cv=none; d=google.com; s=arc-20160816; b=XVZxEjKvvj1a1uynNPMkQg9xKBR5H1xP5TDMkWus4nivCudv6JNhD65U1B0OhtiYyP ufNqfb+jXmeg9m2FSbtyP0ahFOnDjj+E6hQNhtYfo88mRrGbn19dfWpsM5QvAqv+7S7B jyFKR183zHiw1Na+Q4F20oVccTYMpsRT8CxuQU84I3iJWzNZtDr0cC/Z15VODG0eQKKD JhmTaLDerfj0uiLE2CtWbYXK/fbKG4YKL4C0xHFCtSNrd+QgPYGzN4lz2scHyZ9tiBNu xTW4r76LOOiYbdJguF4NeN32L/hQk3JRiPBGnZYNG6L2qgJcUVhwuPqjJvl3B7E57XcR F6IQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:user-agent:in-reply-to:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=xOdSf1iPdyuIGKQcZDNBRQHCgxJoZC1L79ZeEeYmKrs=; b=FBUdwT56XA1yAfJ82n4gwGOQvGrhZ7UHbI014dvQDodIWsOZokFPAA06l7JdG3lCzp UKh1VVAURz4samXmRaIFaE4hO/83dBTLjoJarLX4oC6gBTXs8lJaQSXDhGyFLwcvx7jD uakQ7vfrWaw84iEJzqpnG9sF5kJB5AQBVg6i1BROw2QZgm/jPvdfMREb3Bgg75WJUX9R nlNAuF8LzN4+QHcWT5HcXnSH69HkYU9DRXlclDe14cCl03T3PnSSmtklZpPJS5NtVmnW FKZtS3YWl1t5xvJ3/kXYn8xa4wOXT95+NXJ+PeN+VZ43k/Cdo0NVKFZ2uLnUX2v5FBmh 3/MQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bhgshpV6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b50si12603023ede.28.2019.10.22.04.20.41; Tue, 22 Oct 2019 04:21:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bhgshpV6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388081AbfJVIBX (ORCPT + 99 others); Tue, 22 Oct 2019 04:01:23 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:36260 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2387692AbfJVIBX (ORCPT ); Tue, 22 Oct 2019 04:01:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571731282; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xOdSf1iPdyuIGKQcZDNBRQHCgxJoZC1L79ZeEeYmKrs=; b=bhgshpV64nlWa6W8LNDnDZzRj0obgtdfescZ5V7ISilYX4eZb7WlB69gj1+Md5ZaXr8WOO B+BcMlprKyJYdjR74g047tal/gKPx8DqYCNP8lw158776WmA1q7NJSmUiRD8rDOMH+URLw MNgiO9e8KOVeSCvpaLvv1t2eE+2GDJo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-78-YufY5vFfNHqRQJ236x3gLg-1; Tue, 22 Oct 2019 04:01:19 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DC3821800D79; Tue, 22 Oct 2019 08:01:17 +0000 (UTC) Received: from krava (unknown [10.43.17.61]) by smtp.corp.redhat.com (Postfix) with SMTP id 43F0E60856; Tue, 22 Oct 2019 08:01:16 +0000 (UTC) Date: Tue, 22 Oct 2019 10:01:15 +0200 From: Jiri Olsa To: Andi Kleen Cc: acme@kernel.org, linux-kernel@vger.kernel.org, jolsa@kernel.org, eranian@google.com, kan.liang@linux.intel.com, peterz@infradead.org, Andi Kleen Subject: Re: [PATCH v2 2/9] perf evsel: Avoid close(-1) Message-ID: <20191022080115.GB28177@krava> References: <20191020175202.32456-1-andi@firstfloor.org> <20191020175202.32456-3-andi@firstfloor.org> MIME-Version: 1.0 In-Reply-To: <20191020175202.32456-3-andi@firstfloor.org> User-Agent: Mutt/1.12.1 (2019-06-15) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: YufY5vFfNHqRQJ236x3gLg-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Oct 20, 2019 at 10:51:55AM -0700, Andi Kleen wrote: > From: Andi Kleen >=20 > In some weak fallback cases close can be called a lot with -1. Check > for this case and avoid calling close then. >=20 > This is mainly to shut up valgrind which complains about this case. >=20 > Signed-off-by: Andi Kleen Acked-by: Jiri Olsa thanks, jirka > --- > tools/perf/lib/evsel.c | 3 ++- > tools/perf/util/evsel.c | 3 ++- > 2 files changed, 4 insertions(+), 2 deletions(-) >=20 > diff --git a/tools/perf/lib/evsel.c b/tools/perf/lib/evsel.c > index a8cb582e2721..5a89857b0381 100644 > --- a/tools/perf/lib/evsel.c > +++ b/tools/perf/lib/evsel.c > @@ -120,7 +120,8 @@ void perf_evsel__close_fd(struct perf_evsel *evsel) > =20 > =09for (cpu =3D 0; cpu < xyarray__max_x(evsel->fd); cpu++) > =09=09for (thread =3D 0; thread < xyarray__max_y(evsel->fd); ++thread) { > -=09=09=09close(FD(evsel, cpu, thread)); > +=09=09=09if (FD(evsel, cpu, thread) >=3D 0) > +=09=09=09=09close(FD(evsel, cpu, thread)); > =09=09=09FD(evsel, cpu, thread) =3D -1; > =09=09} > } > diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c > index d831038b55f2..d4451846af93 100644 > --- a/tools/perf/util/evsel.c > +++ b/tools/perf/util/evsel.c > @@ -1815,7 +1815,8 @@ int evsel__open(struct evsel *evsel, struct perf_cp= u_map *cpus, > =09old_errno =3D errno; > =09do { > =09=09while (--thread >=3D 0) { > -=09=09=09close(FD(evsel, cpu, thread)); > +=09=09=09if (FD(evsel, cpu, thread) >=3D 0) > +=09=09=09=09close(FD(evsel, cpu, thread)); > =09=09=09FD(evsel, cpu, thread) =3D -1; > =09=09} > =09=09thread =3D nthreads; > --=20 > 2.21.0 >=20