summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2024-05-25 15:10:33 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2024-05-25 15:10:33 -0700
commit9b62e02e63363f5678d5598ee7372064301587f7 (patch)
tree1f79f1b1506b579e0721d6a522d90809f5360b47 /lib
parenta0db36ed571397df9a3f507ee19913a74d4b97a5 (diff)
parent90e823498881fb8a91d83e9a8eed87c8c3ff2176 (diff)
downloadlwn-9b62e02e63363f5678d5598ee7372064301587f7.tar.gz
lwn-9b62e02e63363f5678d5598ee7372064301587f7.zip
Merge tag 'mm-hotfixes-stable-2024-05-25-09-13' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Pull misc fixes from Andrew Morton: "16 hotfixes, 11 of which are cc:stable. A few nilfs2 fixes, the remainder are for MM: a couple of selftests fixes, various singletons fixing various issues in various parts" * tag 'mm-hotfixes-stable-2024-05-25-09-13' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: mm/ksm: fix possible UAF of stable_node mm/memory-failure: fix handling of dissolved but not taken off from buddy pages mm: /proc/pid/smaps_rollup: avoid skipping vma after getting mmap_lock again nilfs2: fix potential hang in nilfs_detach_log_writer() nilfs2: fix unexpected freezing of nilfs_segctor_sync() nilfs2: fix use-after-free of timer for log writer thread selftests/mm: fix build warnings on ppc64 arm64: patching: fix handling of execmem addresses selftests/mm: compaction_test: fix bogus test success and reduce probability of OOM-killer invocation selftests/mm: compaction_test: fix incorrect write of zero to nr_hugepages selftests/mm: compaction_test: fix bogus test success on Aarch64 mailmap: update email address for Satya Priya mm/huge_memory: don't unpoison huge_zero_folio kasan, fortify: properly rename memintrinsics lib: add version into /proc/allocinfo output mm/vmalloc: fix vmalloc which may return null if called with __GFP_NOFAIL
Diffstat (limited to 'lib')
-rw-r--r--lib/alloc_tag.c47
1 files changed, 32 insertions, 15 deletions
diff --git a/lib/alloc_tag.c b/lib/alloc_tag.c
index 531dbe2f5456..11ed973ac359 100644
--- a/lib/alloc_tag.c
+++ b/lib/alloc_tag.c
@@ -16,47 +16,60 @@ EXPORT_SYMBOL(_shared_alloc_tag);
DEFINE_STATIC_KEY_MAYBE(CONFIG_MEM_ALLOC_PROFILING_ENABLED_BY_DEFAULT,
mem_alloc_profiling_key);
+struct allocinfo_private {
+ struct codetag_iterator iter;
+ bool print_header;
+};
+
static void *allocinfo_start(struct seq_file *m, loff_t *pos)
{
- struct codetag_iterator *iter;
+ struct allocinfo_private *priv;
struct codetag *ct;
loff_t node = *pos;
- iter = kzalloc(sizeof(*iter), GFP_KERNEL);
- m->private = iter;
- if (!iter)
+ priv = kzalloc(sizeof(*priv), GFP_KERNEL);
+ m->private = priv;
+ if (!priv)
return NULL;
+ priv->print_header = (node == 0);
codetag_lock_module_list(alloc_tag_cttype, true);
- *iter = codetag_get_ct_iter(alloc_tag_cttype);
- while ((ct = codetag_next_ct(iter)) != NULL && node)
+ priv->iter = codetag_get_ct_iter(alloc_tag_cttype);
+ while ((ct = codetag_next_ct(&priv->iter)) != NULL && node)
node--;
- return ct ? iter : NULL;
+ return ct ? priv : NULL;
}
static void *allocinfo_next(struct seq_file *m, void *arg, loff_t *pos)
{
- struct codetag_iterator *iter = (struct codetag_iterator *)arg;
- struct codetag *ct = codetag_next_ct(iter);
+ struct allocinfo_private *priv = (struct allocinfo_private *)arg;
+ struct codetag *ct = codetag_next_ct(&priv->iter);
(*pos)++;
if (!ct)
return NULL;
- return iter;
+ return priv;
}
static void allocinfo_stop(struct seq_file *m, void *arg)
{
- struct codetag_iterator *iter = (struct codetag_iterator *)m->private;
+ struct allocinfo_private *priv = (struct allocinfo_private *)m->private;
- if (iter) {
+ if (priv) {
codetag_lock_module_list(alloc_tag_cttype, false);
- kfree(iter);
+ kfree(priv);
}
}
+static void print_allocinfo_header(struct seq_buf *buf)
+{
+ /* Output format version, so we can change it. */
+ seq_buf_printf(buf, "allocinfo - version: 1.0\n");
+ seq_buf_printf(buf, "# <size> <calls> <tag info>\n");
+}
+
static void alloc_tag_to_text(struct seq_buf *out, struct codetag *ct)
{
struct alloc_tag *tag = ct_to_alloc_tag(ct);
@@ -71,13 +84,17 @@ static void alloc_tag_to_text(struct seq_buf *out, struct codetag *ct)
static int allocinfo_show(struct seq_file *m, void *arg)
{
- struct codetag_iterator *iter = (struct codetag_iterator *)arg;
+ struct allocinfo_private *priv = (struct allocinfo_private *)arg;
char *bufp;
size_t n = seq_get_buf(m, &bufp);
struct seq_buf buf;
seq_buf_init(&buf, bufp, n);
- alloc_tag_to_text(&buf, iter->ct);
+ if (priv->print_header) {
+ print_allocinfo_header(&buf);
+ priv->print_header = false;
+ }
+ alloc_tag_to_text(&buf, priv->iter.ct);
seq_commit(m, seq_buf_used(&buf));
return 0;
}