Skip to content

Commit

Permalink
Merge tag 'linux-kselftest-next-6.1-rc1-2' of git://git.kernel.org/pu…
Browse files Browse the repository at this point in the history
…b/scm/linux/kernel/git/shuah/linux-kselftest

Pull more Kselftest updates from Shuah Khan:
 "This consists of fixes and improvements to memory-hotplug test and a
  minor spelling fix to ftrace test"

* tag 'linux-kselftest-next-6.1-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest:
  docs: notifier-error-inject: Correct test's name
  selftests/memory-hotplug: Adjust log info for maintainability
  selftests/memory-hotplug: Restore memory before exit
  selftests/memory-hotplug: Add checking after online or offline
  selftests/ftrace: func_event_triggers: fix typo in user message
  • Loading branch information
Linus Torvalds committed Oct 12, 2022
2 parents d3cf405 + 6a24247 commit 661e009
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Documentation/fault-injection/notifier-error-inject.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ For more usage examples
There are tools/testing/selftests using the notifier error injection features
for CPU and memory notifiers.

* tools/testing/selftests/cpu-hotplug/on-off-test.sh
* tools/testing/selftests/memory-hotplug/on-off-test.sh
* tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh
* tools/testing/selftests/memory-hotplug/mem-on-off-test.sh

These scripts first do simple online and offline tests and then do fault
injection tests if notifier error injection module is available.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ run_enable_disable() {
echo $check_disable > $EVENT_ENABLE
done
sleep $SLEEP_TIME
echo " make sure it's still works"
echo " make sure it still works"
test_event_enabled $check_enable_star

reset_ftrace_filter
Expand Down
34 changes: 27 additions & 7 deletions tools/testing/selftests/memory-hotplug/mem-on-off-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,16 @@ offline_memory_expect_fail()
return 0
}

online_all_offline_memory()
{
for memory in `hotpluggable_offline_memory`; do
if ! online_memory_expect_success $memory; then
echo "$FUNCNAME $memory: unexpected fail" >&2
retval=1
fi
done
}

error=-12
priority=0
# Run with default of ratio=2 for Kselftest run
Expand Down Expand Up @@ -197,8 +207,11 @@ echo -e "\t trying to offline $target out of $hotpluggable_num memory block(s):"
for memory in `hotpluggable_online_memory`; do
if [ "$target" -gt 0 ]; then
echo "online->offline memory$memory"
if offline_memory_expect_success $memory; then
if offline_memory_expect_success $memory &>/dev/null; then
target=$(($target - 1))
echo "-> Success"
else
echo "-> Failure"
fi
fi
done
Expand Down Expand Up @@ -257,7 +270,7 @@ prerequisite_extra
echo 0 > $NOTIFIER_ERR_INJECT_DIR/actions/MEM_GOING_OFFLINE/error
for memory in `hotpluggable_online_memory`; do
if [ $((RANDOM % 100)) -lt $ratio ]; then
offline_memory_expect_success $memory
offline_memory_expect_success $memory &>/dev/null
fi
done

Expand All @@ -266,28 +279,35 @@ done
#
echo $error > $NOTIFIER_ERR_INJECT_DIR/actions/MEM_GOING_ONLINE/error
for memory in `hotpluggable_offline_memory`; do
online_memory_expect_fail $memory
if ! online_memory_expect_fail $memory; then
retval=1
fi
done

#
# Online all hot-pluggable memory
#
echo 0 > $NOTIFIER_ERR_INJECT_DIR/actions/MEM_GOING_ONLINE/error
for memory in `hotpluggable_offline_memory`; do
online_memory_expect_success $memory
done
online_all_offline_memory

#
# Test memory hot-remove error handling (online => offline)
#
echo $error > $NOTIFIER_ERR_INJECT_DIR/actions/MEM_GOING_OFFLINE/error
for memory in `hotpluggable_online_memory`; do
if [ $((RANDOM % 100)) -lt $ratio ]; then
offline_memory_expect_fail $memory
if ! offline_memory_expect_fail $memory; then
retval=1
fi
fi
done

echo 0 > $NOTIFIER_ERR_INJECT_DIR/actions/MEM_GOING_OFFLINE/error
/sbin/modprobe -q -r memory-notifier-error-inject

#
# Restore memory before exit
#
online_all_offline_memory

exit $retval

0 comments on commit 661e009

Please sign in to comment.