From: Vaibhav Nagarnaik <vnagarnaik@google.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Justin Teravest <teravest@google.com>,
David Sharp <dhsharp@google.com>,
linux-kernel@vger.kernel.org,
Vaibhav Nagarnaik <vnagarnaik@google.com>
Subject: [PATCH 2/2] trace-cmd: Close the trace file descriptor
Date: Mon, 19 Mar 2012 13:28:43 -0700 [thread overview]
Message-ID: <1332188923-13375-2-git-send-email-vnagarnaik@google.com> (raw)
In-Reply-To: <1332188923-13375-1-git-send-email-vnagarnaik@google.com>
trace-cmd opens "trace_raw" file descriptor to splice data continuously
through it to the CPU files. This causes a lot of pages being allocated
for the splice interface in the kernel. After the recorder instance is
destroyed, it doesn't close the file descriptor causing many of the
pages to remain in the cache. This gives an invalid view of memory lying
around in cache.
In any case, it is a good practice for the applications to close all the
descriptors that are opened.
This patch closes the open file descriptor which is used in the splice()
call and updates the check for disk file descriptor when closing it.
Signed-off-by: Vaibhav Nagarnaik <vnagarnaik@google.com>
---
trace-recorder.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/trace-recorder.c b/trace-recorder.c
index 4a01fb9..215affc 100644
--- a/trace-recorder.c
+++ b/trace-recorder.c
@@ -50,7 +50,10 @@ void tracecmd_free_recorder(struct tracecmd_recorder *recorder)
if (!recorder)
return;
- if (recorder->fd)
+ if (recorder->trace_fd >= 0)
+ close(recorder->trace_fd);
+
+ if (recorder->fd >= 0)
close(recorder->fd);
free(recorder);
--
1.7.7.3
next prev parent reply other threads:[~2012-03-19 20:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-19 20:28 [PATCH 1/2] Revert "trace-cmd: Add function declaration to fix compile warning" Vaibhav Nagarnaik
2012-03-19 20:28 ` Vaibhav Nagarnaik [this message]
2012-05-21 14:14 ` Steven Rostedt
2012-05-21 17:33 ` Vaibhav Nagarnaik
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1332188923-13375-2-git-send-email-vnagarnaik@google.com \
--to=vnagarnaik@google.com \
--cc=dhsharp@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=teravest@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®