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

Add New Memory Access Tests and Update Documentation for test-tlb #32

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
32 changes: 23 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
test-tlb: test-tlb.c
gcc -g -Wall -O test-tlb.c -o test-tlb -lm
# Compiler and flags
CC = gcc
CFLAGS = -Wall -O2 -std=c11
TARGET = test-tlb

run: test-tlb
for i in 4k 8k 16k 32k 64k 128k 256k 512k 1M 2M 4M 6M 8M 16M 32M 64M 128M 256M ; do echo "$$i:"; ./test-tlb -H $$i 64; ./test-tlb $$i 64 ; ./test-tlb -Hr $$i 64; ./test-tlb -r $$i 64; done
# Targets and rules
all: $(TARGET)

#
# 15485863 is a random prime number that is used as a index into
# the 128MB array. 15485863*4=61943452
odd-case: test-tlb
./test-tlb 128M 61943452
$(TARGET): test-tlb.o
$(CC) $(CFLAGS) -o $(TARGET) test-tlb.o

test-tlb.o: test-tlb.c
$(CC) $(CFLAGS) -c test-tlb.c

run: $(TARGET)
@echo "Running tests with various sizes and strides..."
@for size in 1M 2M 4M 8M 16M 32M 64M 128M 256M; do \
for stride in 4k 8k 16k 32k 64k 128k 256k 512k 1M; do \
echo "Running with size $$size and stride $$stride:"; \
./$(TARGET) $$size $$stride; \
done; \
done

clean:
rm -f $(TARGET) test-tlb.o
113 changes: 0 additions & 113 deletions README

This file was deleted.

80 changes: 80 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Test-TLB

`test-tlb` is a performance testing program designed to evaluate memory access patterns and the efficiency of the Translation Lookaside Buffer (TLB). The application measures the time it takes to access memory under different configurations and provides insights into TLB performance.

## Table of Contents
- [Features](#features)
- [Installation](#installation)
- [Usage](#usage)
- [Tests](#tests)
- [Makefile Usage](#makefile-usage)
- [Known Issues](#known-issues)

## Features

- **Huge Pages**: Option to use huge pages for the test.
- **Random List**: Option to use random access patterns.
- **Timing Measurement**: Measures access time in nanoseconds and estimates cycle time.

## Installation

1. **Clone the Repository**:
```sh
git clone https://github.com/torvalds/test-tlb.git
cd test-tlb
```

2. **Build the Project**:
```sh
make
```

This command will compile the `test-tlb` application and create the `test-tlb` executable.

## Usage

The `test-tlb` program operates with two main parameters: memory size and stride length. To run the test, use the following command:

```sh
./test-tlb <size> <stride>
```

- `<size>`: The size of the memory area. Examples: `4k`, `16k`, `1M`, etc.
- `<stride>`: The stride length for memory access. Examples: `4k`, `16k`, `512k`, etc.

### Options

- `-H`: Use huge pages for the test.
- `-r`: Use a random access pattern.

Example commands:

```sh
./test-tlb 4k 4k
./test-tlb -H 4k 4k
./test-tlb -r 16k 16k
```

## Tests

The `Makefile` includes commands for running various tests with different memory sizes and stride lengths. To execute all tests, use:

```sh
make run
```

This command will run a series of tests with predefined configurations and print the results to the console.

## Makefile Usage

- **Build**: `make` will compile the `test-tlb` target.
- **Clean**: `make clean` will remove all build artifacts.
- **Run Tests**: `make run` will execute the defined tests and display results.

## Known Issues

- **Huge Pages**: The `MADV_HUGEPAGE` and `MADV_NOHUGEPAGE` macros may not be defined on all systems. This may lead to compatibility issues on systems where these features are not supported.

## License

This project is licensed under the [GPLv2](LICENSE.txt).
Loading