diff options
author | Peter Zijlstra <peterz@infradead.org> | 2024-12-20 15:31:19 +0100 |
---|---|---|
committer | Peter Zijlstra <peterz@infradead.org> | 2024-12-20 15:31:19 +0100 |
commit | c2db11a750fb626d0d04f2dc76e548a1f07617df (patch) | |
tree | 01c899b2a06855633ae991f2064242f976987809 /lib | |
parent | 63a48181fbcddefe5fb4c6618938bb64c543945b (diff) | |
parent | 4a077914578183ec397ad09f7156a357e00e5d72 (diff) |
Merge branch 'locking/urgent'
Sync with urgent -- avoid conflicts.
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/alloc_tag.c | 36 | ||||
-rw-r--r-- | lib/kunit/user_alloc.c | 2 | ||||
-rw-r--r-- | lib/stackdepot.c | 10 | ||||
-rw-r--r-- | lib/stackinit_kunit.c | 1 | ||||
-rw-r--r-- | lib/test_firmware.c | 2 |
5 files changed, 34 insertions, 17 deletions
diff --git a/lib/alloc_tag.c b/lib/alloc_tag.c index 2414a7ee7ec77..35f7560a309a4 100644 --- a/lib/alloc_tag.c +++ b/lib/alloc_tag.c @@ -189,26 +189,34 @@ void pgalloc_tag_split(struct folio *folio, int old_order, int new_order) } } -void pgalloc_tag_copy(struct folio *new, struct folio *old) +void pgalloc_tag_swap(struct folio *new, struct folio *old) { - union pgtag_ref_handle handle; - union codetag_ref ref; - struct alloc_tag *tag; + union pgtag_ref_handle handle_old, handle_new; + union codetag_ref ref_old, ref_new; + struct alloc_tag *tag_old, *tag_new; - tag = pgalloc_tag_get(&old->page); - if (!tag) + tag_old = pgalloc_tag_get(&old->page); + if (!tag_old) + return; + tag_new = pgalloc_tag_get(&new->page); + if (!tag_new) return; - if (!get_page_tag_ref(&new->page, &ref, &handle)) + if (!get_page_tag_ref(&old->page, &ref_old, &handle_old)) return; + if (!get_page_tag_ref(&new->page, &ref_new, &handle_new)) { + put_page_tag_ref(handle_old); + return; + } + + /* swap tags */ + __alloc_tag_ref_set(&ref_old, tag_new); + update_page_tag_ref(handle_old, &ref_old); + __alloc_tag_ref_set(&ref_new, tag_old); + update_page_tag_ref(handle_new, &ref_new); - /* Clear the old ref to the original allocation tag. */ - clear_page_tag_ref(&old->page); - /* Decrement the counters of the tag on get_new_folio. */ - alloc_tag_sub(&ref, folio_size(new)); - __alloc_tag_ref_set(&ref, tag); - update_page_tag_ref(handle, &ref); - put_page_tag_ref(handle); + put_page_tag_ref(handle_old); + put_page_tag_ref(handle_new); } static void shutdown_mem_profiling(bool remove_file) diff --git a/lib/kunit/user_alloc.c b/lib/kunit/user_alloc.c index ae935df09a5eb..46951be018be2 100644 --- a/lib/kunit/user_alloc.c +++ b/lib/kunit/user_alloc.c @@ -114,4 +114,4 @@ unsigned long kunit_vm_mmap(struct kunit *test, struct file *file, } EXPORT_SYMBOL_GPL(kunit_vm_mmap); -MODULE_IMPORT_NS(EXPORTED_FOR_KUNIT_TESTING); +MODULE_IMPORT_NS("EXPORTED_FOR_KUNIT_TESTING"); diff --git a/lib/stackdepot.c b/lib/stackdepot.c index 5ed34cc963fc3..245d5b4166999 100644 --- a/lib/stackdepot.c +++ b/lib/stackdepot.c @@ -630,7 +630,15 @@ depot_stack_handle_t stack_depot_save_flags(unsigned long *entries, prealloc = page_address(page); } - raw_spin_lock_irqsave(&pool_lock, flags); + if (in_nmi()) { + /* We can never allocate in NMI context. */ + WARN_ON_ONCE(can_alloc); + /* Best effort; bail if we fail to take the lock. */ + if (!raw_spin_trylock_irqsave(&pool_lock, flags)) + goto exit; + } else { + raw_spin_lock_irqsave(&pool_lock, flags); + } printk_deferred_enter(); /* Try to find again, to avoid concurrently inserting duplicates. */ diff --git a/lib/stackinit_kunit.c b/lib/stackinit_kunit.c index c14c6f8e6308d..c40818ec9c180 100644 --- a/lib/stackinit_kunit.c +++ b/lib/stackinit_kunit.c @@ -212,6 +212,7 @@ static noinline void test_ ## name (struct kunit *test) \ static noinline DO_NOTHING_TYPE_ ## which(var_type) \ do_nothing_ ## name(var_type *ptr) \ { \ + OPTIMIZER_HIDE_VAR(ptr); \ /* Will always be true, but compiler doesn't know. */ \ if ((unsigned long)ptr > 0x2) \ return DO_NOTHING_RETURN_ ## which(ptr); \ diff --git a/lib/test_firmware.c b/lib/test_firmware.c index bcb32cbff1885..211222e63328f 100644 --- a/lib/test_firmware.c +++ b/lib/test_firmware.c @@ -27,7 +27,7 @@ #include <linux/vmalloc.h> #include <linux/efi_embedded_fw.h> -MODULE_IMPORT_NS(TEST_FIRMWARE); +MODULE_IMPORT_NS("TEST_FIRMWARE"); #define TEST_FIRMWARE_NAME "test-firmware.bin" #define TEST_FIRMWARE_NUM_REQS 4 |