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

Registrating struct_ops types from modules #598

Closed
wants to merge 57 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
ed47cb2
selftests/bpf: Convert CHECK macros to ASSERT_* macros in bpf_iter
yuranpereira Oct 28, 2023
cb3c6a5
selftests/bpf: Add malloc failure checks in bpf_iter
yuranpereira Oct 28, 2023
3cda077
selftests/bpf: fix RELEASE=1 build for tc_opts
anakryiko Nov 2, 2023
7bcc07d
selftests/bpf: satisfy compiler by having explicit return in btf test
anakryiko Nov 2, 2023
2e74aef
bpf: derive smin/smax from umin/max bounds
anakryiko Nov 2, 2023
f188765
bpf: derive smin32/smax32 from umin32/umax32 bounds
anakryiko Nov 2, 2023
f404ef3
bpf: derive subreg bounds from full bounds when upper 32 bits are con…
anakryiko Nov 2, 2023
6533e0a
bpf: add special smin32/smax32 derivation from 64-bit bounds
anakryiko Nov 2, 2023
3d6940d
bpf: improve deduction of 64-bit bounds from 32-bit bounds
anakryiko Nov 2, 2023
558c06e
bpf: try harder to deduce register bounds from different numeric domains
anakryiko Nov 2, 2023
b929d49
bpf: drop knowledge-losing __reg_combine_{32,64}_into_{64,32} logic
anakryiko Nov 2, 2023
cdeb5da
bpf: rename is_branch_taken reg arguments to prepare for the second one
anakryiko Nov 2, 2023
fc3615d
bpf: generalize is_branch_taken() to work with two registers
anakryiko Nov 2, 2023
dd2a2cc
bpf: move is_branch_taken() down
anakryiko Nov 2, 2023
171de12
bpf: generalize is_branch_taken to handle all conditional jumps in on…
anakryiko Nov 2, 2023
761a9e5
bpf: unify 32-bit and 64-bit is_branch_taken logic
anakryiko Nov 2, 2023
4c61728
bpf: prepare reg_set_min_max for second set of registers
anakryiko Nov 2, 2023
9a14d62
bpf: generalize reg_set_min_max() to handle two sets of two registers
anakryiko Nov 2, 2023
e68ed64
Merge branch 'bpf-register-bounds-logic-and-testing-improvements'
Nov 2, 2023
3f1f234
selftests/bpf: Use value with enough-size when updating per-cpu map
Nov 1, 2023
ff38534
selftests/bpf: Export map_update_retriable()
Nov 1, 2023
57688b2
selftsets/bpf: Retry map update for non-preallocated per-cpu map
Nov 1, 2023
d221681
Merge branch 'selftests/bpf: Fixes for map_percpu_stats test'
anakryiko Nov 2, 2023
c4be30a
selftests/bpf: Consolidate VIRTIO/9P configs in config.vm file
chantra Oct 31, 2023
7d188e7
bpf: Add __bpf_dynptr_data* for in kernel use
liu-song-6 Nov 7, 2023
e1e43a4
bpftool: Fix prog object type in manpage
sm00th Nov 3, 2023
042c604
bpf: Factor out helper check_reg_const_str()
liu-song-6 Nov 7, 2023
47696c0
selftests/bpf: Disable CONFIG_DEBUG_INFO_REDUCED in config.aarch64
roxell Nov 3, 2023
24a46ed
bpf: Introduce KF_ARG_PTR_TO_CONST_STR
liu-song-6 Nov 7, 2023
ef3b159
bpf, lpm: Fix check prefixlen before walking trie
florianl Nov 5, 2023
a933398
Merge branch 'bpf: __bpf_dynptr_data* and __str annotation'
anakryiko Nov 7, 2023
b4e59c1
libbpf: Fix potential uninitialized tail padding with LIBBPF_OPTS_RESET
Nov 7, 2023
dae6c6b
veristat: add ability to sort by stat's absolute value
anakryiko Nov 8, 2023
0ca98fc
veristat: add ability to filter top N results
anakryiko Nov 8, 2023
3815f89
bpf: replace register_is_const() with is_reg_const()
shunghsiyu Nov 8, 2023
8a53f8c
bpf: Add KF_RCU flag to bpf_refcount_acquire_impl
davemarchevsky Nov 7, 2023
315bbb9
selftests/bpf: Add test passing MAYBE_NULL reg to bpf_refcount_acquire
davemarchevsky Nov 7, 2023
cf1ec20
bpf: Use bpf_mem_free_rcu when bpf_obj_dropping non-refcounted nodes
davemarchevsky Nov 7, 2023
a7b6ab9
bpf: Move GRAPH_{ROOT,NODE}_MASK macros into btf_field_type enum
davemarchevsky Nov 7, 2023
6eba51e
bpf: Mark direct ld of stashed bpf_{rb,list}_node as non-owning ref
davemarchevsky Nov 7, 2023
3975f7e
selftests/bpf: Test bpf_refcount_acquire of node obtained via direct ld
davemarchevsky Nov 7, 2023
6f101db
Merge branch 'allow-bpf_refcount_acquire-of-mapval-obtained-via-direc…
Nov 9, 2023
e80742d
bpf: Use named fields for certain bpf uapi structs
Nov 4, 2023
260b428
adding ci files
d-e-s-o Nov 9, 2023
f9c5be0
bpf: refactory struct_ops type initialization to a function.
ThinkerYzu1 Nov 6, 2023
47b3bbd
bpf: get type information with BPF_ID_LIST
ThinkerYzu1 Nov 6, 2023
ef2df6d
bpf, net: introduce bpf_struct_ops_desc.
ThinkerYzu1 Nov 6, 2023
03b144b
bpf: add struct_ops_tab to btf.
ThinkerYzu1 Nov 6, 2023
2f8e562
bpf: make struct_ops_map support btfs other than btf_vmlinux.
ThinkerYzu1 Nov 6, 2023
f041ada
bpf: lookup struct_ops types from a given module BTF.
ThinkerYzu1 Nov 6, 2023
9ebb865
bpf: pass attached BTF to the bpf_struct_ops subsystem
ThinkerYzu1 Nov 6, 2023
7551a87
bpf: hold module for bpf_struct_ops_map.
ThinkerYzu1 Nov 6, 2023
cdc4d38
bpf: validate value_type
ThinkerYzu1 Nov 6, 2023
78d2b82
bpf, net: switch to dynamic registration
ThinkerYzu1 Nov 6, 2023
7ef6acb
libbpf: Find correct module BTFs for struct_ops maps and progs.
ThinkerYzu1 Nov 6, 2023
76a9d58
bpf: export btf_ctx_access to modules.
ThinkerYzu1 Nov 6, 2023
3bdc24c
selftests/bpf: test case for register_bpf_struct_ops().
ThinkerYzu1 Nov 6, 2023
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
202 changes: 202 additions & 0 deletions .github/scripts/veristat-compare.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
#!/usr/bin/env python3

