Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp449216lqb; Tue, 28 May 2024 23:43:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW7IBX5KfZFvhQ2L0ztwCZIvSbLSEABb5ltcq7OwzYbl4y4HrWAWvTPGqThsybqC4Azuc5ZEayeJHwZjCQ87sO6auYZv8DcrSzKpB2h1w== X-Google-Smtp-Source: AGHT+IF4A9/bnHIHj9W7hkAS02CQH82Cqta651hhB/FL+RE+bBlHKaGl7J2ZIt0PteeS1XQtHMMJ X-Received: by 2002:a17:906:2a05:b0:a5a:76e2:c2a8 with SMTP id a640c23a62f3a-a62646cd756mr949248566b.23.1716965038568; Tue, 28 May 2024 23:43:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716965038; cv=pass; d=google.com; s=arc-20160816; b=1I0e/rpRaEj8ae/syuuzzOJFWFRqR/Ya0sX4ClPNVtamt7DeZXq+47GcwG7K8jXOR1 2DthBKhRhyE1pBbldrPYjrxn29veZGBHcl3gCz8CL3A3XFV4WGQ44tIb8ydQl9DYptJe 7yQfXprCu/rrcPnbi7uIPhR04Q65+grDjnO7O43WTrZZkFFemOTG6297LjX/9Ghm66aA xFSAaoWrqFLj96jbM6ifcka8M/o2/cjHMUw0f/lssL027CoSZrw4+aEHPkxzEb0TpYma 3iR65p/j5MW5qZc1fcI/689fpK/Tc1PmhZvew2z9pBOC8DC669oMoc+L3kEbTbKfgfrm CYMw== 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=rCYtQDNdIKD6FaTIG+o6+V/Z5K6sECz7KPMSysE0xLe/iASEcivSEbKbQdeaMNpLLo ggPMzZxTPWwQAMS5u2cS+YNnUJ6yI0vNBOF4vFa93HWoscNyxTbyGFlcJ6iUj9zYVnQ3 wW2vkk/TO49UHUhNa6JATClqs8fJNiLFEfVnFlnqdmawZvqkf/OCJwWlGsdlCVjLggfh 6REhzJNhsKgk/DILEyuq1eM3HTIPYUXB92LnveVFKL8L2Ukfc/ndZxLg8uULYLZPgy5a taVYxuJNGr0fb1WucuvxKKj6dMmGBwTAHHVQtOf5NpauCdXZEpiIU/cAg5khdhRb8f4h eC/w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YXI1EMXY; 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-193532-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193532-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a626cdd168esi595696466b.964.2024.05.28.23.43.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 23:43:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-193532-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YXI1EMXY; 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-193532-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193532-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 4EE2E1F266A7 for ; Wed, 29 May 2024 06:43:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 306BF1649D1; Wed, 29 May 2024 06:43:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="YXI1EMXY" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (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 F038015FCF2; Wed, 29 May 2024 06:43:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716965018; cv=none; b=VnUQgBSSCA4XNY+yH3h2X3/7FYx5KUdjLCTmVvIvQIPG02QEvjVcIdkJ5ErqvTWWt6Npm+RJ9+nhaYClJW5Sn8hwa0MVL7nx5M5kM0t06L01iZ/lXMyoz0GeIjOGvl4Dc3h0ixIXblDJNeEKm9zuLOw4vXj9LTd6jSlyZekDyqw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716965018; c=relaxed/simple; bh=El3YDeqjczhekPR1W+uyDSK2dsNIh5KkIWwOCQU6c88=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DQbKETVJfWDM+hNXLe1ub5wBC2QxSm11D9+J2DcK69IBbPcB7rOZLnM3x3BBD+ou5x7CRAUQmIBCoE6Aj75j+DhSN615eSj8YwwC03Psrx2StwgeuJDubZ7EqvzFHKqgAY5NJ0AR6PG6ViTibVt/YSsOwCx5W1hXViY4yuP9Gek= 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=YXI1EMXY; arc=none smtp.client-ip=192.198.163.13 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=1716965017; x=1748501017; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=El3YDeqjczhekPR1W+uyDSK2dsNIh5KkIWwOCQU6c88=; b=YXI1EMXYOcQbilH9zYUZ0mGUdprAm7vCKXEibCip3zPKrGATc06mlBl1 kuQ7GXsAVbKkQJUJZTTAbyxKnEayrk50NB8FbFi+GIutxApw1dZx9BIhr keSk2oU96S6EKslzXIunae8h9sxTx5HXeT0jsVZcbQ/PXK5kSKTMGc0eB t2fCOzgA1V+xVT88O3JZWckAQta4cp0iF0OrVh9ekz/T00uiXrZO+Lxhg HPh6sx3J/WcZFNE0tO1CGrIED2P/cciFf22v+rNoAZP7psbXFBPZskMln 3ql731icMvnVVKr1J7VLUXX8kzc8Py2UKMqJe2Rou/5NRZROVkeXCss4+ g==; X-CSE-ConnectionGUID: 217vS8sQS0mNBNDcG8WfYQ== X-CSE-MsgGUID: 81v9E6gKSdShM5wP+Z2fWg== X-IronPort-AV: E=McAfee;i="6600,9927,11085"; a="16297986" X-IronPort-AV: E=Sophos;i="6.08,197,1712646000"; d="scan'208";a="16297986" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2024 23:43:35 -0700 X-CSE-ConnectionGUID: 9QiraeXmTPKOYrvmOit7UA== X-CSE-MsgGUID: NlvS2dNQQhiP0+TOe+wGtQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,197,1712646000"; d="scan'208";a="39759266" Received: from fl31ca102ks0602.deacluster.intel.com (HELO gnr-bkc.deacluster.intel.com) ([10.75.133.163]) by fmviesa005.fm.intel.com with ESMTP; 28 May 2024 23:43:34 -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 v10 2/8] perf data: Allow to use given fd in data->file.fd Date: Wed, 29 May 2024 02:43:18 -0400 Message-ID: <20240529064327.4080674-3-weilin.wang@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240529064327.4080674-1-weilin.wang@intel.com> References: <20240529064327.4080674-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