linux-2.6-block.git
4 months agobcachefs: Fix type of flags parameter for some ->trigger() implementations
Nathan Chancellor [Tue, 23 Apr 2024 18:58:09 +0000 (11:58 -0700)]
bcachefs: Fix type of flags parameter for some ->trigger() implementations

When building with clang's -Wincompatible-function-pointer-types-strict
(a warning designed to catch potential kCFI failures at build time),
there are several warnings along the lines of:

  fs/bcachefs/bkey_methods.c:118:2: error: incompatible function pointer types initializing 'int (*)(struct btree_trans *, enum btree_id, unsigned int, struct bkey_s_c, struct bkey_s, enum btree_iter_update_trigger_flags)' with an expression of type 'int (struct btree_trans *, enum btree_id, unsigned int, struct bkey_s_c, struct bkey_s, unsigned int)' [-Werror,-Wincompatible-function-pointer-types-strict]
    118 |         BCH_BKEY_TYPES()
        |         ^~~~~~~~~~~~~~~~
  fs/bcachefs/bcachefs_format.h:394:2: note: expanded from macro 'BCH_BKEY_TYPES'
    394 |         x(inode,                8)                      \
        |         ^~~~~~~~~~~~~~~~~~~~~~~~~~
  fs/bcachefs/bkey_methods.c:117:41: note: expanded from macro 'x'
    117 | #define x(name, nr) [KEY_TYPE_##name]   = bch2_bkey_ops_##name,
        |                                           ^~~~~~~~~~~~~~~~~~~~
  <scratch space>:277:1: note: expanded from here
    277 | bch2_bkey_ops_inode
        | ^~~~~~~~~~~~~~~~~~~
  fs/bcachefs/inode.h:26:13: note: expanded from macro 'bch2_bkey_ops_inode'
     26 |         .trigger        = bch2_trigger_inode,           \
      |                           ^~~~~~~~~~~~~~~~~~

There are several functions that did not have their flags parameter
converted to 'enum btree_iter_update_trigger_flags' in the recent
unification, which will cause kCFI failures at runtime because the
types, while ABI compatible (hence no warning from the non-strict
version of this warning), do not match exactly.

Fix up these functions (as well as a few other obvious functions that
should have it, even if there are no warnings currently) to resolve the
warnings and potential kCFI runtime failures.

Fixes: 31e4ef3280c8 ("bcachefs: iter/update/trigger/str_hash flag cleanup")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: Kill gc_init_recurse()
Kent Overstreet [Sun, 7 Apr 2024 03:58:01 +0000 (23:58 -0400)]
bcachefs: Kill gc_init_recurse()

This unifies the online and offline btree gc passes; we're not yet
running it online.

We now iterate over one level of the btree at a time - the same as
check_extents_to_backpointers(); this ordering preserves order of keys
regardless of btree splits and merges, which will be important when we
re-enable online gc.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: do reflink_p repair from BTREE_TRIGGER_check_repair
Kent Overstreet [Sun, 7 Apr 2024 23:47:31 +0000 (19:47 -0400)]
bcachefs: do reflink_p repair from BTREE_TRIGGER_check_repair

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: Run bch2_check_fix_ptrs() via triggers
Kent Overstreet [Sun, 7 Apr 2024 23:07:09 +0000 (19:07 -0400)]
bcachefs: Run bch2_check_fix_ptrs() via triggers

Currently, the reflink_p gc trigger does repair as well - turning a
reflink_p key into an error key if the reflink_v it points to doesn't
exist.

This won't work with online check/repair, because the repair path once
online will be subject to transaction restarts, but BTREE_TRIGGER_gc is
not idempotant - we can't run it multiple times if we get a transaction
restart.

So we need to split these paths; to do so this patch calls
check_fix_ptrs() by a new general path - a new trigger type,
BTREE_TRIGGER_check_repair.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: kill gc looping for bucket gens
Kent Overstreet [Wed, 17 Apr 2024 02:35:02 +0000 (22:35 -0400)]
bcachefs: kill gc looping for bucket gens

looping when we change a bucket gen is not ideal - it means we risk
failing if we'd go into an infinite loop, and it's better to make
forward progress even if fsck doesn't fix everything.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: bch2_bucket_ref_update()
Kent Overstreet [Fri, 19 Apr 2024 23:03:58 +0000 (19:03 -0400)]
bcachefs: bch2_bucket_ref_update()

If we hit an inconsistency when updating allocation information, we
don't want to fail the update if it's for a deletion - only if it's for
a new key.

Rename check_bucket_ref() -> bucket_ref_update() so we can centralize
the logic to do this.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: Consolidate mark_stripe_bucket() and trans_mark_stripe_bucket()
Kent Overstreet [Mon, 22 Apr 2024 23:01:40 +0000 (19:01 -0400)]
bcachefs: Consolidate mark_stripe_bucket() and trans_mark_stripe_bucket()

This eliminates some duplicated logic, and the gc path now handles
stripe updates and deletions - we need this since soon we're bringing
back runtime gc.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: mark_stripe_bucket cleanup
Kent Overstreet [Sat, 20 Apr 2024 04:04:07 +0000 (00:04 -0400)]
bcachefs: mark_stripe_bucket cleanup

