Skip to content

Commit 3d6ff0e

Browse files
lyan3lijinxia
authored andcommitted
tools: acrntrace: save trace data file under current dir by default
Current implementation save trace data files on tmpfs by default, acrntrace would use up all the physical mem, which can affect system functioning. This commit changes default location for trace data file to current dir, and removes the codes for space reservation, which is not necessary. Signed-off-by: Yan, Like <like.yan@intel.com> Reviewed-by: Eddie Dong <eddie.dong@intel.com> Reviewed-by: Li, Fei1 <fei1.li@intel.com>
1 parent 3abfdba commit 3d6ff0e

File tree

4 files changed

+10
-42
lines changed

4 files changed

+10
-42
lines changed

tools/acrntrace/README.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Usage
1313
*****
1414

1515
The ``acrntrace`` tool runs on the Service OS (SOS) to capture trace data and
16-
output to trace file under ``/tmp/acrntrace`` with raw (binary) data format.
16+
output to trace file under ``./acrntrace`` with raw (binary) data format.
1717

1818
Options:
1919

@@ -96,7 +96,7 @@ data to your linux system, and running the analysis tool.
9696
will exit automatically when the free storage space on the disk is less than
9797
reserved space. Reserved space on the disk is configurable through '-r'.
9898

99-
Trace files are created under ``/tmp/acrntrace/``, with a
99+
Trace files are created under ``./acrntrace/``, with a
100100
date-time-based directory name such as ``20171115-101605``
101101

102102
#. When done, stop a running ``acrntrace``, with:
@@ -120,7 +120,7 @@ data to your linux system, and running the analysis tool.
120120

121121
.. code-block:: none
122122
123-
# scp -r /tmp/acrntrace/20171115-101605/ \
123+
# scp -r ./acrntrace/20171115-101605/ \
124124
username@hostname:/home/username/trace_data
125125
126126
Replace username and hostname with appropriate values.

tools/acrntrace/acrntrace.c

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@
2222

2323
#include "acrntrace.h"
2424

25-
/* default minimal amount free space (in MB) left on the disk */
26-
static uint64_t disk_reserved = 512;
27-
2825
#define TIMER_ID (128)
2926
static uint32_t timeout = 0;
3027

@@ -47,8 +44,6 @@ static void display_usage(void)
4744
"[Usage] acrntrace [-i] [period in msec] [-ch]\n\n"
4845
"[Options]\n"
4946
"\t-h: print this message\n"
50-
"\t-r: minimal amount (in MB) of free space kept on the disk\n"
51-
"\t before acrntrace stops\n"
5247
"\t-i: period_in_ms: specify polling interval [1-999]\n"
5348
"\t-t: max time to capture trace data (in second)\n"
5449
"\t-c: clear the buffered old data\n");
@@ -109,15 +104,6 @@ static int parse_opt(int argc, char *argv[])
109104
period = ret * 1000;
110105
pr_dbg("Period is %lu\n", period);
111106
break;
112-
case 'r':
113-
ret = atoi(optarg);
114-
if (ret <=0) {
115-
pr_err("'-r' require integer greater than 0\n");
116-
return -EINVAL;
117-
}
118-
disk_reserved = ret;
119-
pr_dbg("Keeping %dMB of space on the disk\n", ret);
120-
break;
121107
case 't':
122108
ret = atoi(optarg);
123109
if (ret <= 0) {
@@ -186,7 +172,6 @@ static int create_trace_file_dir(char *dir)
186172

187173
pr_info("start tracing at %s\n", time_str);
188174

189-
/* Pre-condition: Make sure tmpfs is mounted on /tmp */
190175
if (stat(TRACE_FILE_ROOT, &st)) {
191176
err = mkdir(TRACE_FILE_ROOT, 0644);
192177
if (err) {
@@ -234,24 +219,6 @@ static void reader_fn(param_t * param)
234219

235220
while (1) {
236221
do {
237-
/* Check that filesystem has enough space */
238-
if (fstatvfs(fd, &stat)) {
239-
printf("Fail to get vfs stat.\n");
240-
exiting = 1;
241-
exit(EXIT_FAILURE);
242-
}
243-
244-
freespace = stat.f_frsize * (uint64_t)stat.f_bfree;
245-
freespace >>= 20; /* Convert to MB */
246-
247-
if (freespace <= disk_reserved) {
248-
printf("Disk space limit reached (free space:"
249-
"%luMB, limit %luMB).\n",
250-
freespace, disk_reserved);
251-
exiting = 1;
252-
exit(EXIT_FAILURE);
253-
}
254-
255222
ret = sbuf_write(fd, sbuf);
256223
} while (ret > 0);
257224

tools/acrntrace/acrntrace.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
#define MMAP_SIZE ((TRACE_ELEMENT_SIZE * TRACE_ELEMENT_NUM \
1818
+ PAGE_SIZE - 1) & PAGE_MASK)
1919
*/
20-
#define TRACE_FILE_NAME_LEN 36
21-
#define TRACE_FILE_DIR_LEN (TRACE_FILE_NAME_LEN - 2)
22-
#define TRACE_FILE_ROOT "/tmp/acrntrace/"
20+
#define TRACE_FILE_NAME_LEN 32
21+
#define TRACE_FILE_DIR_LEN (TRACE_FILE_NAME_LEN - 3)
22+
#define TRACE_FILE_ROOT "acrntrace/"
2323
#define DEV_PATH_LEN 18
2424
#define TIME_STR_LEN 16
2525
#define CMD_MAX_LEN 48

tools/acrntrace/sbuf.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <stdio.h>
1111
#include <stdbool.h>
1212
#include "sbuf.h"
13+
#include <errno.h>
1314

1415
static inline bool sbuf_is_empty(shared_buf_t *sbuf)
1516
{
@@ -59,9 +60,9 @@ int sbuf_write(int fd, shared_buf_t *sbuf)
5960

6061
start = (void *)sbuf + SBUF_HEAD_SIZE + sbuf->head;
6162
written = write(fd, start, sbuf->ele_size);
62-
if ( written != sbuf->ele_size) {
63-
printf("Failed to write. Expect written size %d, returned %d\n",
64-
sbuf->ele_size, written);
63+
if (written != sbuf->ele_size) {
64+
printf("Failed to write: ret %d (ele_size %d), errno %d\n",
65+
written, sbuf->ele_size, (written == -1) ? errno : 0);
6566
return -1;
6667
}
6768

0 commit comments

Comments
 (0)