# This script reads a CSV file produced by the following invocation:
#
# veristat --emit file,prog,verdict,states \
# --output-format csv \
# --compare ...
#
# And produces a markdown summary for the file.
# The summary is printed to standard output and appended to a file
# pointed to by GITHUB_STEP_SUMMARY variable.
#
# Script exits with return code 1 if there are new failures in the
# veristat results.
#
# For testing purposes invoke as follows:
#
# GITHUB_STEP_SUMMARY=/dev/null python3 veristat-compare.py test.csv
#
# File format (columns):
# 0. file_name
# 1. prog_name
# 2. verdict_base
# 3. verdict_comp
# 4. verdict_diff
# 5. total_states_base
# 6. total_states_comp
# 7. total_states_diff
#
# Records sample:
# file-a,a,success,failure,MISMATCH,12,12,+0 (+0.00%)
# file-b,b,success,success,MATCH,67,67,+0 (+0.00%)
#
# For better readability suffixes '_OLD' and '_NEW'
# are used instead of '_base' and '_comp' for variable
# names etc.

import io
import os
import sys
import csv
import logging
import argparse
from functools import reduce
from dataclasses import dataclass

TRESHOLD_PCT = 0

HEADERS = ['file_name', 'prog_name', 'verdict_base', 'verdict_comp',
'verdict_diff', 'total_states_base', 'total_states_comp',
'total_states_diff']

