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: remove luo_session_quiesce()

Now that FLB module references are handled dynamically during active
sessions, we can safely remove the luo_session_quiesce() and
luo_session_resume() mechanism.

Link: https://lore.kernel.org/20260327033335.696621-7-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
118c3908 76be9983

+11 -114
+1 -20
kernel/liveupdate/luo_file.c
··· 875 875 return -EINVAL; 876 876 } 877 877 878 - /* 879 - * Ensure the system is quiescent (no active sessions). 880 - * This prevents registering new handlers while sessions are active or 881 - * while deserialization is in progress. 882 - */ 883 - if (!luo_session_quiesce()) 884 - return -EBUSY; 885 - 886 878 down_write(&luo_register_rwlock); 887 879 /* Check for duplicate compatible strings */ 888 880 list_private_for_each_entry(fh_iter, &luo_file_handler_list, list) { ··· 897 905 list_add_tail(&ACCESS_PRIVATE(fh, list), &luo_file_handler_list); 898 906 up_write(&luo_register_rwlock); 899 907 900 - luo_session_resume(); 901 - 902 908 liveupdate_test_register(fh); 903 909 904 910 return 0; 905 911 906 912 err_unlock: 907 913 up_write(&luo_register_rwlock); 908 - luo_session_resume(); 909 914 return err; 910 915 } 911 916 ··· 914 925 * reverses the operations of liveupdate_register_file_handler(). 915 926 * 916 927 * It ensures safe removal by checking that: 917 - * No live update session is currently in progress. 918 928 * No FLB registered with this file handler. 919 929 * 920 930 * If the unregistration fails, the internal test state is reverted. 921 931 * 922 932 * Return: 0 Success. -EOPNOTSUPP when live update is not enabled. -EBUSY A live 923 - * update is in progress, can't quiesce live update or FLB is registred with 924 - * this file handler. 933 + * update is in progress, FLB is registred with this file handler. 925 934 */ 926 935 int liveupdate_unregister_file_handler(struct liveupdate_file_handler *fh) 927 936 { ··· 930 943 931 944 liveupdate_test_unregister(fh); 932 945 933 - if (!luo_session_quiesce()) 934 - goto err_register; 935 - 936 946 down_write(&luo_register_rwlock); 937 947 if (!list_empty(&ACCESS_PRIVATE(fh, flb_list))) 938 948 goto err_unlock; ··· 938 954 up_write(&luo_register_rwlock); 939 955 940 956 module_put(fh->ops->owner); 941 - luo_session_resume(); 942 957 943 958 return 0; 944 959 945 960 err_unlock: 946 961 up_write(&luo_register_rwlock); 947 - luo_session_resume(); 948 - err_register: 949 962 liveupdate_test_register(fh); 950 963 return err; 951 964 }
+10 -49
kernel/liveupdate/luo_flb.c
··· 348 348 struct luo_flb_link *link __free(kfree) = NULL; 349 349 struct liveupdate_flb *gflb; 350 350 struct luo_flb_link *iter; 351 - int err; 352 351 353 352 if (!liveupdate_enabled()) 354 353 return -EOPNOTSUPP; ··· 368 369 if (!link) 369 370 return -ENOMEM; 370 371 371 - /* 372 - * Ensure the system is quiescent (no active sessions). 373 - * This acts as a global lock for registration: no other thread can 374 - * be in this section, and no sessions can be creating/using FDs. 375 - */ 376 - if (!luo_session_quiesce()) 377 - return -EBUSY; 378 - 379 - down_write(&luo_register_rwlock); 372 + guard(rwsem_write)(&luo_register_rwlock); 380 373 381 374 /* Check that this FLB is not already linked to this file handler */ 382 - err = -EEXIST; 383 375 list_for_each_entry(iter, flb_list, list) { 384 376 if (iter->flb == flb) 385 - goto err_resume; 377 + return -EEXIST; 386 378 } 387 379 388 380 /* ··· 381 391 * is registered 382 392 */ 383 393 if (!private->users) { 384 - if (WARN_ON(!list_empty(&private->list))) { 385 - err = -EINVAL; 386 - goto err_resume; 387 - } 394 + if (WARN_ON(!list_empty(&private->list))) 395 + return -EINVAL; 388 396 389 - if (luo_flb_global.count == LUO_FLB_MAX) { 390 - err = -ENOSPC; 391 - goto err_resume; 392 - } 397 + if (luo_flb_global.count == LUO_FLB_MAX) 398 + return -ENOSPC; 393 399 394 400 /* Check that compatible string is unique in global list */ 395 401 list_private_for_each_entry(gflb, &luo_flb_global.list, private.list) { 396 402 if (!strcmp(gflb->compatible, flb->compatible)) 397 - goto err_resume; 403 + return -EEXIST; 398 404 } 399 405 400 406 list_add_tail(&private->list, &luo_flb_global.list); ··· 401 415 private->users++; 402 416 link->flb = flb; 403 417 list_add_tail(&no_free_ptr(link)->list, flb_list); 404 - up_write(&luo_register_rwlock); 405 - luo_session_resume(); 406 418 407 419 return 0; 408 - 409 - err_resume: 410 - up_write(&luo_register_rwlock); 411 - luo_session_resume(); 412 - return err; 413 420 } 414 421 415 422 /** ··· 418 439 * the FLB is removed from the global registry and the reference to its 419 440 * owner module (acquired during registration) is released. 420 441 * 421 - * Context: This function ensures the session is quiesced (no active FDs 422 - * being created) during the update. It is typically called from a 423 - * subsystem's module exit function. 442 + * Context: It is typically called from a subsystem's module exit function. 424 443 * Return: 0 on success. 425 444 * -EOPNOTSUPP if live update is disabled. 426 - * -EBUSY if the live update session is active and cannot be quiesced. 427 445 * -ENOENT if the FLB was not found in the file handler's list. 428 446 */ 429 447 int liveupdate_unregister_flb(struct liveupdate_file_handler *fh, ··· 434 458 if (!liveupdate_enabled()) 435 459 return -EOPNOTSUPP; 436 460 437 - /* 438 - * Ensure the system is quiescent (no active sessions). 439 - * This acts as a global lock for unregistration. 440 - */ 441 - if (!luo_session_quiesce()) 442 - return -EBUSY; 443 - 444 - down_write(&luo_register_rwlock); 461 + guard(rwsem_write)(&luo_register_rwlock); 445 462 446 463 /* Find and remove the link from the file handler's list */ 447 464 list_for_each_entry(iter, flb_list, list) { ··· 447 478 } 448 479 449 480 if (err) 450 - goto err_resume; 481 + return err; 451 482 452 483 private->users--; 453 484 /* ··· 459 490 luo_flb_global.count--; 460 491 } 461 492 462 - up_write(&luo_register_rwlock); 463 - luo_session_resume(); 464 - 465 493 return 0; 466 - 467 - err_resume: 468 - up_write(&luo_register_rwlock); 469 - luo_session_resume(); 470 - return err; 471 494 } 472 495 473 496 /**
-2
kernel/liveupdate/luo_internal.h
··· 85 85 int __init luo_session_setup_incoming(void *fdt); 86 86 int luo_session_serialize(void); 87 87 int luo_session_deserialize(void); 88 - bool luo_session_quiesce(void); 89 - void luo_session_resume(void); 90 88 91 89 int luo_preserve_file(struct luo_file_set *file_set, u64 token, int fd); 92 90 void luo_file_unpreserve_files(struct luo_file_set *file_set);
-43
kernel/liveupdate/luo_session.c
··· 602 602 return err; 603 603 } 604 604 605 - /** 606 - * luo_session_quiesce - Ensure no active sessions exist and lock session lists. 607 - * 608 - * Acquires exclusive write locks on both incoming and outgoing session lists. 609 - * It then validates no sessions exist in either list. 610 - * 611 - * This mechanism is used during file handler un/registration to ensure that no 612 - * sessions are currently using the handler, and no new sessions can be created 613 - * while un/registration is in progress. 614 - * 615 - * This prevents registering new handlers while sessions are active or 616 - * while deserialization is in progress. 617 - * 618 - * Return: 619 - * true - System is quiescent (0 sessions) and locked. 620 - * false - Active sessions exist. The locks are released internally. 621 - */ 622 - bool luo_session_quiesce(void) 623 - { 624 - down_write(&luo_session_global.incoming.rwsem); 625 - down_write(&luo_session_global.outgoing.rwsem); 626 - 627 - if (luo_session_global.incoming.count || 628 - luo_session_global.outgoing.count) { 629 - up_write(&luo_session_global.outgoing.rwsem); 630 - up_write(&luo_session_global.incoming.rwsem); 631 - return false; 632 - } 633 - 634 - return true; 635 - } 636 - 637 - /** 638 - * luo_session_resume - Unlock session lists and resume normal activity. 639 - * 640 - * Releases the exclusive locks acquired by a successful call to 641 - * luo_session_quiesce(). 642 - */ 643 - void luo_session_resume(void) 644 - { 645 - up_write(&luo_session_global.outgoing.rwsem); 646 - up_write(&luo_session_global.incoming.rwsem); 647 - }