Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp37870971rwd; Tue, 11 Jul 2023 22:46:55 -0700 (PDT) X-Google-Smtp-Source: APBJJlFL2G33u/BZ/ePcmP0XM/Ky1MzF6PAT984w4OBRmJ4WZBTIcwixoNcsIY2eOd7h20u5Z7xm X-Received: by 2002:ac2:4d9a:0:b0:4f8:6e1d:cf98 with SMTP id g26-20020ac24d9a000000b004f86e1dcf98mr14386558lfe.66.1689140815690; Tue, 11 Jul 2023 22:46:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689140815; cv=none; d=google.com; s=arc-20160816; b=f+/Dk3RFbWEixfYXpS5cYMA3FDBQFLodP4Z5gGi/sYc3lL93NQHP9NlZJbo98a8/Vp 5Roiga9M/7SaHrqshR7FsNZbg5dmH3iEJAn74CG+PLuWkIfcMsilh36IbE4WdxMQ6buO 0y3IP/7htj3pUGQRZYXhC87LyxSDhLfmPyYkXDfYQCiIm2XO6MtXq1zzE452SfaWQoCd RPE+dCqXs3C5eE5Via+D0HwT7rco9d6uwX/PCm51mJzlxDxSE5yse4PKT7L/G1X5rYGe 4/q61t66aKUJCsq+86gPwm36tAtOyKIu3dRhJH2pfSf0wlYD/eSSY9Ks5sSSDghCJI9Q yqcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=kq6HoCSWjJULrdBpQtK0v2hxm5oXIHwNlZA0C4uPeBU=; fh=4wyNqjiKAsOV0MWM/X3LgrEJdGNhk7ZEiiOv3gS9qxg=; b=SVRoGKVB6iOHZxvQVz/qIcvvelp8A/Ylp0R9dZXlMrjYxjpmeTbLeN6hBJFfWsU1IT jUB4m9q8KjwDzemuRrkZrWHXZ6AB8Xju4+OrrfN2QMHpMWIrjz1y+Wdd3fMibM/W0xzH ciej2PcsCJvvqxzoJ0BkgwbsoCqJ9NRtDrJVTn9nWGXXEqsCP7w2Y5/7Hrc+Rd9rvjg5 XKdQVQs1ZQW2GzrzLc1RFzW1ZS5H8ZZdfpm7fk0BXvO3h7E7UCal8FWJH6cTKT/BRtL6 lYnEKOzcoeS79J6EJ6WrRfoJWpW3Dr8YigNKT1EA+kN8TkG0Zah2yQq5qfEO4KT5uAgt PV3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=ID+pt3M5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j20-20020aa7c0d4000000b0051e037805acsi3750749edp.125.2023.07.11.22.46.31; Tue, 11 Jul 2023 22:46:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=ID+pt3M5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231579AbjGLFBW (ORCPT + 99 others); Wed, 12 Jul 2023 01:01:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229551AbjGLFBU (ORCPT ); Wed, 12 Jul 2023 01:01:20 -0400 Received: from mail-qt1-x836.google.com (mail-qt1-x836.google.com [IPv6:2607:f8b0:4864:20::836]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC9FD10D4 for ; Tue, 11 Jul 2023 22:01:19 -0700 (PDT) Received: by mail-qt1-x836.google.com with SMTP id d75a77b69052e-4036bd4fff1so119321cf.0 for ; Tue, 11 Jul 2023 22:01:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1689138079; x=1691730079; 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=kq6HoCSWjJULrdBpQtK0v2hxm5oXIHwNlZA0C4uPeBU=; b=ID+pt3M5dxPQ0dOTdaZzCnWtxvadEc68M8WuUOiQvrp6cqAgLMyWMHflQRO+NuFWTp hMf7AePC3v3q7yCgEe2+YH+6OJIQ2TDkaklLIA0/ZsB1Y4qp9jbfDu0Vwzftck/3LIqK 9VrdP97s/QFE6azV3dtvUXIJPqHxir/c/lJJRdbr46ebfeAp3TUugVjZs5pEi/RCePab rAy/DOvW1GlqN01UrTG4z8PyCnLNZHit9b08lF3A+sVIYkN8gQD3QdiDsa9kbWIrko7f go8nnGaajCo+Ipsm4CbWGiv0Ww8JSwwbxT6/vaNApc2J3MOLGuN/CIW7BSOFR6NtKsVd ahrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689138079; x=1691730079; 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=kq6HoCSWjJULrdBpQtK0v2hxm5oXIHwNlZA0C4uPeBU=; b=TBAk6MojHL+iuq6QwIM+TEvXGDT8N+ljhyzEO3DKPeMYWrIugCF8gwjhVPL8Chy0GK S/aSZr3jajUrI27YK+ILFwqBk9NY6o2LpT4lLxSEsVf2Yoiw4o/TDJVILfXlwlBl5I4l iLKII7W+O36/h2JBm0D85SPiixp4aUp4VYjoAn2Fi796pU0kD9AiNF8+ZBjWkgMHNvb6 vHMVaBFGLR9CZApGfIylrghkzkdQ6YlxIxtUv/Xkez5m9SGFQZHbS5N9FDmqbHhGvyts Q9crnK+7fcnZT8O0HIb50qsJQtIytlz8cN8L+dPwfCWSGuIG3Amgs6YtCqdvyfW8CcYl LVpQ== X-Gm-Message-State: ABy/qLYZ4eSiIMJwmsgT9U48uXWaDJytpWrHYbIN2Ftgc20JrjcsOfMd XH3RnIfciVS2PrBttbbWCzV25qGG2jc9NXIEShvrIA== X-Received: by 2002:a05:622a:241:b0:403:a43d:be41 with SMTP id c1-20020a05622a024100b00403a43dbe41mr164760qtx.20.1689138078630; Tue, 11 Jul 2023 22:01:18 -0700 (PDT) MIME-Version: 1.0 References: <20230627181030.95608-1-irogers@google.com> <20230627181030.95608-14-irogers@google.com> In-Reply-To: From: Ian Rogers Date: Tue, 11 Jul 2023 22:01:07 -0700 Message-ID: Subject: Re: [PATCH v2 13/13] perf parse-events: Remove ABORT_ON To: Namhyung Kim Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Athira Rajeev , Kan Liang , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jul 1, 2023 at 11:43=E2=80=AFAM Namhyung Kim = wrote: > > On Fri, Jun 30, 2023 at 8:14=E2=80=AFAM Ian Rogers w= rote: > > > > On Thu, Jun 29, 2023 at 2:49=E2=80=AFPM Namhyung Kim wrote: > > > > > > On Tue, Jun 27, 2023 at 11:11=E2=80=AFAM Ian Rogers wrote: > > > > > > > > Prefer informative messages rather than none with ABORT_ON. Documen= t > > > > one failure mode and add an error message for another. > > > > > > > > Signed-off-by: Ian Rogers > > > > --- > > > > tools/perf/util/parse-events.y | 22 ++++++++++++++-------- > > > > 1 file changed, 14 insertions(+), 8 deletions(-) > > > > > > > > diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse= -events.y > > > > index 844646752462..454577f7aff6 100644 > > > > --- a/tools/perf/util/parse-events.y > > > > +++ b/tools/perf/util/parse-events.y > > > > @@ -22,12 +22,6 @@ > > > > > > > > void parse_events_error(YYLTYPE *loc, void *parse_state, void *sca= nner, char const *msg); > > > > > > > > -#define ABORT_ON(val) \ > > > > -do { \ > > > > - if (val) \ > > > > - YYABORT; \ > > > > -} while (0) > > > > - > > > > #define PE_ABORT(val) \ > > > > do { \ > > > > if (val =3D=3D -ENOMEM) \ > > > > @@ -618,7 +612,9 @@ PE_RAW opt_event_config > > > > YYNOMEM; > > > > errno =3D 0; > > > > num =3D strtoull($1 + 1, NULL, 16); > > > > - ABORT_ON(errno); > > > > + /* Given the lexer will only give [a-fA-F0-9]+ a failure he= re should be impossible. */ > > > > + if (errno) > > > > + YYABORT; > > > > free($1); > > > > err =3D parse_events_add_numeric(_parse_state, list, PERF_T= YPE_RAW, num, $2, > > > > /*wildcard=3D*/false); > > > > @@ -978,7 +974,17 @@ PE_VALUE PE_ARRAY_RANGE PE_VALUE > > > > { > > > > struct parse_events_array array; > > > > > > > > - ABORT_ON($3 < $1); > > > > + if ($3 < $1) { > > > > + struct parse_events_state *parse_state =3D _parse_s= tate; > > > > + struct parse_events_error *error =3D parse_state->e= rror; > > > > + char *err_str; > > > > + > > > > + if (asprintf(&err_str, "Expected '%ld' to be less-t= han '%ld'", $3, $1) < 0) > > > > > > Isn't it to be "greater-than or equal" ? > > > > I think the order is right. From the man page: > > > > When successful, these functions return the number of bytes p= rinted, > > just like sprintf(3). If memory allocation wasn't possible, o= r some > > other error occurs, these functions will return -1, and the cont= ents of > > strp are undefined. > > > > So here we need to catch -1 and ensure strp (&err_str) is NULL before > > passing it to parse_events_error__handle. > > Oh, I meant the message not the condition in the if statement. > It seems it aborts if $3 < $1, then it expects $3 >=3D $1 in the > normal condition, right? In the old code with the macro expanded it did: if ($3 < $1) YYABORT in the new code it fills in parse_state->error if the same error condition applies. The change is to get rid of the macro and add an error message. The asprintf is just added to make the error message more informative. Thanks, Ian > Thanks, > Namhyung