From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8DE44C433FE for ; Wed, 23 Nov 2022 13:45:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238017AbiKWNpY (ORCPT ); Wed, 23 Nov 2022 08:45:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237948AbiKWNpG (ORCPT ); Wed, 23 Nov 2022 08:45:06 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CED6DD5396; Wed, 23 Nov 2022 05:33:47 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5A9EB61CC9; Wed, 23 Nov 2022 13:33:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8BB36C433D6; Wed, 23 Nov 2022 13:33:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669210409; bh=o5a/1D++1Mz35bMC46Wx3lUgNniBZ5e14zrk6/8nSLA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=LOl7Q4n4cEl48OuaUSA+Bgl0IZTxdonu6mUt/hJRzmYjzYC5vh9Aa2N3ZXMxrUR/6 48m+AKkRf2fO3muoslzGBzQUQBe2NxHZTgy+eHvpR+Au3yxQ2og13EtKoKPsTf8Wyg nwUHbaUgC/sR+weWCCWEzz0ML39ZkwLmTORo98UEeKQs4s5cDDnvO08asxGGog6Ydz eBDgNoiqpV5wqgiRgNG0A/FUmd9zgySBEdzk5Ud2AYI+S2ARX0UaCBcxxK1s3revGZ GA8gUTbE00d7ixoql1pdSKm1bZNED2WAN8pFIiz5zQiXrapqcLWoVFoJCyl8cfqdRy 8bN3OuFhi7ziQ== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id E73C84034E; Wed, 23 Nov 2022 10:33:26 -0300 (-03) Date: Wed, 23 Nov 2022 10:33:26 -0300 From: Arnaldo Carvalho de Melo To: Ian Rogers Cc: Christophe Leroy , "Naveen N. Rao" , Ravi Bangoria , "linux-perf-users@vger.kernel.org" , Disha Goel , "linuxppc-dev@lists.ozlabs.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] perf test: Skip watchpoint tests if no watchpoints available Message-ID: References: <20221121102747.208289-1-naveen.n.rao@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Url: http://acmel.wordpress.com Precedence: bulk List-ID: X-Mailing-List: linux-perf-users@vger.kernel.org Em Tue, Nov 22, 2022 at 12:57:05PM -0800, Ian Rogers escreveu: > On Tue, Nov 22, 2022 at 11:19 AM Christophe Leroy > wrote: > > > > > > > > Le 21/11/2022 à 11:27, Naveen N. Rao a écrit : > > > On IBM Power9, perf watchpoint tests fail since no hardware breakpoints > > > are available. Detect this by checking the error returned by > > > perf_event_open() and skip the tests in that case. > > > > > > Reported-by: Disha Goel > > > Signed-off-by: Naveen N. Rao > > > --- > > > tools/perf/tests/wp.c | 12 +++++++----- > > > 1 file changed, 7 insertions(+), 5 deletions(-) > > > > > > diff --git a/tools/perf/tests/wp.c b/tools/perf/tests/wp.c > > > index 56455da30341b4..cc8719609b19ea 100644 > > > --- a/tools/perf/tests/wp.c > > > +++ b/tools/perf/tests/wp.c > > > @@ -59,8 +59,10 @@ static int __event(int wp_type, void *wp_addr, unsigned long wp_len) > > > get__perf_event_attr(&attr, wp_type, wp_addr, wp_len); > > > fd = sys_perf_event_open(&attr, 0, -1, -1, > > > perf_event_open_cloexec_flag()); > > > - if (fd < 0) > > > + if (fd < 0) { > > > + fd = -errno; > > > pr_debug("failed opening event %x\n", attr.bp_type); > > > + } > > > > Do you really need that ? > > > > Can't you directly check errno in the caller ? > > errno is very easily clobbered and not clearly set on success - ie, > it'd be better not to do that. > > Acked-by: Ian Rogers Thanks, applied. - Arnaldo