Start to work on unifying mark_stripe_bucket() and
trans_mark_stripe_bucket(); first, clean up all the unnecessary and
gratuitious differences.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: bucket_data_type_mismatch()
Kent Overstreet [Mon, 22 Apr 2024 21:21:35 +0000 (17:21 -0400)]
bcachefs: bucket_data_type_mismatch()

We're working on potentially unifying bch2_check_bucket_ref() and
bch2_check_fix_ptrs() - or at least eliminating gratuitious differences.

Most immediately, there's a bunch of cleanups to be done regarding
BCH_DATA_stripe.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: Clean up inode alloc
Kent Overstreet [Sun, 21 Apr 2024 02:03:09 +0000 (22:03 -0400)]
bcachefs: Clean up inode alloc

There's no need to be using new_inode(); we can skip all that
indirection and make the code easier to follow.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: journal seq blacklist gc no longer has to walk btree
Kent Overstreet [Sun, 21 Apr 2024 02:19:48 +0000 (22:19 -0400)]
bcachefs: journal seq blacklist gc no longer has to walk btree

Since btree_ptr_v2, we no longer require the journal seq blacklist table
for skipping blacklisted bsets (btree node entries); the pointer to a
given node indicates how much data is present.

Therefore there's no longer any need for journal seq blacklist gc to
walk the btree - we can prune entries older than journal last_seq.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: plumb data_type into bch2_bucket_alloc_trans()
Kent Overstreet [Sat, 20 Apr 2024 20:10:40 +0000 (16:10 -0400)]
bcachefs: plumb data_type into bch2_bucket_alloc_trans()

prep work for making the allocator try to keep btree nodes within the
existing member info btree allocated bitmap

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: Add btree_allocated_bitmap to member_to_text()
Kent Overstreet [Sat, 20 Apr 2024 20:50:46 +0000 (16:50 -0400)]
bcachefs: Add btree_allocated_bitmap to member_to_text()

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: Btree key cache instrumentation
Kent Overstreet [Sat, 20 Apr 2024 18:49:22 +0000 (14:49 -0400)]
bcachefs: Btree key cache instrumentation

It turns out the btree key cache shrinker wasn't actually reclaiming
anything, prior to the previous patch. This adds instrumentation so that
if we have further issues we can see what's going on.

Specifically, sysfs internal/btree_key_cache is greatly expanded with
new counters, and the SRCU sequence numbers of the first 10 entries on
each pending freelist, and we also add trigger_btree_key_cache_shrink
for testing without having to prune all the system caches.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: Remove calls to folio_set_error
Matthew Wilcox (Oracle) [Sat, 20 Apr 2024 02:50:01 +0000 (03:50 +0100)]
bcachefs: Remove calls to folio_set_error

Common code doesn't test the error flag, so we don't need to set it in
bcachefs.  We can use folio_end_read() to combine the setting (or not)
of the uptodate flag and clearing the lock flag.

Cc: Kent Overstreet <kent.overstreet@linux.dev>
Cc: Brian Foster <bfoster@redhat.com>
Cc: linux-bcachefs@vger.kernel.org
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: Move gc of bucket.oldest_gen to workqueue
Kent Overstreet [Sat, 20 Apr 2024 02:44:12 +0000 (22:44 -0400)]
bcachefs: Move gc of bucket.oldest_gen to workqueue

This is a nice cleanup - and we've also been having problems with
kthread creation in the mount path.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: fix flag printing in journal_buf_to_text()
Kent Overstreet [Sat, 20 Apr 2024 00:23:32 +0000 (20:23 -0400)]
bcachefs: fix flag printing in journal_buf_to_text()

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: Sync journal when we complete a recovery pass
Kent Overstreet [Wed, 17 Apr 2024 06:03:22 +0000 (02:03 -0400)]
bcachefs: Sync journal when we complete a recovery pass

Make things easier when we're debugging long fsck runs - persist the
work that successful recovery passes did.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: make btree read errors silent during scan
Kent Overstreet [Wed, 17 Apr 2024 05:26:02 +0000 (01:26 -0400)]
bcachefs: make btree read errors silent during scan

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: Rip bch2_snapshot_equiv() out of fsck
Kent Overstreet [Wed, 17 Apr 2024 03:08:39 +0000 (23:08 -0400)]
bcachefs: Rip bch2_snapshot_equiv() out of fsck

Originally, when deleting snapshots we didn't collapse redundant
snapshot nodes; thus, the notion of a class of equivalent snapshot nodes
leaked into fsck.

Now we do, so snapshot ID equivalence classes are purely local to
snapshot deletion.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: Check for writing btree_ptr_v2.sectors_written == 0
Kent Overstreet [Tue, 16 Apr 2024 23:33:56 +0000 (19:33 -0400)]
bcachefs: Check for writing btree_ptr_v2.sectors_written == 0

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: Add asserts to bch2_dev_btree_bitmap_marked_sectors()
Kent Overstreet [Tue, 16 Apr 2024 23:33:51 +0000 (19:33 -0400)]
bcachefs: Add asserts to bch2_dev_btree_bitmap_marked_sectors()

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: fs_alloc_debug_to_text()
Kent Overstreet [Tue, 16 Apr 2024 04:11:33 +0000 (00:11 -0400)]
bcachefs: fs_alloc_debug_to_text()

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: assert that online_reserved == 0 on shutdown
Kent Overstreet [Sun, 14 Apr 2024 23:43:12 +0000 (19:43 -0400)]
bcachefs: assert that online_reserved == 0 on shutdown

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: bch2_trans_verify_not_unlocked()
Kent Overstreet [Wed, 10 Apr 2024 00:14:21 +0000 (20:14 -0400)]
bcachefs: bch2_trans_verify_not_unlocked()

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: bch2_btree_path_can_relock()
Kent Overstreet [Thu, 11 Apr 2024 01:51:37 +0000 (21:51 -0400)]
bcachefs: bch2_btree_path_can_relock()

