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

scst_mem: Port to Linux kernel v6.7 #205

Merged
merged 1 commit into from
Dec 27, 2023
Merged
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
54 changes: 42 additions & 12 deletions scst/src/scst_mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ static atomic_t sgv_releases_on_hiwmk_failed = ATOMIC_INIT(0);
static atomic_t sgv_other_total_alloc = ATOMIC_INIT(0);
#endif

#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 7, 0)
static struct shrinker sgv_shrinker;
#else
static struct shrinker *sgv_shrinker;
#endif

static struct kmem_cache *sgv_pool_cachep;

Expand Down Expand Up @@ -1711,8 +1715,43 @@ void sgv_pool_del(struct sgv_pool *pool)
}
EXPORT_SYMBOL_GPL(sgv_pool_del);

static int __init scst_sgv_shrinker_init(void)
{
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 7, 0)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 12, 0)
sgv_shrinker.count_objects = sgv_can_be_shrunk;
sgv_shrinker.scan_objects = sgv_scan_shrink;
#else
sgv_shrinker.shrink = sgv_shrink;
#endif
sgv_shrinker.seeks = DEFAULT_SEEKS;

return register_shrinker(&sgv_shrinker, "scst-sgv");
#else
sgv_shrinker = shrinker_alloc(0, "scst-sgv");
if (unlikely(!sgv_shrinker))
return -ENOMEM;

sgv_shrinker->count_objects = sgv_can_be_shrunk;
sgv_shrinker->scan_objects = sgv_scan_shrink;

shrinker_register(sgv_shrinker);

return 0;
#endif
}

static void scst_sgv_shrinker_exit(void)
{
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 7, 0)
unregister_shrinker(&sgv_shrinker);
#else
shrinker_free(sgv_shrinker);
#endif
}

/* Both parameters in pages */
int scst_sgv_pools_init(unsigned long mem_hwmark, unsigned long mem_lwmark)
int __init scst_sgv_pools_init(unsigned long mem_hwmark, unsigned long mem_lwmark)
{
int res = 0, i;

Expand Down Expand Up @@ -1791,15 +1830,7 @@ int scst_sgv_pools_init(unsigned long mem_hwmark, unsigned long mem_lwmark)
goto out_free_per_cpu_dma;
}

#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 12, 0)
sgv_shrinker.count_objects = sgv_can_be_shrunk;
sgv_shrinker.scan_objects = sgv_scan_shrink;
#else
sgv_shrinker.shrink = sgv_shrink;
#endif
sgv_shrinker.seeks = DEFAULT_SEEKS;

res = register_shrinker(&sgv_shrinker, "scst-sgv");
res = scst_sgv_shrinker_init();
if (unlikely(res))
goto out_free_per_cpu_dma;

Expand Down Expand Up @@ -1841,7 +1872,7 @@ void scst_sgv_pools_deinit(void)

TRACE_ENTRY();

unregister_shrinker(&sgv_shrinker);
scst_sgv_shrinker_exit();

sgv_pool_destroy(sgv_dma_pool_main);
for (i = 0; i < nr_cpu_ids; i++)
Expand Down Expand Up @@ -1870,7 +1901,6 @@ void scst_sgv_pools_deinit(void)
return;
}


static ssize_t sgv_sysfs_stat_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
{
Expand Down
2 changes: 1 addition & 1 deletion scst/src/scst_mem.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ static inline struct scatterlist *sgv_pool_sg(struct sgv_pool_obj *obj)
return obj->sg_entries;
}

int scst_sgv_pools_init(unsigned long mem_hwmark, unsigned long mem_lwmark);
int __init scst_sgv_pools_init(unsigned long mem_hwmark, unsigned long mem_lwmark);
void scst_sgv_pools_deinit(void);


Expand Down