FILE = 0
PROG = 1
VERDICT_OLD = 2
VERDICT_NEW = 3
STATES_OLD = 5
STATES_NEW = 6

# Given a table row, compute relative increase in the number of
# processed states.
def compute_diff(v):
old = int(v[STATES_OLD]) if v[STATES_OLD] != 'N/A' else 0
new = int(v[STATES_NEW]) if v[STATES_NEW] != 'N/A' else 0
if old == 0:
return 1
return (new - old) / old

@dataclass
class VeristatInfo:
table: list
changes: bool
new_failures: bool

# Read CSV table expecting the above described format.
# Return VeristatInfo instance.
def parse_table(csv_filename):
new_failures = False
changes = False
table = []

with open(csv_filename, newline='') as file:
reader = csv.reader(file)
headers = next(reader)
if headers != HEADERS:
raise Exception(f'Unexpected table header for {filename}: {headers}')

for v in reader:
add = False
verdict = v[VERDICT_NEW]
diff = compute_diff(v)

if v[VERDICT_OLD] != v[VERDICT_NEW]:
changes = True
add = True
verdict = f'{v[VERDICT_OLD]} -> {v[VERDICT_NEW]}'
if v[VERDICT_NEW] == 'failure':
new_failures = True
verdict += ' (!!)'

if abs(diff * 100) > TRESHOLD_PCT:
changes = True
add = True

if not add:
continue

diff_txt = '{:+.1f} %'.format(diff * 100)
table.append([v[FILE], v[PROG], verdict, diff_txt])

return VeristatInfo(table=table,
changes=changes,
new_failures=new_failures)

def format_table(headers, rows, html_mode):
def decorate(val, width):
s = str(val)
if html_mode:
s = s.replace(' -> ', ' → ');
s = s.replace(' (!!)', ' :bangbang: ');
return s.ljust(width)

column_widths = list(reduce(lambda acc, row: map(max, map(len, row), acc),
rows,
map(len, headers)))

with io.StringIO() as out:
def print_row(row):
out.write('| ')
out.write(' | '.join(map(decorate, row, column_widths)))
out.write(' |\n')

print_row(headers)

out.write('|')
out.write('|'.join(map(lambda w: '-' * (w + 2), column_widths)))
out.write('|\n')

for row in rows:
print_row(row)

return out.getvalue()

def format_section_name(info):
if info.new_failures:
return 'There are new veristat failures'
if info.changes:
return 'There are changes in verification performance'
return 'No changes in verification performance'

SUMMARY_HEADERS = ['File', 'Program', 'Verdict', 'States Diff (%)']

def format_html_summary(info):
section_name = format_section_name(info)
if not info.table:
return f'# {section_name}\n'

table = format_table(SUMMARY_HEADERS, info.table, True)
return f'''
# {section_name}

<details>
<summary>Click to expand</summary>

{table}
</details>
'''.lstrip()

def format_text_summary(info):
section_name = format_section_name(info)
table = format_table(SUMMARY_HEADERS, info.table, False)
if not info.table:
return f'# {section_name}\n'

return f'''
# {section_name}

{table}
'''.lstrip()

def main(compare_csv_filename, summary_filename):
info = parse_table(compare_csv_filename)
sys.stdout.write(format_text_summary(info))
with open(summary_filename, 'a') as f:
f.write(format_html_summary(info))

if info.new_failures:
return 1

return 0

if __name__ == '__main__':
parser = argparse.ArgumentParser(
description="""Print veristat comparison output as markdown step summary"""
)
parser.add_argument('filename')
args = parser.parse_args()
summary_filename = os.getenv('GITHUB_STEP_SUMMARY')
if not summary_filename:
logging.error('GITHUB_STEP_SUMMARY environment variable is not set')
sys.exit(1)
sys.exit(main(args.filename, summary_filename))
22 changes: 22 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: "lint"

on:
pull_request:
push:
branches:
- master

jobs:
shellcheck:
# This workflow gets injected into other Linux repositories, but we don't
# want it to run there.
if: ${{ github.repository == 'kernel-patches/vmtest' }}
name: ShellCheck
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
env:
SHELLCHECK_OPTS: --severity=warning --exclude=SC1091
Loading
Loading