With the new assertions, we shouldn't be holding locks when
trans->locked is false, thus, we shouldn't use relock when we just want
to check if we can relock.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: trans->locked
Kent Overstreet [Tue, 9 Apr 2024 23:57:08 +0000 (19:57 -0400)]
bcachefs: trans->locked

Add a field for tracking whether a transaction object holds btree locks,
and assertions to verify state.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: bch2_btree_root_alloc_fake_trans()
Kent Overstreet [Sun, 14 Apr 2024 22:42:42 +0000 (18:42 -0400)]
bcachefs: bch2_btree_root_alloc_fake_trans()

We're starting to be more strict about transaction locked state, and
multiple transactions in a task.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: bch2_trans_unlock() must always be followed by relock() or begin()
Kent Overstreet [Wed, 10 Apr 2024 03:23:08 +0000 (23:23 -0400)]
bcachefs: bch2_trans_unlock() must always be followed by relock() or begin()

We're about to add new asserts for btree_trans locking consistency, and
part of that requires that aren't using the btree_trans while it's
unlocked.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: Use bch2_btree_path_upgrade() in key cache traverse
Kent Overstreet [Wed, 10 Apr 2024 04:35:24 +0000 (00:35 -0400)]
bcachefs: Use bch2_btree_path_upgrade() in key cache traverse

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: bch2_btree_path_upgrade() checks nodes_locked, not uptodate
Kent Overstreet [Thu, 11 Apr 2024 02:19:40 +0000 (22:19 -0400)]
bcachefs: bch2_btree_path_upgrade() checks nodes_locked, not uptodate

In the key cache fill path, we use path_upgrade() on a path that isn't
uptodate yet but should be locked.

This change makes bch2_btree_path_upgrade() slightly looser so we can
use it in key cache upgrade, instead of the __ version.

Also, make the related assert - that path->uptodate implies nodes_locked
- slightly clearer.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: maintain lock invariants in btree_iter_next_node()
Kent Overstreet [Thu, 11 Apr 2024 22:04:00 +0000 (18:04 -0400)]
bcachefs: maintain lock invariants in btree_iter_next_node()

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: bch2_trans_commit_flags_to_text()
Kent Overstreet [Sat, 13 Apr 2024 21:49:23 +0000 (17:49 -0400)]
bcachefs: bch2_trans_commit_flags_to_text()

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: prefer drop_locks_do()
Kent Overstreet [Sat, 13 Apr 2024 21:40:06 +0000 (17:40 -0400)]
bcachefs: prefer drop_locks_do()

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: get_unlocked_mut_path -> bch2_path_get_unlocked_mut
Kent Overstreet [Fri, 12 Apr 2024 19:44:09 +0000 (15:44 -0400)]
bcachefs: get_unlocked_mut_path -> bch2_path_get_unlocked_mut

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: fix typo in reference to BCACHEFS_DEBUG
Lukas Bulwahn [Thu, 11 Apr 2024 08:29:31 +0000 (10:29 +0200)]
bcachefs: fix typo in reference to BCACHEFS_DEBUG

Commit ec9cc18fc2e6 ("bcachefs: Add checks for invalid snapshot IDs")
intends to check the sanity of a snapshot and panic when
BCACHEFS_DEBUG is set, but that conditional has a typo.

Fix the typo to refer to the actual existing Kconfig symbol.

This was found with ./scripts/checkkconfigsymbols.py.

Signed-off-by: Lukas Bulwahn <lukas.bulwahn@redhat.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: chardev: make bch_chardev_class constant
Ricardo B. Marliere [Fri, 8 Mar 2024 12:12:47 +0000 (09:12 -0300)]
bcachefs: chardev: make bch_chardev_class constant

