Received: by 2002:ab2:6f44:0:b0:1fd:c486:4f03 with SMTP id l4csp140831lqq; Wed, 12 Jun 2024 20:36:59 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVvCAg7SJZNvX43bJyomcNE4eB2wXNj57E/jygHfV3T8ywdA+u1j7mou7r5l4NUK8k5g46h+imPvWrkR52Mg4BmdNZBA8MrVdvLAhVilw== X-Google-Smtp-Source: AGHT+IEYNKYr2AzSDC+B+4nHs6UHBmO4DuH4KCMj+79NyO8CvqM9Aixu/0FsYpL0xaFV9HjQfDWk X-Received: by 2002:a05:620a:6848:b0:795:5add:31fa with SMTP id af79cd13be357-797f6128c95mr311026085a.67.1718249819319; Wed, 12 Jun 2024 20:36:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718249819; cv=pass; d=google.com; s=arc-20160816; b=b9Z0yz4woK814BC0XnNvzZBjeMi1rXcZuGkQznv5MBPSmIZfX6jXquC1oFF3Zh8gUa WbgVpHmE4lEpwey7dR0AggGdf4GCT6hv3cSenOj35sJaf1w74qBTJjuYbAyJyafcQ7EC SZY+bd/moW2huBYHcmz0j4rvrCzVHDYOf/26pK6351qH92qpGo51r7Zx6j3NSgsGgUb8 px3AYMFg3cWFKXVOHoViDqTKJdLL+P+9egHVLWAp6DZwqct9VyNhSoVSafLZmQf4npkJ HrY6cs9XFKLV+RnHh2GritmPgcVGgfVBAVHK3MNeQIwZrF0e6nNUHLAJTtVORHsmh2aa AqIw== 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=UstdGBm5ERtG/0EjgLi1ogbH2s53TlQWUratMUsdH0wx7Se+h3gMAC4jvzt7XxFz0X 2nAljDFsuhcfvahL7Efn5sht+Kl1uafEaMHGmKnXv0DzfTRvtMhAudISYw6PC/zuwhe1 d+doqwJuovL18GKFl88lj22CwPqnmimAx6MsfbLbxs+6xdsWuD22l8ws9stFr4mrv+BS 2dnFul8zlnGTnjaWc2AfOO9eaMjiVkPpvFsvoN+ngR4IQD7w7syqKIKO2t5csZGlpZC6 lBgvTYXF+mYjSzTPLPagFUoeiW0aBvNJOmmkeKDssnBEzfFFQZOSvf+pmGQKTsbNlBII g/fg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="F13DQwU/"; 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-212527-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-212527-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-798abf8f38bsi49772285a.689.2024.06.12.20.36.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 20:36:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-212527-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="F13DQwU/"; 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-212527-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-212527-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 0E1101C21F74 for ; Thu, 13 Jun 2024 03:36:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C0EFB13211F; Thu, 13 Jun 2024 03:36:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="F13DQwU/" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (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 84FD8130A68; Thu, 13 Jun 2024 03:36:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718249799; cv=none; b=m1/scLoaLcYgIaZD8OZNnT3gsZlfg7ruHl7zWQOZpNvWerOrIuFQkc32pMqZprcJ3zKzOnoNRm8vitigtn4GwxGVDE/IlFudXFRUZLfKqJRAj6Zg09tIsA/o1elgEJqZHy32nd5OlUvrAw13IQA+9U53QZB0IeLX9CO+U15t3Jg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718249799; c=relaxed/simple; bh=El3YDeqjczhekPR1W+uyDSK2dsNIh5KkIWwOCQU6c88=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QUpYXcYMtoXZ7WeKgFdjsGIMjtSFlllBbDnCAjuifFYvT+LtbxI5wK3s/k4Ux0E9TZZD6BJQ8QhKsc1Ja+6PJ7unjhLnXv+TyDWWEEeDdQhTVVeqyeuSE3XTaBtntW7oWoeS8sUdFCPaT0Lr4DZdyJ8tJbq6YWG3Bdw3HV81F8c= 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=F13DQwU/; arc=none smtp.client-ip=192.198.163.16 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=1718249798; x=1749785798; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=El3YDeqjczhekPR1W+uyDSK2dsNIh5KkIWwOCQU6c88=; b=F13DQwU/IXSwqI4+bisdJHPz9L7f/S3zNg+p/7WtifomBvEOzO/zd+oZ 3UzJmU/GQ3I3MLEs1HM0ls9RyXl0pEmDLUgIJ88vvRqsAcgQ7SZxRy9V0 0ynNRQj/OpLkLwtrX90+9IYywAnmyYs4DAz07Y0RQg6WX9EqDTIsD5a6O 3RKTFWvVsEOYzZ0XSGd+seqUw4SgiuRPHIptSmRPM5uHanIOZg/a5LEyI Kc9j0COMh0wNl8bPf3NiAGD4mfMax9jE0UjQ7mWv967qxb+Y/TT2O5QmE 3iYCrG0gZ3zKlBjbOn0XaRUlDx+++g+mPbgNtJCJM4QTPP0kKE+7Uz/1X A==; X-CSE-ConnectionGUID: F3IiW5uJRR+NjG0ZA/aMFQ== X-CSE-MsgGUID: JeCCoAEVSISPSCMX07sUpw== X-IronPort-AV: E=McAfee;i="6700,10204,11101"; a="12046712" X-IronPort-AV: E=Sophos;i="6.08,234,1712646000"; d="scan'208";a="12046712" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jun 2024 20:36:37 -0700 X-CSE-ConnectionGUID: IQL9ezSvT8OHxw/RxzeWeA== X-CSE-MsgGUID: QWRH2GPBR+iyqJPLq7c1tw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,234,1712646000"; d="scan'208";a="40100350" Received: from fl31ca102ks0602.deacluster.intel.com (HELO gnr-bkc.deacluster.intel.com) ([10.75.133.163]) by fmviesa009.fm.intel.com with ESMTP; 12 Jun 2024 20:36:36 -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 v13 3/9] perf data: Allow to use given fd in data->file.fd Date: Wed, 12 Jun 2024 23:36:23 -0400 Message-ID: <20240613033631.199800-4-weilin.wang@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240613033631.199800-1-weilin.wang@intel.com> References: <20240613033631.199800-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