Skip to content

Commit

Permalink
Add softlockup scenario for kdump/Fadump testing
Browse files Browse the repository at this point in the history
KernelCrash_KdumpSoftlockup testcase use source files(softlockup.c
and Makefile).These files added to op-tests framework's directory
"op-test/test_binaries". This testcase activates the kernel panic
on soft lockup and copy softlockup.c and Makefile to /tmp directory
to build kernel module. The command insmod used to insert generated
kernel module(softlockup.ko) into the kernel and verify the dump
file created after kernel panic on soft lockup.

Signed-off-by: Sachin P Bappalige <sachinpb@linux.vnet.ibm.com>
  • Loading branch information
Sachin P Bappalige committed Sep 22, 2023
1 parent 7e75b5a commit 95a55aa
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test_binaries/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
obj-m += softlockup.o

all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules

clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
35 changes: 35 additions & 0 deletions test_binaries/softlockup.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/spinlock.h>

MODULE_LICENSE("GPL");
MODULE_AUTHOR("LIKHITHA");
MODULE_DESCRIPTION("Kernel Module for softlockups");

static spinlock_t my_lock;

int a;

static int __init my_init(void)
{
spin_lock_init(&my_lock);
printk(KERN_INFO "softlockup module: Initialized spinlock\n");

/* Perform critical section operations */
spin_lock(&my_lock);
while (1) {
a+=1;
}
spin_unlock(&my_lock);

return 0;
}

static void __exit my_exit(void)
{
printk(KERN_INFO "Exiting module\n");
}

module_init(my_init);
module_exit(my_exit);
26 changes: 26 additions & 0 deletions testcases/PowerNVDump.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,8 @@ def kernel_crash(self, crash_type="echo_c"):
elif crash_type == "hmc":
self.cv_HMC.run_command("chsysstate -r lpar -m %s -n %s -o dumprestart" %
(self.system_name, self.lpar_name), timeout=300)
elif crash_type == "softlockup":
self.c.pty.sendline("insmod /tmp/softlockup.ko")
done = False
boot_type = BootType.NORMAL
rc = -1
Expand Down Expand Up @@ -1323,6 +1325,29 @@ def runTest(self):
if not obj.update_kernel_cmdline(self.distro, remove_args="fadump=nocma", reboot=True, reboot_cmd=True):
self.fail("KernelArgTest failed to update kernel args")

class KernelCrash_KdumpSoftlockup(PowerNVDump):

'''
This test verifies kdump/fadump after inserting softlockup kernel module.
'''

def runTest(self):
self.setup_test()
# Make sure softlockup related file does not exist
self.c.run_command("cd /tmp; ls -1; rm -rf soft* Makefile", timeout=60)

#copy the source files from test_binaries to /tmp
self.cv_HOST.copy_test_file_to_host("softlockup.c")
self.cv_HOST.copy_test_file_to_host("Makefile")

#compile source files to get kernel modules
self.c.run_command("cd /tmp; make", timeout=60)

#Enable softlockup
self.c.run_command("sysctl -w kernel.softlockup_panic=1")

boot_type = self.kernel_crash(crash_type="softlockup")
self.verify_dump_file(boot_type)

def crash_suite():
s = unittest.TestSuite()
Expand Down Expand Up @@ -1354,5 +1379,6 @@ def crash_suite():
s.addTest(KernelCrash_DisableAll())
s.addTest(SkirootKernelCrash())
s.addTest(OPALCrash_MPIPL())
s.addTest(KernelCrash_KdumpSoftlockup())

return s

0 comments on commit 95a55aa

Please sign in to comment.