Comment 2 for bug 2046534

Revision history for this message
Chengen Du (chengendu) wrote :

The verification of jammy (5.4.0-171.189) was conducted using a custom approach due to the absence of an InfiniBand environment for testing the patch.
The patch specifically altered the count of mm->mm_users within a function.
To ensure that this modification did not impact the original logic, a kernel module was developed.
The module replicated the content of ib_umem_odp_alloc_child but substituted InfiniBand-related functions with other unaffected custom functions for testing purposes.
===
#include <linux/init.h>
#include <linux/module.h>
#include <linux/sched/mm.h>
#include <linux/slab.h>

MODULE_DESCRIPTION("Test");
MODULE_LICENSE("GPL");

int inner_test(void) {
 return 0;
}

int test(void) {
 int ret;
 char *odp_data = kzalloc(8, GFP_KERNEL);
 if (!odp_data)
  return -ENOMEM;
 if (!mmget_not_zero(current->mm)) {
  ret = -EFAULT;
  goto out_free;
 }

 ret = inner_test();
 if (ret)
  goto out_mmput;
 mmput(current->mm);
 return 0;

out_mmput:
 mmput(current->mm);
out_free:
 kfree(odp_data);
 return ret;
}

static int test_init(void) { return test(); }

static void test_exit(void) {}

module_init(test_init);
module_exit(test_exit);
===

Executing this kernel module allows us to verify that the count of mm_users aligns with expectations, validated through the use of the atomic_read function.