Skip to content

DLPX-78888 [Backport of DLPX-78812 to 6.0.12] Disk IO analytics collector not running on aws #74

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 31 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
8049b85
stbtrace can't find input files for package installations, collection…
brad-lewis Nov 19, 2019
247f1cc
Fix backend io collector post 5.x kernel upgrade (#18) (#20)
prashks Dec 6, 2019
b8e0e49
port txg dtrace script to ebpf
brad-lewis Jan 18, 2020
817bc78
Merge pull request #35 from brad-lewis/txg601
brad-lewis Feb 20, 2020
a4646a4
DLPX-69040 [Backport of DLPX-68396 to 6.0.2.0] port metaslab_alloc dt…
Mar 24, 2020
f19c981
DLPX-69162 [Backport of DLPX-69120 6.0.2.0] running estat against zvo…
Apr 9, 2020
e7b1156
stbtrace should have nonzero exit code on failure [Backport of #17 t…
May 11, 2020
fff5d57
commas in the output of keys in estat [Backport of #22 to 6.0.3.0] (#41)
May 11, 2020
9cf16a2
Compilation failures due to fentry issue [Backport of #33 to 6.0.3.0]…
May 14, 2020
607e52f
Switch to Python 3 [Backport of #9 to 6.0.3.0] (#43)
May 19, 2020
8e746fa
[Backport of DLPX-68397 to 6.0.3.0] need nfs threads to replace dtrac…
May 22, 2020
c27002d
Fix ZPL Collectors after ZFS changes to sync flags and include files …
brad-lewis Dec 6, 2019
c817b30
Fixes for estat usage and arg parsing error messages (#26)
gllghr Jan 10, 2020
e57bac9
Use copy of bcc_helper from performance-diagnositics
gllghr Jan 10, 2020
d80a17d
ZIL fixes
gllghr Jan 14, 2020
aba6e7f
Throughput values are not normalized
brad-lewis Jan 3, 2020
7835d1f
Invalid mem errors when using latest BCC
gllghr Feb 20, 2020
1e722e3
Add arc_prefetch script. (#34)
brad-lewis Mar 13, 2020
43b0a65
DLPX-72430 Estat zil fails to run because of unknown types (#50)
brad-lewis Oct 26, 2020
ccd9920
DLPX-72556 estat warning messages (#52)
brad-lewis Nov 2, 2020
2c79d81
Update estat iscsi, zvol, and zpl scripts. (#55)
brad-lewis Feb 3, 2021
a860fe3
Merge branch 'brad-lewis-estat67' into 6.0/stage
brad-lewis Feb 4, 2021
f0bb551
estat zil script compilation error on 6.1
brad-lewis Feb 23, 2021
b095412
estat zil script always reports an average of 10 allocations
brad-lewis Feb 23, 2021
8d5620b
DLPX-75711 [Backport of DLPX-75405 to 6.0.9.0] nfs_threads script sho…
May 19, 2021
ac43e68
DLPX-75470 estat zpl and arc_prefetch scripts need znode parameter (#…
brad-lewis Jun 11, 2021
3f98846
TOOL-11951 [Backport of TOOL-11731] performance-diagnostics: build-de…
pzakha Aug 3, 2021
fa44f67
DLPX-72683 [Backport of DLPX-72683 to 6.0.12.0] estat utility's help …
brad-lewis Dec 9, 2021
3d0e3f2
DLPX-77845 [Backport of DLPX-77532 to 6.0.12.0] The iscsi estat scrip…
brad-lewis Dec 9, 2021
9c65516
estat backend-io script complains about missing blk_start_request kpr…
mr-t-73 Dec 9, 2021
8b15573
DLPX-78888 [Backport of DLPX-78812 to 6.0.12] Disk IO analytics colle…
brad-lewis Dec 20, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/scripts/flake8_stbtrace.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#/bin/bash
#
# Copyright (c) 2020 by Delphix. All rights reserved.
#
# SPDX-License-Identifier: GPL-2.0-or-later
#

#
# This provides flake8 linting for the various stbtrace templates. It uses
# stbtrace with the '--bcc' flag to produce and print Python code, and then
# runs flake8 against that.
#

set -o pipefail

function die() {
echo "$(basename "$0"): $*" >&2
exit 1
}

prgms=$(find ./bpf/stbtrace -name '*.st' | xargs basename --suffix='.st') ||
die "Failed to generate list of stbtrace programs"

for prgm in $prgms; do
echo "Checking stbtrace program $prgm..."
./cmd/stbtrace.py $prgm --bcc >/tmp/$prgm.py ||
die "Failed to generate python source"
flake8 /tmp/$prgm.py --show-source || die "flake8 errors found in" \
"'bpf/stbtrace/$prgm.st'. Line numbers in error messages" \
"correspond to the output of './cmd/stbtrace.py $prgm --bcc'"
done

exit 0
4 changes: 2 additions & 2 deletions .github/workflows/flake8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ on: [pull_request, push]
jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 2.7
python-version: 3.6
- name: flake8
run: |
python -m pip install --upgrade pip
pip install flake8
flake8 . --show-source --statistics
./.github/scripts/flake8_stbtrace.sh
10 changes: 4 additions & 6 deletions bpf/estat/backend-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,20 @@
#define READ_STR "read "
#define WRITE_STR "write "
#define OP_NAME_LEN 7
#define DEV_NAME_LEN 8
#define NAME_LENGTH (OP_NAME_LEN + 1)
#define AXIS_LENGTH (DEV_NAME_LEN + 1)
#define AXIS_LENGTH (DISK_NAME_LEN + 1)

// Structure to hold thread local data
typedef struct {
u64 ts;
unsigned int size;
unsigned int cmd_flags;
u32 err;
char device[DEV_NAME_LEN];
char device[DISK_NAME_LEN];
} io_data_t;

BPF_HASH(io_base_data, u64, io_data_t);

// @@ kprobe|blk_start_request|disk_io_start
// @@ kprobe|blk_mq_start_request|disk_io_start
int
disk_io_start(struct pt_regs *ctx, struct request *reqp)
Expand All @@ -40,12 +38,12 @@ disk_io_start(struct pt_regs *ctx, struct request *reqp)
data.ts = bpf_ktime_get_ns();
data.cmd_flags = reqp->cmd_flags;
data.size = reqp->__data_len;
__builtin_memcpy(&data.device, diskp->disk_name, DEV_NAME_LEN);
bpf_probe_read_str(&data.device, DISK_NAME_LEN, diskp->disk_name);
io_base_data.update((u64 *) &reqp, &data);
return (0);
}

// @@ kprobe|blk_account_io_completion|disk_io_done
// @@ kprobe|blk_account_io_done|disk_io_done
int
disk_io_done(struct pt_regs *ctx, struct request *reqp)
{
Expand Down
68 changes: 54 additions & 14 deletions bpf/estat/iscsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@
* SPDX-License-Identifier: GPL-2.0-or-later
*/

/*
* This tracer provides latency and througphput data for the iscsi target
* read and writes. The latency is measured from entering
* iscsit_process_scsi_cmd() to exiting iscsit_target_response(). The
* thread that enters iscsi_process_scsi_cmd() will put an entry on the
* request task queue. This entry will be removed from the queue and
* processed by another thread which calls iscsi_target_response.
* The tracing is performed by three probe functions.
* 1. iscsi_target_start - This function saves a timestamp of the entry
* into iscsit_process_scsi_cmd() hashed by a pointer to the iscssi_cmd.
* 2. iscsi_target_response - This function serves the purpose of moving
* the timestamp saved by iscsi_target_start to a thread id based hash.
* Also the size and direction are stored in the hash since kretprobes
* do not have access to parameters.
* 3. iscsi_target_end - This function retrieves the hashed base data by
* thread id and performs the data aggregation.
*/

#include <uapi/linux/ptrace.h>
#include <linux/bpf_common.h>
#include <uapi/linux/bpf.h>
Expand All @@ -19,23 +37,21 @@

typedef struct {
u64 ts;
u64 flags;
u64 size;
u32 direction;
} iscsi_data_t;


BPF_HASH(iscsi_base_data, u64, iscsi_data_t);
BPF_HASH(iscsi_start_ts, u64, u64);
BPF_HASH(iscsi_base_data, u32, iscsi_data_t);

// @@ kprobe|iscsit_process_scsi_cmd|iscsi_target_start
int
iscsi_target_start(struct pt_regs *ctx, struct iscsi_conn *conn,
struct iscsi_cmd *cmd, struct iscsi_scsi_req *hdr)
{
iscsi_data_t data = {};
data.ts = bpf_ktime_get_ns();
data.flags = hdr->flags;
data.size = hdr->data_length;
iscsi_base_data.update((u64 *) &cmd, &data);
u64 ts = bpf_ktime_get_ns();
iscsi_start_ts.update((u64 *) &cmd, &ts);

return (0);
}
Expand All @@ -55,24 +71,48 @@ aggregate_data(iscsi_data_t *data, u64 ts, char *opstr)
return (0);
}

// @@ kprobe|iscsit_build_rsp_pdu|iscsi_target_end


// @@ kprobe|iscsit_response_queue|iscsi_target_response
int
iscsi_target_end(struct pt_regs *ctx, struct iscsi_cmd *cmd)
iscsi_target_response(struct pt_regs *ctx, struct iscsi_conn *conn, struct iscsi_cmd *cmd, int state)
{
u32 tid = bpf_get_current_pid_tgid();
iscsi_data_t data = {};

u64 *tsp = iscsi_start_ts.lookup((u64 *) &cmd);
if (tsp == 0) {
return (0); // missed issue
}

data.ts = *tsp;
data.size = cmd->se_cmd.data_length;
data.direction = cmd->data_direction;

iscsi_base_data.update(&tid, &data);
iscsi_start_ts.delete((u64 *) &cmd);

return (0);
}

// @@ kretprobe|iscsit_response_queue|iscsi_target_end
int
iscsi_target_end(struct pt_regs *ctx)
{
u64 ts = bpf_ktime_get_ns();
iscsi_data_t *data = iscsi_base_data.lookup((u64 *) &cmd);
u64 delta;
u32 tid = bpf_get_current_pid_tgid();
iscsi_data_t *data = iscsi_base_data.lookup(&tid);

if (data == 0) {
return (0); // missed issue
}

if (data->flags & ISCSI_FLAG_CMD_READ) {
if (data->direction == DMA_FROM_DEVICE) {
aggregate_data(data, ts, READ_STR);
} else if (data->flags & ISCSI_FLAG_CMD_WRITE) {
} else if (data->direction == DMA_TO_DEVICE) {
aggregate_data(data, ts, WRITE_STR);
}
iscsi_base_data.delete((u64 *) &cmd);
iscsi_base_data.delete(&tid);

return (0);
}
141 changes: 141 additions & 0 deletions bpf/estat/metaslab-alloc.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
/*
* Copyright 2020 Delphix. All rights reserved.
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/

#include <sys/metaslab.h>
#include <sys/metaslab_impl.h>
#include <sys/vdev_impl.h>
#include <sys/spa_impl.h>

#define VD_NAME_SIZE 32
typedef struct {
u64 ts;
u64 size;
u64 asize;
u64 alloc_time;
char vd_name[VD_NAME_SIZE];
} data_t;

BPF_HASH(data_map, u32, data_t);

#ifndef OPTARG
#define POOL "domain0"
#else
#define POOL (OPTARG)
#endif

static inline bool
equal_to_pool(char *str)
{
char comparand[sizeof (POOL)];
bpf_probe_read(&comparand, sizeof (comparand), str);
char compare[] = POOL;

for (int i = 0; i < sizeof (comparand); ++i)
if (compare[i] != comparand[i])
return (false);

return (true);
}

// @@ kprobe|metaslab_alloc_dva|metaslab_alloc_dva_entry
int
metaslab_alloc_dva_entry(struct pt_regs *ctx,
spa_t *spa, metaslab_class_t *mc, uint64_t psize)
{
u32 tid = bpf_get_current_pid_tgid();
data_t data = {};

if (!equal_to_pool(spa->spa_name))
return (0);

data.ts = bpf_ktime_get_ns();
data.size = psize;

data_map.update(&tid, &data);

return (0);
}

// @@ kprobe|metaslab_group_alloc|metaslab_group_alloc_entry
int
metaslab_group_alloc_entry(struct pt_regs *ctx,
metaslab_group_t *mg, zio_alloc_list_t *zal, uint64_t asize)
{
u32 tid = bpf_get_current_pid_tgid();
data_t *data = data_map.lookup(&tid);

if (data == NULL || data->ts == 0)
return (0);

data->asize = asize;
data->alloc_time = bpf_ktime_get_ns();

if (mg->mg_vd->vdev_path != NULL) {
bpf_probe_read_str(data->vd_name,
sizeof(data->vd_name), mg->mg_vd->vdev_path);
} else {
bpf_probe_read_str(data->vd_name,
sizeof(data->vd_name), mg->mg_vd->vdev_ops->vdev_op_type);
}

return (0);
}

// @@ kretprobe|metaslab_group_alloc|metaslab_group_alloc_exit
int
metaslab_group_alloc_exit(struct pt_regs *ctx)
{
u32 tid = bpf_get_current_pid_tgid();
data_t *data = data_map.lookup(&tid);
char failure[] = "failure";
char success[] = "success";
char *axis;

if (data == NULL || data->ts == 0)
return (0);

if (PT_REGS_RC(ctx) == -1ULL) {
axis = failure;
} else {
axis = success;
}

AGGREGATE_DATA(data->vd_name, axis,
bpf_ktime_get_ns() - data->ts, data->asize);

data->asize = 0;
data->alloc_time = 0;
data->vd_name[0] = '\0';

return (0);
}

// @@ kretprobe|metaslab_alloc_dva|metaslab_alloc_dva_exit
int
metaslab_alloc_dva_exit(struct pt_regs *ctx,
spa_t *spa, metaslab_class_t *mc, uint64_t psize)
{
u32 tid = bpf_get_current_pid_tgid();
data_t *data = data_map.lookup(&tid);

if (data == NULL || data->ts == 0)
return (0);

if (PT_REGS_RC(ctx) == 0)
return (0);

char name[] = "allocation failures";
char axis = 0;
AGGREGATE_DATA(name, &axis,
bpf_ktime_get_ns() - data->ts, data->size);

data->ts = 0;
data->size = 0;

data_map.delete(&tid);

return (0);
}
Loading