Since commit 43a7206b0963 ("driver core: class: make class_register() take
a const *"), the driver core allows for struct class to be in read-only
memory, so move the bch_chardev_class structure to be declared at build
time placing it into read-only memory, instead of having to be dynamically
allocated at boot time. Also, correctly clean up after failing paths in
bch2_chardev_init().

Cc: Hongbo Li <lihongbo22@huawei.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: member helper cleanups
Kent Overstreet [Fri, 12 Apr 2024 03:31:55 +0000 (23:31 -0400)]
bcachefs: member helper cleanups

Some renaming for better consistency

bch2_member_exists -> bch2_member_alive
bch2_dev_exists -> bch2_member_exists
bch2_dev_exsits2 -> bch2_dev_exists
bch_dev_locked -> bch2_dev_locked
bch_dev_bkey_exists -> bch2_dev_bkey_exists

new helper - bch2_dev_safe

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: bucket_valid()
Kent Overstreet [Fri, 12 Apr 2024 01:18:35 +0000 (21:18 -0400)]
bcachefs: bucket_valid()

cut out a branch from doing it the obvious way

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: bch2_trans_relock_fail() - factor out slowpath
Kent Overstreet [Tue, 9 Apr 2024 23:45:41 +0000 (19:45 -0400)]
bcachefs: bch2_trans_relock_fail() - factor out slowpath

Factor out slowpath into a separate helper

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: bch2_dir_emit() - drop_locks_do() conversion
Kent Overstreet [Wed, 10 Apr 2024 17:18:22 +0000 (13:18 -0400)]
bcachefs: bch2_dir_emit() - drop_locks_do() conversion

Add a new helper that calls dir_emit() and updates ctx->pos on success;
this lets us convert bch2_readdir() to drop_locks_do().

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: bch2_btree_insert_trans() no longer specifies BTREE_ITER_cached
Kent Overstreet [Sun, 7 Apr 2024 23:13:45 +0000 (19:13 -0400)]
bcachefs: bch2_btree_insert_trans() no longer specifies BTREE_ITER_cached

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: iter/update/trigger/str_hash flag cleanup
Kent Overstreet [Sun, 7 Apr 2024 22:05:34 +0000 (18:05 -0400)]
bcachefs: iter/update/trigger/str_hash flag cleanup

Combine iter/update/trigger/str_hash flags into a single enum, and
x-macroize them for a to_text() function later.

These flags are all for a specific iter/key/update context, so it makes
sense to group them together - iter/update/trigger flags were already
given distinct bits, this cleans up and unifies that handling.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: __BTREE_ITER_ALL_SNAPSHOTS -> BTREE_ITER_SNAPSHOT_FIELD
Kent Overstreet [Sun, 7 Apr 2024 21:54:00 +0000 (17:54 -0400)]
bcachefs: __BTREE_ITER_ALL_SNAPSHOTS -> BTREE_ITER_SNAPSHOT_FIELD

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: mark_superblock cleanup
Kent Overstreet [Sun, 7 Apr 2024 06:11:03 +0000 (02:11 -0400)]
bcachefs: mark_superblock cleanup

Consolidate mark_superblock() and trans_mark_superblock(), like we did
with the other trigger paths.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: gc_btree_init_recurse() uses gc_mark_node()
Kent Overstreet [Sun, 7 Apr 2024 03:39:12 +0000 (23:39 -0400)]
bcachefs: gc_btree_init_recurse() uses gc_mark_node()

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: move root node topo checks to node_check_topology()
Kent Overstreet [Sun, 7 Apr 2024 03:26:36 +0000 (23:26 -0400)]
bcachefs: move root node topo checks to node_check_topology()

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: move topology repair kick to gc_btrees()
Kent Overstreet [Sun, 7 Apr 2024 03:20:49 +0000 (23:20 -0400)]
bcachefs: move topology repair kick to gc_btrees()

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: kill metadata only gc
Kent Overstreet [Sun, 7 Apr 2024 02:40:12 +0000 (22:40 -0400)]
bcachefs: kill metadata only gc

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: Finish converting reconstruct_alloc to errors_silent
Kent Overstreet [Sun, 7 Apr 2024 21:05:01 +0000 (17:05 -0400)]
bcachefs: Finish converting reconstruct_alloc to errors_silent

with errors_silent, reconstruct_alloc no longer requires fsck and
fix_errors to work

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: bch2_gc() is now private to btree_gc.c
Kent Overstreet [Sat, 6 Apr 2024 04:11:01 +0000 (00:11 -0400)]
bcachefs: bch2_gc() is now private to btree_gc.c

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: for_each_btree_key_continue()
Kent Overstreet [Sun, 7 Apr 2024 04:52:47 +0000 (00:52 -0400)]
bcachefs: for_each_btree_key_continue()

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: kill for_each_btree_key_old()
Kent Overstreet [Sat, 6 Apr 2024 05:44:05 +0000 (01:44 -0400)]
bcachefs: kill for_each_btree_key_old()

Dead code

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: Optimize eytzinger0_sort() with bottom-up heapsort
Kuan-Wei Chiu [Sun, 7 Apr 2024 03:39:04 +0000 (11:39 +0800)]
bcachefs: Optimize eytzinger0_sort() with bottom-up heapsort

This optimization reduces the average number of comparisons required
from 2*n*log2(n) - 3*n + o(n) to n*log2(n) + 0.37*n + o(n). When n is
sufficiently large, it results in approximately 50% fewer comparisons.

Currently, eytzinger0_sort employs the textbook version of heapsort,
where during the heapify process, each level requires two comparisons
to determine the maximum among three elements. In contrast, the
bottom-up heapsort, during heapify, only compares two children at each
level until reaching a leaf node. Then, it backtracks from the leaf
node to find the correct position. Since heapify typically continues
until very close to the leaf node, the standard heapify requires about
2*log2(n) comparisons, while the bottom-up variant only needs log2(n)
comparisons.

The experimental data presented below is based on an array generated
by get_random_u32().

|   N   | comparisons(old) | comparisons(new) | time(old) | time(new) |
|-------|------------------|------------------|-----------|-----------|
| 10000 |     235381       |     136615       |  25545 us |  20366 us |
| 20000 |     510694       |     293425       |  31336 us |  18312 us |
| 30000 |     800384       |     457412       |  35042 us |  27386 us |
| 40000 |    1101617       |     626831       |  48779 us |  38253 us |
| 50000 |    1409762       |     799637       |  62238 us |  46950 us |
| 60000 |    1721191       |     974521       |  75588 us |  58367 us |
| 70000 |    2038536       |    1152171       |  90823 us |  68778 us |
| 80000 |    2362958       |    1333472       | 104165 us |  78625 us |
| 90000 |    2690900       |    1516065       | 116111 us |  89573 us |
| 100000|    3019413       |    1699879       | 133638 us | 100998 us |

Refs:
  BOTTOM-UP-HEAPSORT, a new variant of HEAPSORT beating, on an average,
  QUICKSORT (if n is not very small)
  Ingo Wegener
  Theoretical Computer Science, 118(1); Pages 81-98, 13 September 1993
  https://doi.org/10.1016/0304-3975(93)90364-Y

Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: When traversing to interior nodes, propagate result to paths to same leaf...
Kent Overstreet [Fri, 22 Mar 2024 03:21:56 +0000 (23:21 -0400)]
bcachefs: When traversing to interior nodes, propagate result to paths to same leaf node

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: Don't read journal just for fsck
Kent Overstreet [Sun, 31 Mar 2024 02:42:29 +0000 (22:42 -0400)]
bcachefs: Don't read journal just for fsck

reading the journal can take a decent amount of time compared to the
rest of fsck, let's only read it when required.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: allow for custom action in fsck error messages
Kent Overstreet [Thu, 28 Mar 2024 04:39:11 +0000 (00:39 -0400)]
bcachefs: allow for custom action in fsck error messages

Be more explicit to the user about what we're doing.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: New assertion for writing to the journal after shutdown
Kent Overstreet [Wed, 21 Feb 2024 02:17:15 +0000 (21:17 -0500)]
bcachefs: New assertion for writing to the journal after shutdown

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: bch2_btree_path_to_text()
Kent Overstreet [Sat, 6 Apr 2024 01:32:06 +0000 (21:32 -0400)]
bcachefs: bch2_btree_path_to_text()

Long form version of bch2_btree_path_to_text() - useful in error
messages and tracepoints.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: add btree_node_merging_disabled debug param
Kent Overstreet [Fri, 5 Apr 2024 20:21:39 +0000 (16:21 -0400)]
bcachefs: add btree_node_merging_disabled debug param

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: bch2_hash_lookup() now returns bkey_s_c
Kent Overstreet [Sun, 7 Apr 2024 20:16:49 +0000 (16:16 -0400)]
bcachefs: bch2_hash_lookup() now returns bkey_s_c

small cleanup

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: bch2_journal_keys_dump()
Kent Overstreet [Tue, 9 Apr 2024 04:04:31 +0000 (00:04 -0400)]
bcachefs: bch2_journal_keys_dump()

debug helper

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: bch2_btree_node_header_to_text()
Kent Overstreet [Wed, 10 Apr 2024 18:41:17 +0000 (14:41 -0400)]
bcachefs: bch2_btree_node_header_to_text()

better btree node read path error messages

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: prt_printf() now respects \r\n\t
Kent Overstreet [Wed, 10 Apr 2024 20:08:24 +0000 (16:08 -0400)]
bcachefs: prt_printf() now respects \r\n\t

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: printbufs: prt_printf() now handles \t\r\n
Kent Overstreet [Wed, 10 Apr 2024 18:32:45 +0000 (14:32 -0400)]
bcachefs: printbufs: prt_printf() now handles \t\r\n

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: printbuf improvements
Kent Overstreet [Wed, 10 Apr 2024 18:32:45 +0000 (14:32 -0400)]
bcachefs: printbuf improvements

- fix assorted (harmless) off-by-one errors
- we were inconsistent on whether out->pos stays <= out->size on
  overflow; now it does, and printbuf.overflow exists to indicate if a
  printbuf has overflowed
- factor out printbuf_advance_pos()
- printbuf_nul_terminate_reserved(); use this to reduce the number of
  printbuf_make_room() calls

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: Run upgrade/downgrade even in -o nochanges mode
Kent Overstreet [Mon, 29 Apr 2024 01:24:45 +0000 (21:24 -0400)]
bcachefs: Run upgrade/downgrade even in -o nochanges mode

We need to be able to test these paths in dry run mode.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: Better write_super() error messages
Kent Overstreet [Fri, 3 May 2024 18:17:54 +0000 (14:17 -0400)]
bcachefs: Better write_super() error messages

When a superblock write is silently dropped or it's been modified by
another process we need to know which device it was.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: Fix xattr_to_text() unsafety
Kent Overstreet [Wed, 8 May 2024 06:50:42 +0000 (02:50 -0400)]
bcachefs: Fix xattr_to_text() unsafety

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: bch2_bkey_format_field_overflows()
Kent Overstreet [Wed, 8 May 2024 14:58:26 +0000 (10:58 -0400)]
bcachefs: bch2_bkey_format_field_overflows()

Fix another shift-by-64 by factoring out a common helper for
bch2_bkey_format_invalid() and bformat_needs_redo() (where it was
already fixed).

Reported-by: syzbot+9833a1d29d4a44361e2c@syzkaller.appspotmail.com
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: Fix needs_whiteout BUG_ON() in bkey_sort()
Kent Overstreet [Wed, 8 May 2024 04:29:24 +0000 (00:29 -0400)]
bcachefs: Fix needs_whiteout BUG_ON() in bkey_sort()

Btree nodes are log structured; thus, we need to emit whiteouts when
we're deleting a key that's been written out to disk.

k->needs_whiteout tracks whether a key will need a whiteout when it's
deleted, and this requires some careful handling; e.g. the key we're
deleting may not have been written out to disk, but it may have
overwritten a key that was - thus we need to carry this flag around on
overwrites.

Invariants:
There may be multiple key for the same position in a given node (because
of overwrites), but only one of them will be a live (non deleted) key,
and only one key for a given position will have the needs_whiteout flag
set.

Additionally, we don't want to carry around whiteouts that need to be
written in the main searchable part of a btree node - btree_iter_peek()
will have to skip past them, and this can lead to an O(n^2) issues when
doing sequential deletions (e.g. inode rm/truncate). So there's a
separate region in the btree node buffer for unwritten whiteouts; these
are merge sorted with the rest of the keys we're writing in the btree
node write path.

The unwritten whiteouts was a later optimization that bch2_sort_keys()
didn't take into account; the unwritten whiteouts area means that we
never have deleted keys with needs_whiteout set in the main searchable
part of a btree node.

That means we can simplify and optimize some sort paths, and eliminate
an assertion that syzbot found:

- Unless we're in the btree node write path, it's always ok to drop
  whiteouts when sorting
- When sorting for a btree node write, we drop the whiteout if it's not
  from the unwritten whiteouts area, or if it's overwritten by a real
  key at the same position.

This completely eliminates some tricky logic for propagating the
needs_whiteout flag: syzbot was able to hit the assertion that checked
that there shouldn't be more than one key at the same pos with
needs_whiteout set, likely due to a combination of flipping on
needs_whiteout on all written keys (they need whiteouts if overwritten),
combined with not always dropping unneeded whiteouts, and the tricky
logic in the sort path for preserving needs_whiteout that wasn't really
needed.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: Fix sb_clean_validate endianness conversion
Kent Overstreet [Wed, 8 May 2024 14:17:12 +0000 (10:17 -0400)]
bcachefs: Fix sb_clean_validate endianness conversion

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: Add missing sched_annotate_sleep() in bch2_journal_flush_seq_async()
Kent Overstreet [Tue, 7 May 2024 03:11:43 +0000 (23:11 -0400)]
bcachefs: Add missing sched_annotate_sleep() in bch2_journal_flush_seq_async()

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: Fix race in bch2_write_super()
Kent Overstreet [Tue, 7 May 2024 00:49:24 +0000 (20:49 -0400)]
bcachefs: Fix race in bch2_write_super()

bch2_write_super() was looping over online devices multiple times -
dropping and retaking io_ref each time.

This meant it could race with device removal; it could increment the
sequence number on a device but fail to write it - and then if the
device was re-added, it would get confused the next time around thinking
a superblock write was silently dropped.

Fix this by taking io_ref once, and stashing pointers to online devices
in a darray.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: BCH_SB_LAYOUT_SIZE_BITS_MAX
Kent Overstreet [Mon, 6 May 2024 13:10:29 +0000 (09:10 -0400)]
bcachefs: BCH_SB_LAYOUT_SIZE_BITS_MAX

Define a constant for the max superblock size, to avoid a too-large
shift.

Reported-by: syzbot+a8b0fb419355c91dda7f@syzkaller.appspotmail.com
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: Add missing skcipher_request_set_callback() call
Kent Overstreet [Mon, 6 May 2024 12:40:46 +0000 (08:40 -0400)]
bcachefs: Add missing skcipher_request_set_callback() call

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: Fix snapshot_t() usage in bch2_fs_quota_read_inode()
Kent Overstreet [Mon, 6 May 2024 02:56:54 +0000 (22:56 -0400)]
bcachefs: Fix snapshot_t() usage in bch2_fs_quota_read_inode()

bch2_fs_quota_read_inode() wasn't entirely updated to the
bch2_snapshot_tree() helper, which takes rcu lock.

Reported-by: syzbot+a3a9a61224ed3b7f0010@syzkaller.appspotmail.com
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: Fix shift-by-64 in bformat_needs_redo()
Kent Overstreet [Mon, 6 May 2024 02:44:27 +0000 (22:44 -0400)]
bcachefs: Fix shift-by-64 in bformat_needs_redo()

Ancient versions of bcachefs produced packed formats that could
represent keys that our in memory format cannot represent;
bformat_needs_redo() has some tricky shifts to check for this sort of
overflow.

Reported-by: syzbot+594427aebfefeebe91c6@syzkaller.appspotmail.com
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: Guard against unknown k.k->type in __bkey_invalid()
Kent Overstreet [Mon, 6 May 2024 02:33:05 +0000 (22:33 -0400)]
bcachefs: Guard against unknown k.k->type in __bkey_invalid()

For forwards compatibility we have to allow unknown key types, and only
run the checks that make sense against them.

Fix a missing guard on k.k->type being known.

Reported-by: syzbot+ae4dc916da3ce51f284f@syzkaller.appspotmail.com
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: Add missing validation for superblock section clean
Kent Overstreet [Mon, 6 May 2024 02:28:00 +0000 (22:28 -0400)]
bcachefs: Add missing validation for superblock section clean

We were forgetting to check for jset entries that overrun the end of the
section - both in validate and to_text(); to_text() needs to be safe for
types that fail to validate.

Reported-by: syzbot+c48865e11e7e893ec4ab@syzkaller.appspotmail.com
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: Fix assert in bch2_alloc_v4_invalid()
Kent Overstreet [Mon, 6 May 2024 02:02:28 +0000 (22:02 -0400)]
bcachefs: Fix assert in bch2_alloc_v4_invalid()

Reported-by: syzbot+10827fa6b176e1acf1d0@syzkaller.appspotmail.com
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: fix overflow in fiemap
Reed Riley [Sat, 4 May 2024 22:12:23 +0000 (22:12 +0000)]
bcachefs: fix overflow in fiemap

filefrag (and potentially other utilities that call fiemap) sometimes
pass ULONG_MAX as the length.  fiemap_prep clamps excessively large
lengths - but the calculation of end can overflow if it occurs before
calling fiemap_prep.  When this happens, filefrag assumes it has read to
the end and exits.

Signed-off-by: Reed Riley <reed@riley.engineer>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: Add a better limit for maximum number of buckets
Kent Overstreet [Sat, 4 May 2024 17:26:37 +0000 (13:26 -0400)]
bcachefs: Add a better limit for maximum number of buckets

The bucket_gens array is a single array allocation (one byte per
bucket), and kernel allocations are still limited to INT_MAX.

Check this limit to avoid failing the bucket_gens array allocation.

Reported-by: syzbot+b29f436493184ea42e2b@syzkaller.appspotmail.com
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: Fix lifetime issue in device iterator helpers
Kent Overstreet [Sat, 4 May 2024 16:55:44 +0000 (12:55 -0400)]
bcachefs: Fix lifetime issue in device iterator helpers

bch2_get_next_dev() and bch2_get_next_online_dev() iterate over devices,
dropping and taking refs as they go; we can't access the previous device
(for ca->dev_idx) after we've dropped our ref to it, unless we take
rcu_read_lock() first.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: Fix bch2_dev_lookup() refcounting
Kent Overstreet [Sat, 4 May 2024 16:51:49 +0000 (12:51 -0400)]
bcachefs: Fix bch2_dev_lookup() refcounting

bch2_dev_lookup() is supposed to take a ref on the device it returns, but
for_each_member_device() takes refs as it iterates,
for_each_member_device_rcu() does not.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: Initialize bch_write_op->failed in inline data path
Kent Overstreet [Sat, 4 May 2024 16:29:46 +0000 (12:29 -0400)]
bcachefs: Initialize bch_write_op->failed in inline data path

Normally this is initialized in __bch2_write(), which is executed in a
loop, but the inline data path skips this.

Reported-by: syzbot+fd3ccb331eb21f05d13b@syzkaller.appspotmail.com
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: Fix refcount put in sb_field_resize error path
Kent Overstreet [Fri, 3 May 2024 21:13:21 +0000 (17:13 -0400)]
bcachefs: Fix refcount put in sb_field_resize error path

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: Inodes need extra padding for varint_decode_fast()
Kent Overstreet [Fri, 3 May 2024 15:31:22 +0000 (11:31 -0400)]
bcachefs: Inodes need extra padding for varint_decode_fast()

Reported-by: syzbot+66b9b74f6520068596a9@syzkaller.appspotmail.com
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: Fix early error path in bch2_fs_btree_key_cache_exit()
Kent Overstreet [Fri, 3 May 2024 15:39:53 +0000 (11:39 -0400)]
bcachefs: Fix early error path in bch2_fs_btree_key_cache_exit()

Reported-by: syzbot+a35cdb62ec34d44fb062@syzkaller.appspotmail.com
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: bucket_pos_to_bp_noerror()
Kent Overstreet [Fri, 3 May 2024 15:06:54 +0000 (11:06 -0400)]
bcachefs: bucket_pos_to_bp_noerror()

We don't want the assert when we're checking if the backpointer is
valid.

Reported-by: syzbot+bf7215c0525098e7747a@syzkaller.appspotmail.com
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: don't free error pointers
Kent Overstreet [Fri, 3 May 2024 14:55:17 +0000 (10:55 -0400)]
bcachefs: don't free error pointers

Reported-by: syzbot+3333603f569fc2ef258c@syzkaller.appspotmail.com
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agobcachefs: Fix a scheduler splat in __bch2_next_write_buffer_flush_journal_buf()
Kent Overstreet [Mon, 6 May 2024 14:14:13 +0000 (10:14 -0400)]
bcachefs: Fix a scheduler splat in __bch2_next_write_buffer_flush_journal_buf()

We're using mutex_lock() inside a wait_event() conditional -
prepare_to_wait() has already flipped task state, so potentially
blocking ops need annotation.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
5 months agobcachefs: fix integer conversion bug
Kent Overstreet [Thu, 25 Apr 2024 18:41:17 +0000 (14:41 -0400)]
bcachefs: fix integer conversion bug

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
5 months agobcachefs: btree node scan now fills in sectors_written
Kent Overstreet [Thu, 25 Apr 2024 07:55:48 +0000 (03:55 -0400)]
bcachefs: btree node scan now fills in sectors_written

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
5 months agobcachefs: Remove accidental debug assert
Kent Overstreet [Mon, 22 Apr 2024 21:33:20 +0000 (17:33 -0400)]
bcachefs: Remove accidental debug assert

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
5 months agoLinux 6.9-rc6 v6.9-rc6
Linus Torvalds [Sun, 28 Apr 2024 20:47:24 +0000 (13:47 -0700)]
Linux 6.9-rc6

5 months agoMerge tag 'sched-urgent-2024-04-28' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Sun, 28 Apr 2024 19:11:26 +0000 (12:11 -0700)]
Merge tag 'sched-urgent-2024-04-28' of git://git./linux/kernel/git/tip/tip

