Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp442240pxv; Wed, 30 Jun 2021 09:04:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJQsXf1eUgaLd/jRR+AH+Ez8rtGXwWW/1jc1XW9ZSfOSAdVqZfIQEobHh+SPrBMg0eLSx+ X-Received: by 2002:a05:6000:1c9:: with SMTP id t9mr12137795wrx.330.1625069068319; Wed, 30 Jun 2021 09:04:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625069068; cv=none; d=google.com; s=arc-20160816; b=uksqbaiZpaCaduHChx7M6lfs6V+a3bKwOezwz1GN3nHBlfVWOBLxVDMC4hYD5gy3Fb MVn/9PpHg/kLcHqfokqewiq2bql5NbEDUev7HqCVPc7o4Kh7w6sdMavJyyu6Oo3nuh2t eFZMyQi6HCPkVsicS00YR0dGCiT3YR3yJmNpxAw7lCoxmGPDW75tb+FeTZEaW5fAOhfj 0gzhEprgdDJL3MgV+10tyC4ZesPSf9eBApbKvtdl2eOP9QhGP0ALNV9jJTB4wDDkiyjp vk6C5K+O4Az0Ny10uI7E1QbFFuC78dALw9nCf7wHRGKvZ1JgC3l0+q9KU+/wYTKrW9Hw PE8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=zX9UyQx6c5gc+3xjzBS2jmTOf890W1x177RpcXR7jok=; b=EwBeDA/vdG5toCI7Fy7zNfSdYYTCzlnvmh/MOVqgQuGMhUMcaip9hwXAr+HTU5gUDU Srj8KYi73iR84IwvG+TvlZbMxyyGzMCzvfXLbrafonlLkVUufNTAK94LS/iGFAeL6DRp gVku2UcBul0ehNlk3nq1i/5/UoXe3mxqkhelkqDcrajNEN0hc2WE6OZLyU82Yy7M6URo AF358ft+C3Q9vMQZsL1vUaKdsrPuWHq+cgRG+KPbrU08/2lRmHZjZqvDwrMShW1fUv1c huUENP6xShI2OPNvrhS+vHUsDwuDHqtGiUMxzGgtC9S19cejaF3uSKjTDtYWIjTRIXK+ YcYA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id og12si6794112ejc.607.2021.06.30.09.04.02; Wed, 30 Jun 2021 09:04:28 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236262AbhF3QCE (ORCPT + 99 others); Wed, 30 Jun 2021 12:02:04 -0400 Received: from mga01.intel.com ([192.55.52.88]:4075 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236177AbhF3QBn (ORCPT ); Wed, 30 Jun 2021 12:01:43 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10031"; a="230016087" X-IronPort-AV: E=Sophos;i="5.83,312,1616482800"; d="scan'208";a="230016087" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2021 08:56:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,312,1616482800"; d="scan'208";a="559099899" Received: from nntpat99-84.inn.intel.com ([10.125.99.84]) by fmsmga001.fm.intel.com with ESMTP; 30 Jun 2021 08:56:11 -0700 From: Alexey Bayduraev To: Arnaldo Carvalho de Melo Cc: Jiri Olsa , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Ingo Molnar , linux-kernel , Andi Kleen , Adrian Hunter , Alexander Antonov , Alexei Budankov , Riccardo Mancini Subject: [PATCH v8 21/22] perf session: Introduce READER_NODATA state Date: Wed, 30 Jun 2021 18:55:00 +0300 Message-Id: <17c991ec0d814a5718dc49ae08cabc3210b4a133.1625065643.git.alexey.v.bayduraev@linux.intel.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Adding READER_NODATA state to differentiate it from the real end-of-file state. Also an indent depth in reades initialization loop is reduced. Suggested-by: Namhyung Kim Signed-off-by: Alexey Bayduraev --- tools/perf/util/session.c | 45 ++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index b11a502c22a3..c2b6c5f4e119 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -70,7 +70,8 @@ struct reader_state { enum { READER_EOF = 0, - READER_OK = 1, + READER_NODATA = 1, + READER_OK = 2, }; struct reader { @@ -2305,7 +2306,7 @@ reader__read_event(struct reader *rd, struct perf_session *session, return PTR_ERR(event); if (!event) - return READER_EOF; + return READER_NODATA; session->active_reader = rd; size = event->header.size; @@ -2395,7 +2396,7 @@ static int __perf_session__process_events(struct perf_session *session) err = reader__read_event(rd, session, &prog); if (err < 0) break; - if (err == READER_EOF) { + if (err == READER_NODATA) { err = reader__mmap(rd, session); if (err <= 0) break; @@ -2472,25 +2473,25 @@ static int __perf_session__process_dir_events(struct perf_session *session) readers++; for (i = 0; i < data->dir.nr; i++) { - if (data->dir.files[i].size) { - rd[readers] = (struct reader) { - .fd = data->dir.files[i].fd, - .path = data->dir.files[i].path, - .data_size = data->dir.files[i].size, - .data_offset = 0, - .in_place_update = session->data->in_place_update, - }; - ret = reader__init(&rd[readers], NULL); - if (ret) - goto out_err; - ret = reader__mmap(&rd[readers], session); - if (ret != READER_OK) { - if (ret == READER_EOF) - ret = -EINVAL; - goto out_err; - } - readers++; + if (!data->dir.files[i].size) + continue; + rd[readers] = (struct reader) { + .fd = data->dir.files[i].fd, + .path = data->dir.files[i].path, + .data_size = data->dir.files[i].size, + .data_offset = 0, + .in_place_update = session->data->in_place_update, + }; + ret = reader__init(&rd[readers], NULL); + if (ret) + goto out_err; + ret = reader__mmap(&rd[readers], session); + if (ret != READER_OK) { + if (ret == READER_EOF) + ret = -EINVAL; + goto out_err; } + readers++; } i = 0; @@ -2507,7 +2508,7 @@ static int __perf_session__process_dir_events(struct perf_session *session) ret = reader__read_event(&rd[i], session, &prog); if (ret < 0) break; - if (ret == READER_EOF) { + if (ret == READER_NODATA) { ret = reader__mmap(&rd[i], session); if (ret < 0) goto out_err; -- 2.19.0