Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

liveupdate: defer file handler module refcounting to active sessions

Stop pinning modules indefinitely upon file handler registration.
Instead, dynamically increment the module reference count only when a live
update session actively uses the file handler (e.g., during preservation
or deserialization), and release it when the session ends.

This allows modules providing live update handlers to be gracefully
unloaded when no live update is in progress.

Link: https://lore.kernel.org/20260327033335.696621-11-pasha.tatashin@soleen.com
Signed-off-by: Pasha Tatashin <pasha.tatashin@soleen.com>
Reviewed-by: Pratyush Yadav (Google) <pratyush@kernel.org>
Cc: David Matlack <dmatlack@google.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Pasha Tatashin and committed by
Andrew Morton
68750e82 2ab7207e

+12 -12
+12 -12
kernel/liveupdate/luo_file.c
··· 291 291 down_read(&luo_register_rwlock); 292 292 list_private_for_each_entry(fh, &luo_file_handler_list, list) { 293 293 if (fh->ops->can_preserve(fh, file)) { 294 - err = 0; 294 + if (try_module_get(fh->ops->owner)) 295 + err = 0; 295 296 break; 296 297 } 297 298 } ··· 305 304 err = xa_insert(&luo_preserved_files, luo_get_id(fh, file), 306 305 file, GFP_KERNEL); 307 306 if (err) 308 - goto err_free_files_mem; 307 + goto err_module_put; 309 308 310 309 err = luo_flb_file_preserve(fh); 311 310 if (err) ··· 341 340 luo_flb_file_unpreserve(fh); 342 341 err_erase_xa: 343 342 xa_erase(&luo_preserved_files, luo_get_id(fh, file)); 343 + err_module_put: 344 + module_put(fh->ops->owner); 344 345 err_free_files_mem: 345 346 luo_free_files_mem(file_set); 346 347 err_fput: ··· 385 382 args.private_data = luo_file->private_data; 386 383 luo_file->fh->ops->unpreserve(&args); 387 384 luo_flb_file_unpreserve(luo_file->fh); 385 + module_put(luo_file->fh->ops->owner); 388 386 389 387 xa_erase(&luo_preserved_files, 390 388 luo_get_id(luo_file->fh, luo_file->file)); ··· 677 673 678 674 luo_file->fh->ops->finish(&args); 679 675 luo_flb_file_finish(luo_file->fh); 676 + module_put(luo_file->fh->ops->owner); 680 677 } 681 678 682 679 /** ··· 815 810 down_read(&luo_register_rwlock); 816 811 list_private_for_each_entry(fh, &luo_file_handler_list, list) { 817 812 if (!strcmp(fh->compatible, file_ser[i].compatible)) { 818 - handler_found = true; 813 + if (try_module_get(fh->ops->owner)) 814 + handler_found = true; 819 815 break; 820 816 } 821 817 } ··· 830 824 } 831 825 832 826 luo_file = kzalloc_obj(*luo_file); 833 - if (!luo_file) 827 + if (!luo_file) { 828 + module_put(fh->ops->owner); 834 829 return -ENOMEM; 830 + } 835 831 836 832 luo_file->fh = fh; 837 833 luo_file->file = NULL; ··· 894 886 } 895 887 } 896 888 897 - /* Pin the module implementing the handler */ 898 - if (!try_module_get(fh->ops->owner)) { 899 - err = -EAGAIN; 900 - goto err_unlock; 901 - } 902 - 903 889 INIT_LIST_HEAD(&ACCESS_PRIVATE(fh, flb_list)); 904 890 INIT_LIST_HEAD(&ACCESS_PRIVATE(fh, list)); 905 891 list_add_tail(&ACCESS_PRIVATE(fh, list), &luo_file_handler_list); ··· 923 921 guard(rwsem_write)(&luo_register_rwlock); 924 922 luo_flb_unregister_all(fh); 925 923 list_del(&ACCESS_PRIVATE(fh, list)); 926 - 927 - module_put(fh->ops->owner); 928 924 }