Skip to content

Commit 1ea9d33

Browse files
committed
Merge tag 'mm-stable-2022-12-17-2' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Pull more mm updates from Andrew Morton: - A few late-breaking minor fixups - Two minor feature patches which were awkwardly dependent on mm-nonmm. I need to set up a new branch to handle such things. * tag 'mm-stable-2022-12-17-2' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: MAINTAINERS: zram: zsmalloc: Add an additional co-maintainer mm/kmemleak: use %pK to display kernel pointers in backtrace mm: use stack_depot for recording kmemleak's backtrace maple_tree: update copyright dates for test code maple_tree: fix mas_find_rev() comment mm/gup_test: free memory allocated via kvcalloc() using kvfree()
2 parents 4f292c4 + 8b77759 commit 1ea9d33

File tree

7 files changed

+42
-28
lines changed

7 files changed

+42
-28
lines changed

CREDITS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,6 +1439,10 @@ N: Justin Guyett
14391439
14401440
D: via-rhine net driver hacking
14411441

1442+
N: Nitin Gupta
1443+
1444+
D: zsmalloc memory allocator and zram block device driver
1445+
14421446
N: Danny ter Haar
14431447
14441448
D: /proc/cpuinfo, reboot on panic , kernel pre-patch tester ;)

MAINTAINERS

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23055,8 +23055,7 @@ F: drivers/media/pci/zoran/
2305523055

2305623056
ZRAM COMPRESSED RAM BLOCK DEVICE DRVIER
2305723057
M: Minchan Kim <[email protected]>
23058-
M: Nitin Gupta <[email protected]>
23059-
R: Sergey Senozhatsky <[email protected]>
23058+
M: Sergey Senozhatsky <[email protected]>
2306023059
2306123060
S: Maintained
2306223061
F: Documentation/admin-guide/blockdev/zram.rst
@@ -23069,8 +23068,7 @@ F: drivers/tty/serial/zs.*
2306923068

2307023069
ZSMALLOC COMPRESSED SLAB MEMORY ALLOCATOR
2307123070
M: Minchan Kim <[email protected]>
23072-
M: Nitin Gupta <[email protected]>
23073-
R: Sergey Senozhatsky <[email protected]>
23071+
M: Sergey Senozhatsky <[email protected]>
2307423072
2307523073
S: Maintained
2307623074
F: Documentation/mm/zsmalloc.rst

lib/Kconfig.debug

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,7 @@ config DEBUG_KMEMLEAK
728728
select STACKTRACE if STACKTRACE_SUPPORT
729729
select KALLSYMS
730730
select CRC32
731+
select STACKDEPOT
731732
help
732733
Say Y here if you want to enable the memory leak
733734
detector. The memory allocation/freeing is traced in a way

lib/maple_tree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6062,7 +6062,7 @@ void *mas_find_rev(struct ma_state *mas, unsigned long min)
60626062
if (mas->index < min)
60636063
return NULL;
60646064

6065-
/* Retries on dead nodes handled by mas_next_entry */
6065+
/* Retries on dead nodes handled by mas_prev_entry */
60666066
return mas_prev_entry(mas, min);
60676067
}
60686068
EXPORT_SYMBOL_GPL(mas_find_rev);

mm/gup_test.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ static inline void pin_longterm_test_stop(void)
214214
if (pin_longterm_test_nr_pages)
215215
unpin_user_pages(pin_longterm_test_pages,
216216
pin_longterm_test_nr_pages);
217-
kfree(pin_longterm_test_pages);
217+
kvfree(pin_longterm_test_pages);
218218
pin_longterm_test_pages = NULL;
219219
pin_longterm_test_nr_pages = 0;
220220
}
@@ -255,7 +255,7 @@ static inline int pin_longterm_test_start(unsigned long arg)
255255
fast = !!(args.flags & PIN_LONGTERM_TEST_FLAG_USE_FAST);
256256

257257
if (!fast && mmap_read_lock_killable(current->mm)) {
258-
kfree(pages);
258+
kvfree(pages);
259259
return -EINTR;
260260
}
261261

mm/kmemleak.c

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
#include <linux/mutex.h>
8080
#include <linux/rcupdate.h>
8181
#include <linux/stacktrace.h>
82+
#include <linux/stackdepot.h>
8283
#include <linux/cache.h>
8384
#include <linux/percpu.h>
8485
#include <linux/memblock.h>
@@ -159,8 +160,7 @@ struct kmemleak_object {
159160
u32 checksum;
160161
/* memory ranges to be scanned inside an object (empty for all) */
161162
struct hlist_head area_list;
162-
unsigned long trace[MAX_TRACE];
163-
unsigned int trace_len;
163+
depot_stack_handle_t trace_handle;
164164
unsigned long jiffies; /* creation timestamp */
165165
pid_t pid; /* pid of the current task */
166166
char comm[TASK_COMM_LEN]; /* executable name */
@@ -346,19 +346,22 @@ static void print_unreferenced(struct seq_file *seq,
346346
struct kmemleak_object *object)
347347
{
348348
int i;
349+
unsigned long *entries;
350+
unsigned int nr_entries;
349351
unsigned int msecs_age = jiffies_to_msecs(jiffies - object->jiffies);
350352

353+
nr_entries = stack_depot_fetch(object->trace_handle, &entries);
351354
warn_or_seq_printf(seq, "unreferenced object 0x%08lx (size %zu):\n",
352-
object->pointer, object->size);
355+
object->pointer, object->size);
353356
warn_or_seq_printf(seq, " comm \"%s\", pid %d, jiffies %lu (age %d.%03ds)\n",
354-
object->comm, object->pid, object->jiffies,
355-
msecs_age / 1000, msecs_age % 1000);
357+
object->comm, object->pid, object->jiffies,
358+
msecs_age / 1000, msecs_age % 1000);
356359
hex_dump_object(seq, object);
357360
warn_or_seq_printf(seq, " backtrace:\n");
358361