Pull scheduler fixes from Ingo Molnar:

 - Fix EEVDF corner cases

 - Fix two nohz_full= related bugs that can cause boot crashes
   and warnings

* tag 'sched-urgent-2024-04-28' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  sched/isolation: Fix boot crash when maxcpus < first housekeeping CPU
  sched/isolation: Prevent boot crash when the boot CPU is nohz_full
  sched/eevdf: Prevent vlag from going out of bounds in reweight_eevdf()
  sched/eevdf: Fix miscalculation in reweight_entity() when se is not curr
  sched/eevdf: Always update V if se->on_rq when reweighting

5 months agoMerge tag 'x86-urgent-2024-04-28' of git://git.kernel.org/pub/scm/linux/kernel/git...
Linus Torvalds [Sun, 28 Apr 2024 18:58:16 +0000 (11:58 -0700)]
Merge tag 'x86-urgent-2024-04-28' of git://git./linux/kernel/git/tip/tip

Pull x86 fixes from Ingo Molnar:

 - Make the CPU_MITIGATIONS=n interaction with conflicting
   mitigation-enabling boot parameters a bit saner.

 - Re-enable CPU mitigations by default on non-x86

 - Fix TDX shared bit propagation on mprotect()

 - Fix potential show_regs() system hang when PKE initialization
   is not fully finished yet.

 - Add the 0x10-0x1f model IDs to the Zen5 range

 - Harden #VC instruction emulation some more

