projects/linux·commit 527eff22

Merge tag 'mm-nonmm-stable-2024-07-21-15-07' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

527eff22 · Linus Torvalds <[email protected]> · 2024-07-21 17:56:22 -07:00

Pull non-MM updates from Andrew Morton:

 - In the series "treewide: Refactor heap related implementation",
   Kuan-Wei Chiu has significantly reworked the min_heap library code
   and has taught bcachefs to use the new more generic implementation.

 - Yury Norov's series "Cleanup cpumask.h inclusion in core headers"
   reworks the cpumask and nodemask headers to make things generally
   more rational.

 - Kuan-Wei Chiu has sent along some maintenance work against our
   sorting library code in the series "lib/sort: Optimizations and
   cleanups".

 - More library maintainance work from Christophe Jaillet in the series
   "Remove usage of the deprecated ida_simple_xx() API".

 - Ryusuke Konishi continues with the nilfs2 fixes and clanups in the
   series "nilfs2: eliminate the call to inode_attach_wb()".

 - Kuan-Ying Lee has some fixes to the gdb scripts in the series "Fix
   GDB command error".

 - Plus the usual shower of singleton patches all over the place. Please
   see the relevant changelogs for details.

* tag 'mm-nonmm-stable-2024-07-21-15-07' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: (98 commits)
  ia64: scrub ia64 from poison.h
  watchdog/perf: properly initialize the turbo mode timestamp and rearm counter
  tsacct: replace strncpy() with strscpy()
  lib/bch.c: use swap() to improve code
  test_bpf: convert comma to semicolon
  init/modpost: conditionally check section mismatch to __meminit*
  init: remove unused __MEMINIT* macros
  nilfs2: Constify struct kobj_type
  nilfs2: avoid undefined behavior in nilfs_cnt32_ge macro
  math: rational: add missing MODULE_DESCRIPTION() macro
  lib/zlib: add missing MODULE_DESCRIPTION() macro
  fs: ufs: add MODULE_DESCRIPTION()
  lib/rbtree.c: fix the example typo
  ocfs2: add bounds checking to ocfs2_check_dir_entry()
  fs: add kernel-doc comments to ocfs2_prepare_orphan_dir()
  coredump: simplify zap_process()
  selftests/fpu: add missing MODULE_DESCRIPTION() macro
  compiler.h: simplify data_race() macro
  build-id: require program headers to be right after ELF header
  resource: add missing MODULE_DESCRIPTION()
  ...
Commit
527eff227d4321c6ea453db1083bc4fdd4d3a3e8
Parents
fbc90c04 · 67856f44

Merge commit. Changes below are compared with the first parent: fbc90c04.

Changes

156 files changed · +1416 −842

