Received: by 2002:ab2:69cc:0:b0:1fd:c486:4f03 with SMTP id n12csp136291lqp; Mon, 10 Jun 2024 22:31:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUt2yXjjWVmur6EuybdJzgPTNutDygMOiMd5TEQPYLtG1pBCQRSZEj8LMV1Q+ACsyRfH03Bb8a182HBhfvdGnRiBX12kde+rvxqHpGDeA== X-Google-Smtp-Source: AGHT+IEfPMaPvCqUuWJoCmGyxrd/CTjTxBDQBbjDrVqLyj1C8jvjxIn/GF/9MWup2EG03m0BR/VD X-Received: by 2002:a67:f11a:0:b0:48b:9f31:fe71 with SMTP id ada2fe7eead31-48c274a6ccemr9671599137.29.1718083882575; Mon, 10 Jun 2024 22:31:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718083882; cv=pass; d=google.com; s=arc-20160816; b=WlmuWdT0UKda0romZizj4x/nezfDn3Z2LNH6pm/r65V78RjdKEhA5XEN/QejMXI17K 2NJmTPGYXSGK4nj7hWIAKKjad6vAHNn0wX2norfLiYu0Uf+x7qbWpMNskxtkDEvBjz5k u/zfl1MJrANYDUcfd7pFn1TadYaKBu5r4Zd/UoNRSQk0pdwKtGbrpztKx5eTNT+t8+Ku V3ihWyjnYz8wEAGmgGWwFeyUWAsYX0LOqPmk8SZS6zW2Ln+yn/5zcdUiinnWQC0FsUDh 6/IgPbiS2+JQowDGzSvqD63daHSAtbTqasHzXZQyHq3EmGMeiP7iBLYY4ADMQciGJCCO 5hWw== 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=cLwQ26JIoQDh+1d+H1weXsik+/WEfgGn06V8+712jK4Re13SrM1FcPcRLQoJJTd8+x 6V1lzxuyQYYhSR1FwZQPq/TqDB7ipP53cVfW1lZaCPBA5X6U3x3kFq9RPyotKZfm1C7v FCe0IjtzJxqgVw8LsFvE48SdqRpeIcC7rlau+BK5MAetKw8ihTt+XVvWLYOWucmqnINi O9qxnLzqOR3YzOPD76P28cVJoD0gnOPu1SH5rXd6MAJms1kLJu8F+RWifse+UsDrPRJm X9zPjiJUEzWRvtnajue4KKr2IKXi41wxaXMJPDO091BrmDSOj/UKI/PrVBfMjuzqAh9I 92mQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nAFD7Oet; 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-209273-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-209273-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. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id af79cd13be357-795332ed468si1295467185a.430.2024.06.10.22.31.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 22:31:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-209273-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nAFD7Oet; 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-209273-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-209273-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 4A6DE1C21E95 for ; Tue, 11 Jun 2024 05:31:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B2CDA172BD0; Tue, 11 Jun 2024 05:24:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="nAFD7Oet" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 6A416171083; Tue, 11 Jun 2024 05:24:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718083447; cv=none; b=VQS/oF740ObHbPJX3DcbY+AcGE1dAFrr5oB44tMzMCSkCve2iVhcYQyICqueha29nA5T04jQ8ImhDfq7PdOyJclaGazjBtuQee+7JGUYYb9xpBaF9hprqyYXZUSf7tvw3MHzw7WWmgrcCMfLv5HKX9ob17B6+vezCYI50A6yj7s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718083447; c=relaxed/simple; bh=El3YDeqjczhekPR1W+uyDSK2dsNIh5KkIWwOCQU6c88=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QNzmaRQNVgBXP/obVs3d94usDy8N3Fh3HVFeR4qRgIbPGoXTX5dO6iZaA2jA34YGnMYaaJ9Efb3ZTXVjUmsjEWbsh5djH2NZxwdhS/8psVdfgLlmvcFYBuwSdT1hqTp4BfSUEaTp/iegMZDELN3IABJcBxX54cvzfjUw/OOL7vY= 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=nAFD7Oet; arc=none smtp.client-ip=192.198.163.17 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=1718083446; x=1749619446; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=El3YDeqjczhekPR1W+uyDSK2dsNIh5KkIWwOCQU6c88=; b=nAFD7Oetu7Dm5ajokMMWV9MMq2R4J/Kteq2AjSUFOzOp1mGRJ1dcM4U4 SpO8s1Pi79ZfYpY/vIJaaqtZ5IGVZ/9aL8lWoU2fRwLQ81cp9hcznNoHk NY+S//Xay7SAhXyEnBJydge0GjAuDu0MYS9t3VHTJeKWVeySTXiCig6UG pyysF1wdhFiNDCWvMZzCK1JsEIpaPRE3r91oAQuaAzIDBVJARHVR4HC1s Aw/qoVwdQ3JtHx3othkkFhVNkgdS6qyyp5yCjLBOXAJPWL0jhpOl9k1iM eY6vb61qPNyaWhVyW0wYJGh1X2OIdYd+v9tjSMNkFVZP76q6IgZJU2udm g==; X-CSE-ConnectionGUID: 81SOgoYiS8iQMZGXuOLPvQ== X-CSE-MsgGUID: zBPGSJ5sQ0OX3ftaMdOqlA== X-IronPort-AV: E=McAfee;i="6600,9927,11099"; a="14651129" X-IronPort-AV: E=Sophos;i="6.08,229,1712646000"; d="scan'208";a="14651129" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2024 22:24:03 -0700 X-CSE-ConnectionGUID: D3ikHP1PRfORkEaAFvxAAA== X-CSE-MsgGUID: d8AeygDfR1esrYkukERD2w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,229,1712646000"; d="scan'208";a="44441192" Received: from fl31ca102ks0602.deacluster.intel.com (HELO gnr-bkc.deacluster.intel.com) ([10.75.133.163]) by orviesa004.jf.intel.com with ESMTP; 10 Jun 2024 22:24:04 -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 v12 2/8] perf data: Allow to use given fd in data->file.fd Date: Tue, 11 Jun 2024 01:23:21 -0400 Message-ID: <20240611052331.85715-3-weilin.wang@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240611052331.85715-1-weilin.wang@intel.com> References: <20240611052331.85715-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