Skip to content
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

blkalgn: add support #5128

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

dkruces
Copy link

@dkruces dkruces commented Oct 29, 2024

Add blkalgn support to trace block I/Os and report Granularity and Alignment.


Note: I chose not to create a separate Makefile (for now) as mentioned in the README. This first approach is to gather feedback on the tool and code.

A previous version of the tool using bcc/Python was 'introduced' here:
#4813

Output example:

sudo blkalgn --disk nvme0n1 --ops Write --trace
Tracing block device I/O... Hit Ctrl-C to end.
DISK       OPS        FLAGS    LEN      LBA                   PID        COMM             ALGN
nvme0n1    0x801      Write    131072   0                     0          fio              131072
nvme0n1    0x801      Write    131072   0                     0          fio              131072
nvme0n1    0x801      Write    131072   0                     0          fio              131072
nvme0n1    0x801      Write    131072   0                     0          fio              131072
nvme0n1    0x801      Write    131072   0                     0          fio              131072
nvme0n1    0x801      Write    131072   0                     0          fio              131072
nvme0n1    0x801      Write    131072   0                     0          fio              131072
nvme0n1    0x801      Write    131072   0                     0          fio              131072
nvme0n1    0x801      Write    131072   0                     0          fio              131072

{...}

nvme0n1    0x801      Write    4096     0                     0          fio              4096
nvme0n1    0x801      Write    4096     0                     0          fio              4096
nvme0n1    0x801      Write    4096     0                     0          fio              4096
^C

I/O Granularity Histogram for Device nvme0n1
Total I/Os: 187
     sector        : count     distribution
        8          : 12       |****                                    |
        64         : 25       |**********                              |
        128        : 50       |********************                    |
        256        : 100      |****************************************|

I/O Alignment Histogram for Device nvme0n1
     bytes               : count    distribution
         0 -> 1          : 0        |                                        |
         2 -> 3          : 0        |                                        |
         4 -> 7          : 0        |                                        |
         8 -> 15         : 0        |                                        |
        16 -> 31         : 0        |                                        |
        32 -> 63         : 0        |                                        |
        64 -> 127        : 0        |                                        |
       128 -> 255        : 0        |                                        |
       256 -> 511        : 0        |                                        |
       512 -> 1023       : 0        |                                        |
      1024 -> 2047       : 0        |                                        |
      2048 -> 4095       : 0        |                                        |
      4096 -> 8191       : 12       |****                                    |
      8192 -> 16383      : 0        |                                        |
     16384 -> 32767      : 0        |                                        |
     32768 -> 65535      : 25       |**********                              |
     65536 -> 131071     : 50       |********************                    |
    131072 -> 262143     : 100      |****************************************|
    ```
    
    Test case for the above results
    
    ```sh
sudo fio --name=deterministic_io_test --size=128K --bs=128K --rw=randwrite --numjobs=1 --iodepth=1 --filename=/dev/nvme0n1 --loop 100
sudo fio --name=deterministic_io_test --size=64K --bs=64K --rw=randwrite --numjobs=1 --iodepth=1 --filename=/dev/nvme0n1 --loop 50
sudo fio --name=deterministic_io_test --size=32K --bs=32K --rw=randwrite --numjobs=1 --iodepth=1 --filename=/dev/nvme0n1 --loop 25
sudo fio --name=deterministic_io_test --size=512 --bs=512 --rw=randwrite --numjobs=1 --iodepth=1 --filename=/dev/nvme0n1 --loop 12

Help output:

sudo blkalgn --help
Usage: blkalgn [OPTION...]
BPF blkalgn application.

It traces block I/O operations and reports I/O granularity and
alignment.

USAGE: ./blkalgn [-d <disk>] [-o <ops>] [-j <output>] [-t] [-v]

 -d, --disk=DISK            Trace this disk only
 -j, --json=JSON            Output to JSON
 -o, --ops=OPS              Trace this ops only
 -t, --trace                Enable trace output
 -v, --verbose              Verbose debug output
 -?, --help                 Give this help list
     --usage                Give a short usage message
 -V, --version              Print program version

Mandatory or optional arguments to long options are also mandatory or optional
for any corresponding short options.

Report bugs to <[email protected]>.

The tool can trace I/Os, filter by device and/or block operation, and generate an output file to JSON with captured information. I think, because of the use of a JSON external library, it requires to have a separate Makefile as stated in the README section. Can you provide feedback on this? Note that it also depends on math.h for log2l in user space.

Add blkalgn support to trace block I/Os and report Granularity and
Alignment.

Update libbpf-tools/Makefile to support math.h and json-c/json.h
headers for blkalgn.

Update fedora Dockerfile to include json-c development package support.

Signed-off-by: Daniel Gomez <[email protected]>
@dkruces
Copy link
Author

dkruces commented Oct 30, 2024

Changes:

  • Add json-c development headers to Fedora Dockerfile.
  • Add blkalgn to clean Makefile target.
  • Rename *_LEN defines and cleanup unused event fields.

@dkruces
Copy link
Author

dkruces commented Nov 14, 2024

Kindly ping. Any feedback on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant