Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp3107029lqo; Tue, 14 May 2024 22:45:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUaI0kauCGSZPYuAUQ2CD995cogWrEdP70s2pjWuIcICh2npLk3/V70sUGhGXSzmpBrrnZOyzn7EEfsoA+IXN7gVN/rw8I3VWeIP5dnvg== X-Google-Smtp-Source: AGHT+IHD4ZTdCJoXvmOF3SlYna+cs5/s1V6W4mbB5Hsykj3ArWuZMjUn3E9pGGY+pTs1xbAWYQoD X-Received: by 2002:ac8:7d82:0:b0:43a:a813:65b with SMTP id d75a77b69052e-43dfdaf4432mr151902971cf.40.1715751917813; Tue, 14 May 2024 22:45:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715751917; cv=pass; d=google.com; s=arc-20160816; b=T1GkYID5H5sbBBfY0sdqPrnytxUVkzeoZAzQYHr/6jtoaqbIhbfG747Xrag1Re4Sqy iTzbfKyOi67P9BDJ+o+iZGb8DVVyqIosYiFmRvFXFaowch6yVvDNohIiX92w7MTjM9I6 MTk0DGBi0L4ju66g1vJYL8cq2N8Kt8rWk653E1A/a1gsQnsMkdvlmh9oBJEL67t++RAv ssNbqaOnU4ZCyATyBVYxZOxhD024lFevmz9hh9hTHgc/GnWQ2uKJzS1lEFe0b9WzFGOV gY/Q1wPF+G5oxZ8MgrF4KzzrwJriakuBZA1UgpRasUvmyjc4qYHba6aZjPZOGXeXrVVO 9qBQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=hfkROd5Bw1AFUt4MEnz47XASvZq08V6Z3/FB1WWOTAg=; fh=7D8bWqELNqJM6KF7zbibUOya8038rGAdDMFXsJMRu8c=; b=fCx4xRPKHaDLyd5mJNMg9QWrKtkyAuqcmflbzaSB4bIjjK7RxCuZFY25Mt+Y5Sb/7N Nz7MObjNThTG0STKWA8oaWWnc9y0MWSWmlyag6qM2dSifG/XaEp0wTRqgoAHaJ6ywNJa GXvwz4xVMw2+h5JO8GiVWEjICkVZDK6km9UUGthLi9sOqxu+TqceT//d/wUHzK72or/X OvhbXBOrbBThqA34oOXlsJQOUS6ne8Zqb8UwgcEZhjlJppZ0un0e3D8p6e9nCPefXmk5 vOZQAcBdzSUyytgCCCE9/rchwY2P3ieS4SF/8zS495hnKSjIknnDFJJ0p1MFM6iU8Jh2 Uv3Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=XNj3oJd+; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-179469-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179469-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d75a77b69052e-43df566f59bsi135183711cf.266.2024.05.14.22.45.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 May 2024 22:45:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-179469-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=XNj3oJd+; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-179469-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179469-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 8BA3B1C20A25 for ; Wed, 15 May 2024 05:45:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5780A3C062; Wed, 15 May 2024 05:44:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="XNj3oJd+" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CE1BB3A29C; Wed, 15 May 2024 05:44:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.8 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715751894; cv=none; b=C8S0EUCjIiGSmZPUkEkMx8DuCSTlhxr3FO50O5UnW5KMi3IT0Mc8shnYrz8sYbmm0yL7/HuF1SmmfTH4iAbFEdAlsvbhLO4Erm2C3e5+vFnZJ02AcUwqp6C2yixWihONsqRdXb+4Wb/QDrIGOravw5zyn+sNXgStX1E8ImwqkrM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715751894; c=relaxed/simple; bh=El3YDeqjczhekPR1W+uyDSK2dsNIh5KkIWwOCQU6c88=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IIK/ZkqzsrSwHg4+0MvtuaV8yN51yO6VIzsZKWiSEXHT+TSJHzCwZ3Js6Jqy4QluOIDc/e9VGQwQY+EgIDaIWdQuUetPt0MeFr2bnJvEpQ0VIdDwsCLjOrbkxDNs0dk39edyVdqnVpllWpgYmlg/Ul23nELE7+FDGRD+PKQNWqc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=XNj3oJd+; arc=none smtp.client-ip=192.198.163.8 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715751893; x=1747287893; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=El3YDeqjczhekPR1W+uyDSK2dsNIh5KkIWwOCQU6c88=; b=XNj3oJd+1b3Sa0FFwduk+d3h0ldNhg7NR62rOiGCcVbD9HUZyCI50Z+1 LwcZMujxZDYEfRydharfN9Sw+qvJsqxf0pWQHUa1t30Zs5MyuKMihjS+q zY+odL0oF8S7HxTVwLM/PQnHWblfK5Ty9jT1SqmCC5yoXZKhuTAA8Oi4E cpZGu4HeHJZCs21kKGKYfEIuNQhPK9axLzhOZnmRbvOe70Q/KqjTsFoJy 5sSy2ItvCKbvKh95uTETAnIQHi1KKd8W5g2hSt/cJIfUSIHDWvVw6RFIw fpbvbyW96aKcUt6KYH/ZF3mZ/mBtZI4MsBmMWdRg2sAwLLL42PPJ7pbzh w==; X-CSE-ConnectionGUID: C05+YnMmTq+6XhRrv9oWvQ== X-CSE-MsgGUID: 9Us7zIwFQYisoi3XyzsafQ== X-IronPort-AV: E=McAfee;i="6600,9927,11073"; a="29298025" X-IronPort-AV: E=Sophos;i="6.08,160,1712646000"; d="scan'208";a="29298025" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 May 2024 22:44:50 -0700 X-CSE-ConnectionGUID: TuBgUl9HRf2kdIWgXytw+g== X-CSE-MsgGUID: 96ocs0epQNWlhDdoIHhmsA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,160,1712646000"; d="scan'208";a="35469200" Received: from fl31ca102ks0602.deacluster.intel.com (HELO gnr-bkc.deacluster.intel.com) ([10.75.133.163]) by fmviesa003.fm.intel.com with ESMTP; 14 May 2024 22:44:50 -0700 From: weilin.wang@intel.com To: weilin.wang@intel.com, Namhyung Kim , Ian Rogers , Arnaldo Carvalho de Melo , Peter Zijlstra , Ingo Molnar , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Perry Taylor , Samantha Alt , Caleb Biggers Subject: [RFC PATCH v8 2/7] perf data: Allow to use given fd in data->file.fd Date: Wed, 15 May 2024 01:44:24 -0400 Message-ID: <20240515054443.2824147-3-weilin.wang@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240515054443.2824147-1-weilin.wang@intel.com> References: <20240515054443.2824147-1-weilin.wang@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Weilin Wang When in PIPE mode, allow to use fd dynamically opened and asigned to data->file.fd instead of STDIN_FILENO or STDOUT_FILENO. Signed-off-by: Weilin Wang --- tools/perf/util/data.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/data.c b/tools/perf/util/data.c index 08c4bfbd817f..98661ede2a73 100644 --- a/tools/perf/util/data.c +++ b/tools/perf/util/data.c @@ -204,7 +204,12 @@ static bool check_pipe(struct perf_data *data) data->file.fd = fd; data->use_stdio = false; } - } else { + + /* + * When is_pipe and data->file.fd is given, use given fd + * instead of STDIN_FILENO or STDOUT_FILENO + */ + } else if (data->file.fd <= 0) { data->file.fd = fd; } } -- 2.43.0