FileStatusAddDelContent
MAINTAINERSmodified+2−0View file
arch/powerpc/kernel/vmlinux.lds.Smodified+0−2View file
drivers/fsi/fsi-occ.cmodified+8−9View file
drivers/gpu/drm/i915/gem/i915_gem_execbuffer.cmodified+1−1View file
drivers/md/bcache/alloc.cmodified+47−17View file
drivers/md/bcache/bcache.hmodified+1−1View file
drivers/md/bcache/bset.cmodified+79−45View file
drivers/md/bcache/bset.hmodified+17−23View file
drivers/md/bcache/btree.cmodified+40−29View file
drivers/md/bcache/extents.cmodified+34−19View file
drivers/md/bcache/movinggc.cmodified+31−10View file
drivers/md/bcache/super.cmodified+1−2View file
drivers/md/bcache/sysfs.cmodified+3−1View file
drivers/md/bcache/util.cmodified+1−1View file
drivers/md/bcache/util.hmodified+2−65View file
drivers/md/bcache/writeback.cmodified+8−5View file
drivers/md/dm-vdo/repair.cmodified+10−9View file
drivers/md/dm-vdo/slab-depot.cmodified+7−7View file
drivers/most/core.cmodified+5−5View file
drivers/most/most_cdev.cmodified+3−3View file
drivers/net/wireless/ti/wl1251/acx.hmodified+1−1View file
drivers/scsi/qedf/qedf_main.cmodified+1−1View file
drivers/staging/rtl8723bs/core/rtw_mlme_ext.cmodified+1−1View file
drivers/staging/rtl8723bs/core/rtw_pwrctrl.cmodified+1−1View file
fs/bcachefs/clock.cmodified+38−12View file
fs/bcachefs/clock_types.hmodified+1−1View file
fs/bcachefs/ec.cmodified+51−25View file
fs/bcachefs/ec_types.hmodified+1−1View file
fs/bcachefs/util.cmodified+1−1View file
fs/bcachefs/util.hmodified+2−116View file
fs/coredump.cmodified+7−7View file
fs/nilfs2/segment.cmodified+55−36View file
fs/nilfs2/sysfs.cmodified+3−3View file
fs/ocfs2/dir.cmodified+29−17View file
fs/ocfs2/dlmglue.cmodified+14−14View file
fs/ocfs2/namei.cmodified+2−0View file
fs/ocfs2/ocfs2.hmodified+1−1View file
fs/ocfs2/stack_o2cb.cmodified+1−1View file
fs/ocfs2/stack_user.cmodified+1−1View file
fs/ocfs2/stackglue.hmodified+1−1View file
fs/ocfs2/xattr.cmodified+18−9View file
fs/ufs/super.cmodified+1−0View file
include/asm-generic/vmlinux.lds.hmodified+2−16View file
include/linux/cacheinfo.hmodified+1−1View file
include/linux/cgroup.hmodified+0−1View file
include/linux/clockchips.hmodified+1−1View file
include/linux/compiler.hmodified+2−4View file
include/linux/cpu.hmodified+0−1View file
include/linux/cpu_cooling.hmodified+0−1View file
include/linux/cpu_rmap.hmodified+1−1View file
include/linux/cpumask.hmodified+1−55View file
include/linux/cpumask_types.hadded+66−0View file
include/linux/init.hmodified+9−9View file
include/linux/interrupt.hmodified+1−1View file
include/linux/irqchip/irq-partition-percpu.hmodified+1−1View file
include/linux/jhash.hmodified+3−3View file
include/linux/kernel_stat.hmodified+0−1View file
include/linux/min_heap.hmodified+144−44View file
include/linux/msi.hmodified+1−1View file
include/linux/node.hmodified+0−1View file
include/linux/nvme-fc-driver.hmodified+1−1View file
include/linux/panic.hmodified+5−3View file
include/linux/percpu.hmodified+0−1View file
include/linux/pm_domain.hmodified+1−1View file
include/linux/poison.hmodified+0−6View file
include/linux/profile.hmodified+0−1View file
include/linux/rcupdate.hmodified+0−1View file
include/linux/sched.hmodified+4−3View file
include/linux/seq_file.hmodified+0−1View file
include/linux/soc/apple/rtkit.hmodified+2−2View file
include/linux/stop_machine.hmodified+1−1View file
include/linux/torture.hmodified+1−1View file
include/linux/tracepoint.hmodified+0−1View file
include/linux/workqueue.hmodified+1−1View file
kernel/backtracetest.cmodified+1−0View file
kernel/crash_reserve.cmodified+0−1View file
kernel/events/core.cmodified+15−14View file
kernel/fork.cmodified+4−3View file
kernel/hung_task.cmodified+1−1View file
kernel/panic.cmodified+79−37View file
kernel/resource_kunit.cmodified+1−0View file
kernel/tsacct.cmodified+1−1View file
kernel/watchdog_perf.cmodified+8−3View file
lib/Kconfig.debugmodified+3−1View file
lib/asn1_encoder.cmodified+1−0View file
lib/atomic64_test.cmodified+1−0View file
lib/bch.cmodified+5−15View file
lib/bitfield_kunit.cmodified+1−0View file
lib/buildid.cmodified+14−0View file
lib/checksum_kunit.cmodified+1−0View file
lib/cmdline_kunit.cmodified+1−0View file
lib/dhry_run.cmodified+1−0View file
lib/dump_stack.cmodified+7−2View file
lib/fortify_kunit.cmodified+1−0View file
lib/hashtable_test.cmodified+1−0View file
lib/is_signed_type_kunit.cmodified+1−0View file
lib/math/rational.cmodified+1−0View file
lib/memcpy_kunit.cmodified+1−0View file
lib/overflow_kunit.cmodified+1−0View file
lib/percpu_counter.cmodified+39−5View file
lib/plist.cmodified+39−3View file
lib/rbtree.cmodified+4−4View file
lib/siphash_kunit.cmodified+1−0View file
lib/sort.cmodified+7−7View file
lib/stackinit_kunit.cmodified+1−0View file
lib/test-kstrtox.cmodified+1−0View file
lib/test_bits.cmodified+1−0View file
lib/test_blackhole_dev.cmodified+1−0View file
lib/test_bpf.cmodified+2−2View file
lib/test_firmware.cmodified+1−0View file
lib/test_fpu_glue.cmodified+1−0View file
lib/test_free_pages.cmodified+1−0View file
lib/test_hash.cmodified+1−0View file
lib/test_hexdump.cmodified+1−0View file
lib/test_ida.cmodified+1−0View file
lib/test_kmod.cmodified+1−0View file
lib/test_kprobes.cmodified+2−1View file
lib/test_linear_ranges.cmodified+1−0View file
lib/test_list_sort.cmodified+1−0View file
lib/test_memcat_p.cmodified+1−0View file
lib/test_meminit.cmodified+1−0View file
lib/test_min_heap.cmodified+56−20View file
lib/test_module.cmodified+1−0View file
lib/test_ref_tracker.cmodified+2−1View file
lib/test_sort.cmodified+14−1View file
lib/test_static_key_base.cmodified+1−0View file
lib/test_static_keys.cmodified+1−0View file
lib/test_sysctl.cmodified+1−0View file
lib/test_uuid.cmodified+1−0View file
lib/ts_bm.cmodified+1−0View file
lib/ts_fsm.cmodified+1−0View file
lib/ts_kmp.cmodified+1−0View file
lib/zlib_deflate/deflate_syms.cmodified+1−0View file
net/netfilter/nf_conntrack_core.cmodified+1−1View file
net/tipc/socket.cmodified+1−1View file
samples/kfifo/bytestream-example.cmodified+1−0View file
samples/kfifo/dma-example.cmodified+1−0View file
samples/kfifo/inttype-example.cmodified+1−0View file
samples/kfifo/record-example.cmodified+1−0View file
scripts/checkpatch.plmodified+25−1View file
scripts/decode_stacktrace.shmodified+5−1View file
scripts/gdb/linux/mm.pymodified+14−9View file
scripts/gdb/linux/stackdepot.pymodified+6−2View file
scripts/mod/modpost.cmodified+4−15View file
scripts/spelling.txtmodified+3−0View file
tools/lib/list_sort.cmodified+0−10View file
tools/testing/radix-tree/idr-test.cmodified+1−0View file
tools/testing/radix-tree/maple.cmodified+1−0View file
tools/testing/radix-tree/xarray.cmodified+1−0View file
tools/testing/selftests/filesystems/eventfd/eventfd_test.cmodified+131−5View file
tools/testing/selftests/mqueue/mq_perf_tests.cmodified+4−2View file
tools/testing/selftests/proc/.gitignoremodified+2−0View file
tools/testing/selftests/proc/Makefilemodified+2−0View file
tools/testing/selftests/proc/proc-2-is-kthread.cadded+53−0View file
tools/testing/selftests/proc/proc-empty-vm.cmodified+0−3View file
tools/testing/selftests/proc/proc-self-isnt-kthread.cadded+37−0View file

Only the first 600 diff lines are shown. Download the complete patch.

MAINTAINERS

View file
diff --git a/MAINTAINERS b/MAINTAINERS
index 222c973..a0baccc 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3801,8 +3801,10 @@ F: include/linux/bitmap-str.h
F: include/linux/bitmap.h
F: include/linux/bits.h
F: include/linux/cpumask.h
+F: include/linux/cpumask_types.h
F: include/linux/find.h
F: include/linux/nodemask.h
+F: include/linux/nodemask_types.h
F: include/vdso/bits.h
F: lib/bitmap-str.c
F: lib/bitmap.c

arch/powerpc/kernel/vmlinux.lds.S

View file
diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
index f420df7..7ab4e2f 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -123,8 +123,6 @@ SECTIONS
*/
*(.sfpr);
*(.text.asan.* .text.tsan.*)
- MEM_KEEP(init.text)
- MEM_KEEP(exit.text)
} :text
. = ALIGN(PAGE_SIZE);

drivers/fsi/fsi-occ.c

View file
diff --git a/drivers/fsi/fsi-occ.c b/drivers/fsi/fsi-occ.c
index da35ca9..f7157c1 100644
--- a/drivers/fsi/fsi-occ.c
+++ b/drivers/fsi/fsi-occ.c
@@ -656,17 +656,16 @@ static int occ_probe(struct platform_device *pdev)
rc = of_property_read_u32(dev->of_node, "reg", &reg);
if (!rc) {
/* make sure we don't have a duplicate from dts */
- occ->idx = ida_simple_get(&occ_ida, reg, reg + 1,
- GFP_KERNEL);
+ occ->idx = ida_alloc_range(&occ_ida, reg, reg,
+ GFP_KERNEL);
if (occ->idx < 0)
- occ->idx = ida_simple_get(&occ_ida, 1, INT_MAX,
- GFP_KERNEL);
+ occ->idx = ida_alloc_min(&occ_ida, 1,
+ GFP_KERNEL);
} else {
- occ->idx = ida_simple_get(&occ_ida, 1, INT_MAX,
- GFP_KERNEL);
+ occ->idx = ida_alloc_min(&occ_ida, 1, GFP_KERNEL);
}
} else {
- occ->idx = ida_simple_get(&occ_ida, 1, INT_MAX, GFP_KERNEL);
+ occ->idx = ida_alloc_min(&occ_ida, 1, GFP_KERNEL);
}
platform_set_drvdata(pdev, occ);
@@ -680,7 +679,7 @@ static int occ_probe(struct platform_device *pdev)
rc = misc_register(&occ->mdev);
if (rc) {
dev_err(dev, "failed to register miscdevice: %d\n", rc);
- ida_simple_remove(&occ_ida, occ->idx);
+ ida_free(&occ_ida, occ->idx);
kvfree(occ->buffer);
return rc;
}
@@ -719,7 +718,7 @@ static int occ_remove(struct platform_device *pdev)
else
device_for_each_child(&pdev->dev, NULL, occ_unregister_of_child);
- ida_simple_remove(&occ_ida, occ->idx);
+ ida_free(&occ_ida, occ->idx);
return 0;
}

drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c

View file
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
index 090724f..d54162c 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
@@ -340,7 +340,7 @@ static int eb_create(struct i915_execbuffer *eb)
* Without a 1:1 association between relocation handles and
* the execobject[] index, we instead create a hashtable.
* We size it dynamically based on available memory, starting
- * first with 1:1 assocative hash and scaling back until
+ * first with 1:1 associative hash and scaling back until
* the allocation succeeds.
*
* Later on we use a positive lut_size to indicate we are

drivers/md/bcache/alloc.c