359-
for (i = 0; i < object->trace_len; i++) {
360-
void *ptr = (void *)object->trace[i];
361-
warn_or_seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
362+
for (i = 0; i < nr_entries; i++) {
363+
void *ptr = (void *)entries[i];
364+
warn_or_seq_printf(seq, " [<%pK>] %pS\n", ptr, ptr);
362365
}
363366
}
364367

@@ -370,15 +373,16 @@ static void print_unreferenced(struct seq_file *seq,
370373
static void dump_object_info(struct kmemleak_object *object)
371374
{
372375
pr_notice("Object 0x%08lx (size %zu):\n",
373-
object->pointer, object->size);
376+
object->pointer, object->size);
374377
pr_notice(" comm \"%s\", pid %d, jiffies %lu\n",
375-
object->comm, object->pid, object->jiffies);
378+
object->comm, object->pid, object->jiffies);
376379
pr_notice(" min_count = %d\n", object->min_count);
377380
pr_notice(" count = %d\n", object->count);
378381
pr_notice(" flags = 0x%x\n", object->flags);
379382
pr_notice(" checksum = %u\n", object->checksum);
380383
pr_notice(" backtrace:\n");
381-
stack_trace_print(object->trace, object->trace_len, 4);
384+
if (object->trace_handle)
385+
stack_depot_print(object->trace_handle);
382386
}
383387

384388
/*
@@ -591,12 +595,18 @@ static struct kmemleak_object *find_and_remove_object(unsigned long ptr, int ali
591595
return object;
592596
}
593597

594-
/*
595-
* Save stack trace to the given array of MAX_TRACE size.
596-
*/
597-
static int __save_stack_trace(unsigned long *trace)
598+
static noinline depot_stack_handle_t set_track_prepare(void)
598599
{
599-
return stack_trace_save(trace, MAX_TRACE, 2);
600+
depot_stack_handle_t trace_handle;
601+
unsigned long entries[MAX_TRACE];
602+
unsigned int nr_entries;
603+
604+
if (!kmemleak_initialized)
605+
return 0;
606+
nr_entries = stack_trace_save(entries, ARRAY_SIZE(entries), 3);
607+
trace_handle = stack_depot_save(entries, nr_entries, GFP_NOWAIT);
608+
609+
return trace_handle;
600610
}
601611

602612
/*
@@ -653,7 +663,7 @@ static void __create_object(unsigned long ptr, size_t size,
653663
}
654664

655665
/* kernel backtrace */
656-
object->trace_len = __save_stack_trace(object->trace);
666+
object->trace_handle = set_track_prepare();
657667

658668
raw_spin_lock_irqsave(&kmemleak_lock, flags);
659669

@@ -692,7 +702,6 @@ static void __create_object(unsigned long ptr, size_t size,
692702
rb_link_node(&object->rb_node, rb_parent, link);
693703
rb_insert_color(&object->rb_node, is_phys ? &object_phys_tree_root :
694704
&object_tree_root);
695-
696705
list_add_tail_rcu(&object->object_list, &object_list);
697706
out:
698707
raw_spin_unlock_irqrestore(&kmemleak_lock, flags);
@@ -1091,7 +1100,7 @@ void __ref kmemleak_update_trace(const void *ptr)
10911100
}
10921101

10931102
raw_spin_lock_irqsave(&object->lock, flags);
1094-
object->trace_len = __save_stack_trace(object->trace);
1103+
object->trace_handle = set_track_prepare();
10951104
raw_spin_unlock_irqrestore(&object->lock, flags);
10961105

10971106
put_object(object);
@@ -2084,6 +2093,7 @@ void __init kmemleak_init(void)
20842093
if (kmemleak_error)
20852094
return;
20862095

2096+
stack_depot_init();
20872097
jiffies_min_age = msecs_to_jiffies(MSECS_MIN_AGE);
20882098
jiffies_scan_wait = msecs_to_jiffies(SECS_SCAN_WAIT * 1000);
20892099

tools/testing/radix-tree/maple.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// SPDX-License-Identifier: GPL-2.0+
22
/*
3-
* maple_tree.c: Userspace shim for maple tree test-suite
4-
* Copyright (c) 2018 Liam R. Howlett <[email protected]>
3+
* maple_tree.c: Userspace testing for maple tree test-suite
4+
* Copyright (c) 2018-2022 Oracle Corporation
5+
* Author: Liam R. Howlett <[email protected]>
56
*
67
* Any tests that require internal knowledge of the tree or threads and other
78
* difficult to handle in kernel tests.

0 commit comments

Comments
 (0)