From patchwork Thu Feb 14 14:07:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slavomir Kaslev X-Patchwork-Id: 10812803 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9AB20746 for ; Thu, 14 Feb 2019 14:07:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 89FE32E6B1 for ; Thu, 14 Feb 2019 14:07:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7E4132E6B5; Thu, 14 Feb 2019 14:07:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1DFCA2E6B1 for ; Thu, 14 Feb 2019 14:07:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729495AbfBNOHf (ORCPT ); Thu, 14 Feb 2019 09:07:35 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:53819 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728665AbfBNOHf (ORCPT ); Thu, 14 Feb 2019 09:07:35 -0500 Received: by mail-wm1-f67.google.com with SMTP id d15so6436027wmb.3 for ; Thu, 14 Feb 2019 06:07:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=HPqJ5rNjIKd+FxBAsm6BSpI/Zvpwo027NhQLS4+wkzw=; b=bLlhteLmDazBnlaTZe/nzA5+pad+OGSIO+U+8az8SwgvHn9N0TwvdFS60nrhMsBWCR 2FH2q1odKOMDMe7c1lSTLGzxxq6ic/XCcSs9RynHnPoousdYTOgJZwQiap/H0xGupyYe RQvObxWRVx5bD2LBVedpybYqUPrnmYuJ4eli7Zn/ajP6pv1wW3UpcxXVKvdiYqeWQ4OZ l8KXPIdqfFQpJBKe89xga2M6vPI8YlM3Hs/GTQ0uueQIyqP7ol8CRFOVLiRDonnHMYEh YSTvmcWkfhSM59sO9de+4tkGRv6+GUMM3bgR6BRQ1BIFKtUIGD3meYvStU3FsYfLYs3e BHDw== X-Gm-Message-State: AHQUAua7DZikFlGI8oXk5nHywiLIfr6coLSBmf2jUDL6ErNkYNFdv5gI jpLzxy+a3OY5hjH5OaKoOg== X-Google-Smtp-Source: AHgI3IZV1g8RqyDa2RN5zQaBHXR4NPOEpVtzak4Sv9QAaNCW0do4XpKknnJkFN7EsoD3OruMKKivfw== X-Received: by 2002:a1c:2082:: with SMTP id g124mr2722650wmg.59.1550153253721; Thu, 14 Feb 2019 06:07:33 -0800 (PST) Received: from localhost.localdomain ([213.145.108.55]) by smtp.gmail.com with ESMTPSA id c9sm2067220wrs.84.2019.02.14.06.07.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Feb 2019 06:07:31 -0800 (PST) From: Slavomir Kaslev To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, slavomir.kaslev@gmail.com Subject: [PATCH 1/3] trace-cmd: Fix tracecmd_recorder leaking file descriptors Date: Thu, 14 Feb 2019 16:07:21 +0200 Message-Id: <20190214140723.27804-1-kaslevs@vmware.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Sender: linux-trace-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP tracecmd_recorder is leaking brass pipe() file descriptors it creates for splice()-ing. Fix this. Signed-off-by: Slavomir Kaslev --- lib/trace-cmd/trace-recorder.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/trace-cmd/trace-recorder.c b/lib/trace-cmd/trace-recorder.c index 5331925..b941cdc 100644 --- a/lib/trace-cmd/trace-recorder.c +++ b/lib/trace-cmd/trace-recorder.c @@ -88,6 +88,12 @@ void tracecmd_free_recorder(struct tracecmd_recorder *recorder) append_file(recorder->page_size, recorder->fd1, recorder->fd2); } close: + if (recorder->brass[0] >= 0) + close(recorder->brass[0]); + + if (recorder->brass[1] >= 0) + close(recorder->brass[1]); + if (recorder->trace_fd >= 0) close(recorder->trace_fd); From patchwork Thu Feb 14 14:07:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slavomir Kaslev X-Patchwork-Id: 10812805 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9FF90746 for ; Thu, 14 Feb 2019 14:07:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8FDB22E6B1 for ; Thu, 14 Feb 2019 14:07:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 83E572E6B5; Thu, 14 Feb 2019 14:07:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2CC702E6B1 for ; Thu, 14 Feb 2019 14:07:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728276AbfBNOHh (ORCPT ); Thu, 14 Feb 2019 09:07:37 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:53036 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728665AbfBNOHg (ORCPT ); Thu, 14 Feb 2019 09:07:36 -0500 Received: by mail-wm1-f67.google.com with SMTP id m1so6439741wml.2 for ; Thu, 14 Feb 2019 06:07:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/L+sxL3MJASp3TmTH7GNw+LnZZpZclu+Ja3ElVg4RD8=; b=m+Zorr3Bn7UEl/LP2fUvLjdGJPhcGRAZMxuT7WC0sNZHK3qhvaJjM3YndAVFcH1AGj m0m5Wn2IA3+o5/Oi2OEmneTXFxh4NdHx1nKzfyr84uGoommH5NjXcJ5HfjQNvBQjAaeW 5GmlWZI00Kto5xS8OCwysFbyna2E8BsIfI5YqPZbQTqvcdjPtovVI7SwWbJQenGXbbYj ipMfP2c5Hhi6ZgNgPho4UnK9dtk5BXLhk2NYulxvEdJXJfQcZXsUcuaQwwCOC5vDO5dp VPJpx2JxGWJCCcziSnOn5P9Dw4JBwW8DzHuFxrDFH0rWu8qYxxP9pazS6IlOylkQuGss ZS2w== X-Gm-Message-State: AHQUAuZBUITTZbFtT5wHAWPdIDsqvDApq61wVPRqxi5lYfIgBPuqpQ2Y DSYKcBrUHc8N9Zg6YSGmaw== X-Google-Smtp-Source: AHgI3Ibfj9fwM/pztkmzcb/0rbZ2f+p57Ffj2Jjb3qO9pKSf3BYiLZQotP/c8Xn/MThR/HYD1Cu/QA== X-Received: by 2002:a1c:9810:: with SMTP id a16mr2858203wme.37.1550153255050; Thu, 14 Feb 2019 06:07:35 -0800 (PST) Received: from localhost.localdomain ([213.145.108.55]) by smtp.gmail.com with ESMTPSA id c9sm2067220wrs.84.2019.02.14.06.07.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Feb 2019 06:07:34 -0800 (PST) From: Slavomir Kaslev To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, slavomir.kaslev@gmail.com Subject: [PATCH 2/3] trace-cmd: Add defines for splice() flags on systems with old glibc Date: Thu, 14 Feb 2019 16:07:22 +0200 Message-Id: <20190214140723.27804-2-kaslevs@vmware.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190214140723.27804-1-kaslevs@vmware.com> References: <20190214140723.27804-1-kaslevs@vmware.com> MIME-Version: 1.0 Sender: linux-trace-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use SPLICE_F_ defines to refer to splice() flags instead of their numeric values. This should be only necessary on systems with glibc version < 2.5. No changes in behavior intended. Signed-off-by: Slavomir Kaslev --- lib/trace-cmd/trace-recorder.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/trace-cmd/trace-recorder.c b/lib/trace-cmd/trace-recorder.c index b941cdc..1b6a995 100644 --- a/lib/trace-cmd/trace-recorder.c +++ b/lib/trace-cmd/trace-recorder.c @@ -26,6 +26,13 @@ # define F_GETPIPE_SZ 1032 /* The Linux number for the option */ #endif +#ifndef SPLICE_F_MOVE +# define SPLICE_F_MOVE 1 +# define SPLICE_F_NONBLOCK 2 +# define SPLICE_F_MORE 4 +# define SPLICE_F_GIFT 8 +#endif + struct tracecmd_recorder { int fd; int fd1; @@ -122,10 +129,10 @@ tracecmd_create_buffer_recorder_fd2(int fd, int fd2, int cpu, unsigned flags, recorder->cpu = cpu; recorder->flags = flags; - recorder->fd_flags = 1; /* SPLICE_F_MOVE */ + recorder->fd_flags = SPLICE_F_MOVE; if (!(recorder->flags & TRACECMD_RECORD_BLOCK)) - recorder->fd_flags |= 2; /* and NON_BLOCK */ + recorder->fd_flags |= SPLICE_F_NONBLOCK; /* Init to know what to free and release */ recorder->trace_fd = -1; @@ -349,7 +356,7 @@ static long splice_data(struct tracecmd_recorder *recorder) long ret; read = splice(recorder->trace_fd, NULL, recorder->brass[1], NULL, - recorder->pipe_size, 1 /* SPLICE_F_MOVE */); + recorder->pipe_size, SPLICE_F_MOVE); if (read < 0) { if (errno != EAGAIN && errno != EINTR) { warning("recorder error in splice input"); @@ -421,7 +428,7 @@ static void set_nonblock(struct tracecmd_recorder *recorder) fcntl(recorder->trace_fd, F_SETFL, flags | O_NONBLOCK); /* Do not block on streams for write */ - recorder->fd_flags |= 2; /* NON_BLOCK */ + recorder->fd_flags |= SPLICE_F_NONBLOCK; } long tracecmd_flush_recording(struct tracecmd_recorder *recorder) From patchwork Thu Feb 14 14:07:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slavomir Kaslev X-Patchwork-Id: 10812809 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 08EAB13A4 for ; Thu, 14 Feb 2019 14:08:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA8EC2E6B5 for ; Thu, 14 Feb 2019 14:08:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DC0452E6C1; Thu, 14 Feb 2019 14:08:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6BBC12E6B5 for ; Thu, 14 Feb 2019 14:08:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389253AbfBNOIi (ORCPT ); Thu, 14 Feb 2019 09:08:38 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:53834 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388106AbfBNOHi (ORCPT ); Thu, 14 Feb 2019 09:07:38 -0500 Received: by mail-wm1-f65.google.com with SMTP id d15so6436352wmb.3 for ; Thu, 14 Feb 2019 06:07:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wX6Tb5dK6vOJarWEgtra+dhFLMjvVO6pzuwP6dVDh8M=; b=PcENor2ukB/D+MCxDLbuaNI3URHerp2dfYlNVo3EGhj0dxOBn0KXC53bq+UDvneawH DZN37fQ92CvygL4RTKGiKW6gptaQZC06+jol95kTqwAq6sP3vyY4FUBkXWmZ67Rh4dKk Ge6NvN6Lkd+eKgUXqwM6xfK0A3sAuouVnN5jcBEc9yPfhd+9CZ65uJDwIoDiQ5sFVmyK /TNsaat6K4KdWS+3fD05yJn0NczC7zqtoq9Xaugq6rC28brHmdENQUOI8m3joBVbXIoe 67bJWr0EXvVbodGjWcXTA7IlHgMM60vx80vdgiNngxyWBGhMK9XMejcE4l8IFftZ9ryq 2cCw== X-Gm-Message-State: AHQUAuYeOiOOdm7D+m7rHzLnLluyA8g8B0H4kvOAfZWkqaMf7P3WFugT cpEc5MECilQE/4CN6fGvrw== X-Google-Smtp-Source: AHgI3IazbQp5y1DHmvPh/OV7iHnnnQZihwf8jz+IR/dBDG8I4WPTmsrCI9MaZu9uKovx1Qdnh368lQ== X-Received: by 2002:a7b:c777:: with SMTP id x23mr2989689wmk.71.1550153256790; Thu, 14 Feb 2019 06:07:36 -0800 (PST) Received: from localhost.localdomain ([213.145.108.55]) by smtp.gmail.com with ESMTPSA id c9sm2067220wrs.84.2019.02.14.06.07.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Feb 2019 06:07:36 -0800 (PST) From: Slavomir Kaslev To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, slavomir.kaslev@gmail.com Subject: [PATCH 3/3] trace-cmd: Removed some unused #includes Date: Thu, 14 Feb 2019 16:07:23 +0200 Message-Id: <20190214140723.27804-3-kaslevs@vmware.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190214140723.27804-1-kaslevs@vmware.com> References: <20190214140723.27804-1-kaslevs@vmware.com> MIME-Version: 1.0 Sender: linux-trace-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch removes several unused #include directives. No changes in behaviour intended. Signed-off-by: Slavomir Kaslev --- lib/trace-cmd/trace-input.c | 9 --------- lib/trace-cmd/trace-recorder.c | 9 +-------- 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/lib/trace-cmd/trace-input.c b/lib/trace-cmd/trace-input.c index b628570..34a8301 100644 --- a/lib/trace-cmd/trace-input.c +++ b/lib/trace-cmd/trace-input.c @@ -4,22 +4,13 @@ * */ #define _LARGEFILE64_SOURCE -#include #include #include #include -#include -#include -#include -#include -#include -#include #include -#include #include #include #include -#include #include #include diff --git a/lib/trace-cmd/trace-recorder.c b/lib/trace-cmd/trace-recorder.c index 1b6a995..0b8d98a 100644 --- a/lib/trace-cmd/trace-recorder.c +++ b/lib/trace-cmd/trace-recorder.c @@ -4,18 +4,11 @@ * */ #define _LARGEFILE64_SOURCE -#include #include #include -#include -#include -#include -#include -#include -#include #include +#include #include -#include #include #include "trace-cmd.h"