View file
diff --git a/drivers/md/bcache/alloc.c b/drivers/md/bcache/alloc.c
index 48ce750..da50f66 100644
--- a/drivers/md/bcache/alloc.c
+++ b/drivers/md/bcache/alloc.c
@@ -164,40 +164,68 @@ static void bch_invalidate_one_bucket(struct cache *ca, struct bucket *b)
* prio is worth 1/8th of what INITIAL_PRIO is worth.
*/
-#define bucket_prio(b) \
-({ \
- unsigned int min_prio = (INITIAL_PRIO - ca->set->min_prio) / 8; \
- \
- (b->prio - ca->set->min_prio + min_prio) * GC_SECTORS_USED(b); \
-})
+static inline unsigned int new_bucket_prio(struct cache *ca, struct bucket *b)
+{
+ unsigned int min_prio = (INITIAL_PRIO - ca->set->min_prio) / 8;
+
+ return (b->prio - ca->set->min_prio + min_prio) * GC_SECTORS_USED(b);
+}
+
+static inline bool new_bucket_max_cmp(const void *l, const void *r, void *args)
+{
+ struct bucket **lhs = (struct bucket **)l;
+ struct bucket **rhs = (struct bucket **)r;
+ struct cache *ca = args;
+
+ return new_bucket_prio(ca, *lhs) > new_bucket_prio(ca, *rhs);
+}
-#define bucket_max_cmp(l, r) (bucket_prio(l) < bucket_prio(r))
-#define bucket_min_cmp(l, r) (bucket_prio(l) > bucket_prio(r))
+static inline bool new_bucket_min_cmp(const void *l, const void *r, void *args)
+{
+ struct bucket **lhs = (struct bucket **)l;
+ struct bucket **rhs = (struct bucket **)r;
+ struct cache *ca = args;
+
+ return new_bucket_prio(ca, *lhs) < new_bucket_prio(ca, *rhs);
+}
+
+static inline void new_bucket_swap(void *l, void *r, void __always_unused *args)
+{
+ struct bucket **lhs = l, **rhs = r;
+
+ swap(*lhs, *rhs);
+}
static void invalidate_buckets_lru(struct cache *ca)
{
struct bucket *b;
- ssize_t i;
+ const struct min_heap_callbacks bucket_max_cmp_callback = {
+ .less = new_bucket_max_cmp,
+ .swp = new_bucket_swap,
+ };
+ const struct min_heap_callbacks bucket_min_cmp_callback = {
+ .less = new_bucket_min_cmp,
+ .swp = new_bucket_swap,
+ };
- ca->heap.used = 0;
+ ca->heap.nr = 0;
for_each_bucket(b, ca) {
if (!bch_can_invalidate_bucket(ca, b))
continue;
- if (!heap_full(&ca->heap))
- heap_add(&ca->heap, b, bucket_max_cmp);
- else if (bucket_max_cmp(b, heap_peek(&ca->heap))) {
+ if (!min_heap_full(&ca->heap))
+ min_heap_push(&ca->heap, &b, &bucket_max_cmp_callback, ca);
+ else if (!new_bucket_max_cmp(&b, min_heap_peek(&ca->heap), ca)) {
ca->heap.data[0] = b;
- heap_sift(&ca->heap, 0, bucket_max_cmp);
+ min_heap_sift_down(&ca->heap, 0, &bucket_max_cmp_callback, ca);
}
}
- for (i = ca->heap.used / 2 - 1; i >= 0; --i)
- heap_sift(&ca->heap, i, bucket_min_cmp);
+ min_heapify_all(&ca->heap, &bucket_min_cmp_callback, ca);
while (!fifo_full(&ca->free_inc)) {
- if (!heap_pop(&ca->heap, b, bucket_min_cmp)) {
+ if (!ca->heap.nr) {
/*
* We don't want to be calling invalidate_buckets()
* multiple times when it can't do anything
@@ -206,6 +234,8 @@ static void invalidate_buckets_lru(struct cache *ca)
wake_up_gc(ca->set);
return;
}
+ b = min_heap_peek(&ca->heap)[0];
+ min_heap_pop(&ca->heap, &bucket_min_cmp_callback, ca);
bch_invalidate_one_bucket(ca, b);
}

drivers/md/bcache/bcache.h

View file
diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h
index 1d33e40..785b0d9 100644
--- a/drivers/md/bcache/bcache.h
+++ b/drivers/md/bcache/bcache.h
@@ -458,7 +458,7 @@ struct cache {
/* Allocation stuff: */
struct bucket *buckets;
- DECLARE_HEAP(struct bucket *, heap);
+ DEFINE_MIN_HEAP(struct bucket *, cache_heap) heap;
/*
* If nonzero, we know we aren't going to find any buckets to invalidate

drivers/md/bcache/bset.c

View file
diff --git a/drivers/md/bcache/bset.c b/drivers/md/bcache/bset.c
index 463eb13..bd97d86 100644
--- a/drivers/md/bcache/bset.c
+++ b/drivers/md/bcache/bset.c
@@ -54,9 +54,11 @@ void bch_dump_bucket(struct btree_keys *b)
int __bch_count_data(struct btree_keys *b)
{
unsigned int ret = 0;
- struct btree_iter_stack iter;
+ struct btree_iter iter;
struct bkey *k;
+ min_heap_init(&iter.heap, NULL, MAX_BSETS);
+
if (b->ops->is_extents)
for_each_key(b, k, &iter)
ret += KEY_SIZE(k);
@@ -67,9 +69,11 @@ void __bch_check_keys(struct btree_keys *b, const char *fmt, ...)
{
va_list args;
struct bkey *k, *p = NULL;
- struct btree_iter_stack iter;
+ struct btree_iter iter;
const char *err;
+ min_heap_init(&iter.heap, NULL, MAX_BSETS);
+
for_each_key(b, k, &iter) {
if (b->ops->is_extents) {
err = "Keys out of order";
@@ -110,9 +114,9 @@ bug:
static void bch_btree_iter_next_check(struct btree_iter *iter)
{
- struct bkey *k = iter->data->k, *next = bkey_next(k);
+ struct bkey *k = iter->heap.data->k, *next = bkey_next(k);
- if (next < iter->data->end &&
+ if (next < iter->heap.data->end &&
bkey_cmp(k, iter->b->ops->is_extents ?
&START_KEY(next) : next) > 0) {
bch_dump_bucket(iter->b);
@@ -879,12 +883,14 @@ unsigned int bch_btree_insert_key(struct btree_keys *b, struct bkey *k,
unsigned int status = BTREE_INSERT_STATUS_NO_INSERT;
struct bset *i = bset_tree_last(b)->data;
struct bkey *m, *prev = NULL;
- struct btree_iter_stack iter;
+ struct btree_iter iter;
struct bkey preceding_key_on_stack = ZERO_KEY;
struct bkey *preceding_key_p = &preceding_key_on_stack;
BUG_ON(b->ops->is_extents && !KEY_SIZE(k));
+ min_heap_init(&iter.heap, NULL, MAX_BSETS);
+
/*
* If k has preceding key, preceding_key_p will be set to address
* of k's preceding key; otherwise preceding_key_p will be set
@@ -895,9 +901,9 @@ unsigned int bch_btree_insert_key(struct btree_keys *b, struct bkey *k,
else
preceding_key(k, &preceding_key_p);
- m = bch_btree_iter_stack_init(b, &iter, preceding_key_p);
+ m = bch_btree_iter_init(b, &iter, preceding_key_p);
- if (b->ops->insert_fixup(b, k, &iter.iter, replace_key))
+ if (b->ops->insert_fixup(b, k, &iter, replace_key))
return status;
status = BTREE_INSERT_STATUS_INSERT;
@@ -1077,79 +1083,102 @@ struct bkey *__bch_bset_search(struct btree_keys *b, struct bset_tree *t,
/* Btree iterator */
-typedef bool (btree_iter_cmp_fn)(struct btree_iter_set,
- struct btree_iter_set);
+typedef bool (new_btree_iter_cmp_fn)(const void *, const void *, void *);
+
+static inline bool new_btree_iter_cmp(const void *l, const void *r, void __always_unused *args)
+{
+ const struct btree_iter_set *_l = l;
+ const struct btree_iter_set *_r = r;
+
+ return bkey_cmp(_l->k, _r->k) <= 0;
+}
-static inline bool btree_iter_cmp(struct btree_iter_set l,
- struct btree_iter_set r)
+static inline void new_btree_iter_swap(void *iter1, void *iter2, void __always_unused *args)
{
- return bkey_cmp(l.k, r.k) > 0;
+ struct btree_iter_set *_iter1 = iter1;
+ struct btree_iter_set *_iter2 = iter2;
+
+ swap(*_iter1, *_iter2);
}
static inline bool btree_iter_end(struct btree_iter *iter)
{
- return !iter->used;
+ return !iter->heap.nr;
}
void bch_btree_iter_push(struct btree_iter *iter, struct bkey *k,
struct bkey *end)
{
+ const struct min_heap_callbacks callbacks = {
+ .less = new_btree_iter_cmp,
+ .swp = new_btree_iter_swap,
+ };
+
if (k != end)
- BUG_ON(!heap_add(iter,
- ((struct btree_iter_set) { k, end }),
- btree_iter_cmp));
+ BUG_ON(!min_heap_push(&iter->heap,
+ &((struct btree_iter_set) { k, end }),
+ &callbacks,
+ NULL));
}
-static struct bkey *__bch_btree_iter_stack_init(struct btree_keys *b,
- struct btree_iter_stack *iter,
- struct bkey *search,
- struct bset_tree *start)
+static struct bkey *__bch_btree_iter_init(struct btree_keys *b,
+ struct btree_iter *iter,
+ struct bkey *search,
+ struct bset_tree *start)
{
struct bkey *ret = NULL;
- iter->iter.size = ARRAY_SIZE(iter->stack_data);
- iter->iter.used = 0;
+ iter->heap.size = ARRAY_SIZE(iter->heap.preallocated);
+ iter->heap.nr = 0;
#ifdef CONFIG_BCACHE_DEBUG
- iter->iter.b = b;
+ iter->b = b;
#endif
for (; start <= bset_tree_last(b); start++) {
ret = bch_bset_search(b, start, search);
- bch_btree_iter_push(&iter->iter, ret, bset_bkey_last(start->data));
+ bch_btree_iter_push(iter, ret, bset_bkey_last(start->data));
}
return ret;
}
-struct bkey *bch_btree_iter_stack_init(struct btree_keys *b,
- struct btree_iter_stack *iter,
+struct bkey *bch_btree_iter_init(struct btree_keys *b,
+ struct btree_iter *iter,
struct bkey *search)
{
- return __bch_btree_iter_stack_init(b, iter, search, b->set);
+ return __bch_btree_iter_init(b, iter, search, b->set);
}
static inline struct bkey *__bch_btree_iter_next(struct btree_iter *iter,
- btree_iter_cmp_fn *cmp)
+ new_btree_iter_cmp_fn *cmp)
{
struct btree_iter_set b __maybe_unused;
struct bkey *ret = NULL;
+ const struct min_heap_callbacks callbacks = {
+ .less = cmp,
+ .swp = new_btree_iter_swap,
+ };
if (!btree_iter_end(iter)) {
bch_btree_iter_next_check(iter);
- ret = iter->data->k;
- iter->data->k = bkey_next(iter->data->k);
+ ret = iter->heap.data->k;
+ iter->heap.data->k = bkey_next(iter->heap.data->k);
- if (iter->data->k > iter->data->end) {
+ if (iter->heap.data->k > iter->heap.data->end) {
WARN_ONCE(1, "bset was corrupt!\n");
- iter->data->k = iter->data->end;
+ iter->heap.data->k = iter->heap.data->end;
}
- if (iter->data->k == iter->data->end)
- heap_pop(iter, b, cmp);
+ if (iter->heap.data->k == iter->heap.data->end) {
+ if (iter->heap.nr) {
+ b = min_heap_peek(&iter->heap)[0];
+ min_heap_pop(&iter->heap, &callbacks, NULL);
+ }
+ }
else
- heap_sift(iter, 0, cmp);
+ min_heap_sift_down(&iter->heap, 0, &callbacks, NULL);
}
return ret;
@@ -1157,7 +1186,7 @@ static inline struct bkey *__bch_btree_iter_next(struct btree_iter *iter,
struct bkey *bch_btree_iter_next(struct btree_iter *iter)
{
- return __bch_btree_iter_next(iter, btree_iter_cmp);
+ return __bch_btree_iter_next(iter, new_btree_iter_cmp);
}
@@ -1195,16 +1224,18 @@ static void btree_mergesort(struct btree_keys *b, struct bset *out,
struct btree_iter *iter,
bool fixup, bool remove_stale)
{
- int i;
struct bkey *k, *last = NULL;
BKEY_PADDED(k) tmp;
bool (*bad)(struct btree_keys *, const struct bkey *) = remove_stale
? bch_ptr_bad
: bch_ptr_invalid;
+ const struct min_heap_callbacks callbacks = {
+ .less = b->ops->sort_cmp,
+ .swp = new_btree_iter_swap,
+ };
/* Heapify the iterator, using our comparison function */
- for (i = iter->used / 2 - 1; i >= 0; --i)
- heap_sift(iter, i, b->ops->sort_cmp);
+ min_heapify_all(&iter->heap, &callbacks, NULL);
while (!btree_iter_end(iter)) {
if (b->ops->sort_fixup && fixup)
@@ -1293,10 +1324,11 @@ void bch_btree_sort_partial(struct btree_keys *b, unsigned int start,
struct bset_sort_state *state)
{
size_t order = b->page_order, keys = 0;
- struct btree_iter_stack iter;
+ struct btree_iter iter;
int oldsize = bch_count_data(b);
- __bch_btree_iter_stack_init(b, &iter, NULL, &b->set[start]);
+ min_heap_init(&iter.heap, NULL, MAX_BSETS);
+ __bch_btree_iter_init(b, &iter, NULL, &b->set[start]);
if (start) {
unsigned int i;
@@ -1307,7 +1339,7 @@ void bch_btree_sort_partial(struct btree_keys *b, unsigned int start,
order = get_order(__set_bytes(b->set->data, keys));
}
- __btree_sort(b, &iter.iter, start, order, false, state);
+ __btree_sort(b, &iter, start, order, false, state);
EBUG_ON(oldsize >= 0 && bch_count_data(b) != oldsize);
}
@@ -1323,11 +1355,13 @@ void bch_btree_sort_into(struct btree_keys *b, struct btree_keys *new,
struct bset_sort_state *state)
{
uint64_t start_time = local_clock();
- struct btree_iter_stack iter;
+ struct btree_iter iter;
+
+ min_heap_init(&iter.heap, NULL, MAX_BSETS);
- bch_btree_iter_stack_init(b, &iter, NULL);
+ bch_btree_iter_init(b, &iter, NULL);
- btree_mergesort(b, new->set->data, &iter.iter, false, true);
+ btree_mergesort(b, new->set->data, &iter, false, true);
bch_time_stats_update(&state->time, start_time);

drivers/md/bcache/bset.h

View file
diff --git a/drivers/md/bcache/bset.h b/drivers/md/bcache/bset.h
index 011f606..f79441a 100644
--- a/drivers/md/bcache/bset.h
+++ b/drivers/md/bcache/bset.h
@@ -187,8 +187,9 @@ struct bset_tree {
};
struct btree_keys_ops {
- bool (*sort_cmp)(struct btree_iter_set l,
- struct btree_iter_set r);
+ bool (*sort_cmp)(const void *l,
+ const void *r,
+ void *args);
struct bkey *(*sort_fixup)(struct btree_iter *iter,
struct bkey *tmp);
bool (*insert_fixup)(struct btree_keys *b,
@@ -312,23 +313,17 @@ enum {
BTREE_INSERT_STATUS_FRONT_MERGE,
};
+struct btree_iter_set {
+ struct bkey *k, *end;
+};
+
/* Btree key iteration */
struct btree_iter {
- size_t size, used;
#ifdef CONFIG_BCACHE_DEBUG
struct btree_keys *b;
#endif
- struct btree_iter_set {
- struct bkey *k, *end;
- } data[];
-};
-
-/* Fixed-size btree_iter that can be allocated on the stack */
-
-struct btree_iter_stack {
- struct btree_iter iter;
- struct btree_iter_set stack_data[MAX_BSETS];
+ MIN_HEAP_PREALLOCATED(struct btree_iter_set, btree_iter_heap, MAX_BSETS) heap;
};
typedef bool (*ptr_filter_fn)(struct btree_keys *b, const struct bkey *k);
@@ -340,9 +335,9 @@ struct bkey *bch_btree_iter_next_filter(struct btree_iter *iter,
void bch_btree_iter_push(struct btree_iter *iter, struct bkey *k,
struct bkey *end);
-struct bkey *bch_btree_iter_stack_init(struct btree_keys *b,
- struct btree_iter_stack *iter,
- struct bkey *search);
+struct bkey *bch_btree_iter_init(struct btree_keys *b,
+ struct btree_iter *iter,
+ struct bkey *search);
struct bkey *__bch_bset_search(struct btree_keys *b, struct bset_tree *t,
const struct bkey *search);
@@ -357,14 +352,13 @@ static inline struct bkey *bch_bset_search(struct btree_keys *b,
return search ? __bch_bset_search(b, t, search) : t->data->start;
}
-#define for_each_key_filter(b, k, stack_iter, filter) \
- for (bch_btree_iter_stack_init((b), (stack_iter), NULL); \
- ((k) = bch_btree_iter_next_filter(&((stack_iter)->iter), (b), \
- filter));)
+#define for_each_key_filter(b, k, iter, filter) \
+ for (bch_btree_iter_init((b), (iter), NULL); \
+ ((k) = bch_btree_iter_next_filter((iter), (b), filter));)
-#define for_each_key(b, k, stack_iter) \
- for (bch_btree_iter_stack_init((b), (stack_iter), NULL); \
- ((k) = bch_btree_iter_next(&((stack_iter)->iter)));)
+#define for_each_key(b, k, iter) \
+ for (bch_btree_iter_init((b), (iter), NULL); \
+ ((k) = bch_btree_iter_next(iter));)
/* Sorting */

drivers/md/bcache/btree.c

View file
diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c
index 4e6ccf2..ed40d86 100644
--- a/drivers/md/bcache/btree.c
+++ b/drivers/md/bcache/btree.c
@@ -149,19 +149,19 @@ void bch_btree_node_read_done(struct btree *b)
{
const char *err = "bad btree header";
struct bset *i = btree_bset_first(b);
- struct btree_iter *iter;
+ struct btree_iter iter;
/*
* c->fill_iter can allocate an iterator with more memory space
* than static MAX_BSETS.
* See the comment arount cache_set->fill_iter.
*/
- iter = mempool_alloc(&b->c->fill_iter, GFP_NOIO);
- iter->size = b->c->cache->sb.bucket_size / b->c->cache->sb.block_size;
- iter->used = 0;
+ iter.heap.data = mempool_alloc(&b->c->fill_iter, GFP_NOIO);
+ iter.heap.size = b->c->cache->sb.bucket_size / b->c->cache->sb.block_size;
+ iter.heap.nr = 0;
#ifdef CONFIG_BCACHE_DEBUG
- iter->b = &b->keys;
+ iter.b = &b->keys;
#endif
if (!i->seq)
@@ -199,7 +199,7 @@ void bch_btree_node_read_done(struct btree *b)
if (i != b->keys.set[0].data && !i->keys)
goto err;
- bch_btree_iter_push(iter, i->start, bset_bkey_last(i));
+ bch_btree_iter_push(&iter, i->start, bset_bkey_last(i));
b->written += set_blocks(i, block_bytes(b->c->cache));
}
@@ -211,7 +211,7 @@ void bch_btree_node_read_done(struct btree *b)
if (i->seq == b->keys.set[0].data->seq)
goto err;
- bch_btree_sort_and_fix_extents(&b->keys, iter, &b->c->sort);
+ bch_btree_sort_and_fix_extents(&b->keys, &iter, &b->c->sort);
i = b->keys.set[0].data;
err = "short btree key";
@@ -223,7 +223,7 @@ void bch_btree_node_read_done(struct btree *b)
bch_bset_init_next(&b->keys, write_block(b),
bset_magic(&b->c->cache->sb));

This diff is incomplete. Download the complete patch.

drivers/md/bcache/extents.c

View file

This diff is incomplete. Download the complete patch.

drivers/md/bcache/movinggc.c

View file

This diff is incomplete. Download the complete patch.

drivers/md/bcache/super.c

View file

This diff is incomplete. Download the complete patch.

drivers/md/bcache/sysfs.c

View file

This diff is incomplete. Download the complete patch.

drivers/md/bcache/util.c

View file

This diff is incomplete. Download the complete patch.

drivers/md/bcache/util.h

View file

This diff is incomplete. Download the complete patch.

drivers/md/bcache/writeback.c

View file

This diff is incomplete. Download the complete patch.

drivers/md/dm-vdo/repair.c

View file

This diff is incomplete. Download the complete patch.

drivers/md/dm-vdo/slab-depot.c

View file

This diff is incomplete. Download the complete patch.

drivers/most/core.c

View file

This diff is incomplete. Download the complete patch.

drivers/most/most_cdev.c

View file

This diff is incomplete. Download the complete patch.

drivers/net/wireless/ti/wl1251/acx.h

View file

This diff is incomplete. Download the complete patch.

drivers/scsi/qedf/qedf_main.c

View file

This diff is incomplete. Download the complete patch.

drivers/staging/rtl8723bs/core/rtw_mlme_ext.c

View file

This diff is incomplete. Download the complete patch.

drivers/staging/rtl8723bs/core/rtw_pwrctrl.c

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/clock.c

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/clock_types.h

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/ec.c

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/ec_types.h

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/util.c

View file

This diff is incomplete. Download the complete patch.

fs/bcachefs/util.h

View file

This diff is incomplete. Download the complete patch.

fs/coredump.c

View file

This diff is incomplete. Download the complete patch.

fs/nilfs2/segment.c

View file

This diff is incomplete. Download the complete patch.

fs/nilfs2/sysfs.c

View file

This diff is incomplete. Download the complete patch.

fs/ocfs2/dir.c

View file

This diff is incomplete. Download the complete patch.

fs/ocfs2/dlmglue.c

View file

This diff is incomplete. Download the complete patch.

fs/ocfs2/namei.c

View file

This diff is incomplete. Download the complete patch.

fs/ocfs2/ocfs2.h

View file

This diff is incomplete. Download the complete patch.

fs/ocfs2/stack_o2cb.c

View file

This diff is incomplete. Download the complete patch.

fs/ocfs2/stack_user.c

View file

This diff is incomplete. Download the complete patch.

fs/ocfs2/stackglue.h

View file

This diff is incomplete. Download the complete patch.

fs/ocfs2/xattr.c

View file

This diff is incomplete. Download the complete patch.

fs/ufs/super.c

View file

This diff is incomplete. Download the complete patch.

include/asm-generic/vmlinux.lds.h

View file

This diff is incomplete. Download the complete patch.

include/linux/cacheinfo.h

View file

This diff is incomplete. Download the complete patch.

include/linux/cgroup.h

View file

This diff is incomplete. Download the complete patch.

include/linux/clockchips.h

View file

This diff is incomplete. Download the complete patch.

include/linux/compiler.h

View file

This diff is incomplete. Download the complete patch.

include/linux/cpu.h

View file

This diff is incomplete. Download the complete patch.

include/linux/cpu_cooling.h

View file

This diff is incomplete. Download the complete patch.

include/linux/cpu_rmap.h

View file

This diff is incomplete. Download the complete patch.

include/linux/cpumask.h

View file

This diff is incomplete. Download the complete patch.

include/linux/cpumask_types.h

View file

This diff is incomplete. Download the complete patch.

include/linux/init.h

View file

This diff is incomplete. Download the complete patch.

include/linux/interrupt.h

View file

This diff is incomplete. Download the complete patch.

include/linux/irqchip/irq-partition-percpu.h

View file

This diff is incomplete. Download the complete patch.

include/linux/jhash.h

View file

This diff is incomplete. Download the complete patch.

include/linux/kernel_stat.h

View file

This diff is incomplete. Download the complete patch.

include/linux/min_heap.h

View file

This diff is incomplete. Download the complete patch.

include/linux/msi.h

View file

This diff is incomplete. Download the complete patch.

include/linux/node.h

View file

This diff is incomplete. Download the complete patch.

include/linux/nvme-fc-driver.h

View file

This diff is incomplete. Download the complete patch.

include/linux/panic.h

View file

This diff is incomplete. Download the complete patch.

include/linux/percpu.h

View file

This diff is incomplete. Download the complete patch.

include/linux/pm_domain.h

View file

This diff is incomplete. Download the complete patch.

include/linux/poison.h

View file

This diff is incomplete. Download the complete patch.

include/linux/profile.h

View file

This diff is incomplete. Download the complete patch.

include/linux/rcupdate.h

View file

This diff is incomplete. Download the complete patch.

include/linux/sched.h

View file

This diff is incomplete. Download the complete patch.

include/linux/seq_file.h

View file

This diff is incomplete. Download the complete patch.

include/linux/soc/apple/rtkit.h

View file

This diff is incomplete. Download the complete patch.

include/linux/stop_machine.h

View file

This diff is incomplete. Download the complete patch.

include/linux/torture.h

View file

This diff is incomplete. Download the complete patch.

include/linux/tracepoint.h

View file

This diff is incomplete. Download the complete patch.

include/linux/workqueue.h

View file

This diff is incomplete. Download the complete patch.

kernel/backtracetest.c

View file

This diff is incomplete. Download the complete patch.

kernel/crash_reserve.c

View file

This diff is incomplete. Download the complete patch.

kernel/events/core.c

View file

This diff is incomplete. Download the complete patch.

kernel/fork.c

View file

This diff is incomplete. Download the complete patch.

kernel/hung_task.c

View file

This diff is incomplete. Download the complete patch.

kernel/panic.c

View file

This diff is incomplete. Download the complete patch.

kernel/resource_kunit.c

View file

This diff is incomplete. Download the complete patch.

kernel/tsacct.c

View file

This diff is incomplete. Download the complete patch.

kernel/watchdog_perf.c

View file

This diff is incomplete. Download the complete patch.

lib/Kconfig.debug

View file

This diff is incomplete. Download the complete patch.

lib/asn1_encoder.c

View file

This diff is incomplete. Download the complete patch.

lib/atomic64_test.c

View file

This diff is incomplete. Download the complete patch.

lib/bch.c

View file

This diff is incomplete. Download the complete patch.

lib/bitfield_kunit.c

View file

This diff is incomplete. Download the complete patch.

lib/buildid.c

View file

This diff is incomplete. Download the complete patch.

lib/checksum_kunit.c

View file

This diff is incomplete. Download the complete patch.

lib/cmdline_kunit.c

View file

This diff is incomplete. Download the complete patch.

lib/dhry_run.c

View file

This diff is incomplete. Download the complete patch.

lib/dump_stack.c

View file

This diff is incomplete. Download the complete patch.

lib/fortify_kunit.c

View file

This diff is incomplete. Download the complete patch.

lib/hashtable_test.c

View file

This diff is incomplete. Download the complete patch.

lib/is_signed_type_kunit.c

View file

This diff is incomplete. Download the complete patch.

lib/math/rational.c

View file

This diff is incomplete. Download the complete patch.

lib/memcpy_kunit.c

View file

This diff is incomplete. Download the complete patch.

lib/overflow_kunit.c

View file

This diff is incomplete. Download the complete patch.

lib/percpu_counter.c

View file

This diff is incomplete. Download the complete patch.

lib/plist.c

View file

This diff is incomplete. Download the complete patch.

lib/rbtree.c

View file

This diff is incomplete. Download the complete patch.

lib/siphash_kunit.c

View file

This diff is incomplete. Download the complete patch.

lib/sort.c

View file

This diff is incomplete. Download the complete patch.

lib/stackinit_kunit.c

View file

This diff is incomplete. Download the complete patch.

lib/test-kstrtox.c

View file

This diff is incomplete. Download the complete patch.

lib/test_bits.c

View file

This diff is incomplete. Download the complete patch.

lib/test_blackhole_dev.c

View file

This diff is incomplete. Download the complete patch.

lib/test_bpf.c

View file

This diff is incomplete. Download the complete patch.

lib/test_firmware.c

View file

This diff is incomplete. Download the complete patch.

lib/test_fpu_glue.c

View file

This diff is incomplete. Download the complete patch.

lib/test_free_pages.c

View file

This diff is incomplete. Download the complete patch.

lib/test_hash.c

View file

This diff is incomplete. Download the complete patch.

lib/test_hexdump.c

View file

This diff is incomplete. Download the complete patch.

lib/test_ida.c

View file

This diff is incomplete. Download the complete patch.

lib/test_kmod.c

View file

This diff is incomplete. Download the complete patch.

lib/test_kprobes.c

View file

This diff is incomplete. Download the complete patch.

lib/test_linear_ranges.c

View file

This diff is incomplete. Download the complete patch.

lib/test_list_sort.c

View file

This diff is incomplete. Download the complete patch.

lib/test_memcat_p.c

View file

This diff is incomplete. Download the complete patch.

lib/test_meminit.c

View file

This diff is incomplete. Download the complete patch.

lib/test_min_heap.c

View file

This diff is incomplete. Download the complete patch.

lib/test_module.c

View file

This diff is incomplete. Download the complete patch.

lib/test_ref_tracker.c

View file

This diff is incomplete. Download the complete patch.

lib/test_sort.c

View file

This diff is incomplete. Download the complete patch.

lib/test_static_key_base.c

View file

This diff is incomplete. Download the complete patch.

lib/test_static_keys.c

View file

This diff is incomplete. Download the complete patch.

lib/test_sysctl.c

View file

This diff is incomplete. Download the complete patch.

lib/test_uuid.c

View file

This diff is incomplete. Download the complete patch.

lib/ts_bm.c

View file

This diff is incomplete. Download the complete patch.

lib/ts_fsm.c

View file

This diff is incomplete. Download the complete patch.

lib/ts_kmp.c

View file

This diff is incomplete. Download the complete patch.

lib/zlib_deflate/deflate_syms.c

View file

This diff is incomplete. Download the complete patch.

net/netfilter/nf_conntrack_core.c

View file

This diff is incomplete. Download the complete patch.

net/tipc/socket.c

View file

This diff is incomplete. Download the complete patch.

samples/kfifo/bytestream-example.c

View file

This diff is incomplete. Download the complete patch.

samples/kfifo/dma-example.c

View file

This diff is incomplete. Download the complete patch.

samples/kfifo/inttype-example.c

View file

This diff is incomplete. Download the complete patch.

samples/kfifo/record-example.c

View file

This diff is incomplete. Download the complete patch.

scripts/checkpatch.pl

View file

This diff is incomplete. Download the complete patch.

scripts/decode_stacktrace.sh

View file

This diff is incomplete. Download the complete patch.

scripts/gdb/linux/mm.py

View file

This diff is incomplete. Download the complete patch.

scripts/gdb/linux/stackdepot.py

View file

This diff is incomplete. Download the complete patch.

scripts/mod/modpost.c

View file

This diff is incomplete. Download the complete patch.

scripts/spelling.txt

View file

This diff is incomplete. Download the complete patch.

tools/lib/list_sort.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/radix-tree/idr-test.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/radix-tree/maple.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/radix-tree/xarray.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/filesystems/eventfd/eventfd_test.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/mqueue/mq_perf_tests.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/proc/.gitignore

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/proc/Makefile

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/proc/proc-2-is-kthread.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/proc/proc-empty-vm.c

View file

This diff is incomplete. Download the complete patch.

tools/testing/selftests/proc/proc-self-isnt-kthread.c

View file

This diff is incomplete. Download the complete patch.