* tag 'x86-urgent-2024-04-28' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  cpu: Ignore "mitigations" kernel parameter if CPU_MITIGATIONS=n
  cpu: Re-enable CPU mitigations by default for !X86 architectures
  x86/tdx: Preserve shared bit on mprotect()
  x86/cpu: Fix check for RDPKRU in __show_regs()
  x86/CPU/AMD: Add models 0x10-0x1f to the Zen5 range
  x86/sev: Check for MWAITX and MONITORX opcodes in the #VC handler

5 months agoMerge tag 'irq-urgent-2024-04-28' of git://git.kernel.org/pub/scm/linux/kernel/git...
Linus Torvalds [Sun, 28 Apr 2024 18:51:13 +0000 (11:51 -0700)]
Merge tag 'irq-urgent-2024-04-28' of git://git./linux/kernel/git/tip/tip

Pull irq fix from Ingo Molnar:
 "Fix a double free bug in the init error path of the GICv3 irqchip
  driver"

* tag 'irq-urgent-2024-04-28' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  irqchip/gic-v3-its: Prevent double free on error

5 months agosched/isolation: Fix boot crash when maxcpus < first housekeeping CPU
Oleg Nesterov [Sat, 13 Apr 2024 14:17:46 +0000 (16:17 +0200)]
sched/isolation: Fix boot crash when maxcpus < first housekeeping CPU

housekeeping_setup() checks cpumask_intersects(present, online) to ensure
that the kernel will have at least one housekeeping CPU after smp_init(),
but this doesn't work if the maxcpus= kernel parameter limits the number of
processors available after bootup.

For example, a kernel with "maxcpus=2 nohz_full=0-2" parameters crashes at
boot time on a virtual machine with 4 CPUs.

Change housekeeping_setup() to use cpumask_first_and() and check that the
returned CPU number is valid and less than setup_max_cpus.

Another corner case is "nohz_full=0" on a machine with a single CPU or with
the maxcpus=1 kernel argument. In this case non_housekeeping_mask is empty
and tick_nohz_full_setup() makes no sense. And indeed, the kernel hits the
WARN_ON(tick_nohz_full_running) in tick_sched_do_timer().

And how should the kernel interpret the "nohz_full=" parameter? It should
be silently ignored, but currently cpulist_parse() happily returns the
empty cpumask and this leads to the same problem.

Change housekeeping_setup() to check cpumask_empty(non_housekeeping_mask)
and do nothing in this case.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Phil Auld <pauld@redhat.com>
Acked-by: Frederic Weisbecker <frederic@kernel.org>
Link: https://lore.kernel.org/r/20240413141746.GA10008@redhat.com