All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Boris Burkov <boris@bur.io>
Cc: linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: Re: [PATCH v2 1/4] btrfs: use ffe_ctl in btrfs allocator tracepoints
Date: Fri, 18 Nov 2022 17:51:12 +0100	[thread overview]
Message-ID: <20221118165112.GU5824@twin.jikos.cz> (raw)
In-Reply-To: <ef44014bc0c5599a0cc7034d9912a4151e3c8e3b.1668626092.git.boris@bur.io>

On Wed, Nov 16, 2022 at 11:22:02AM -0800, Boris Burkov wrote:
> The allocator tracepoints currently have a pile of values from ffe_ctl.
> In modifying the allocator and adding more tracepoints, I found myself
> adding to the already long argument list of the tracepoints. It makes it
> a lot simpler to just send in the ffe_ctl itself.
> 
> Signed-off-by: Boris Burkov <boris@bur.io>
> ---
>  fs/btrfs/extent-tree.c       | 91 ++----------------------------------
>  fs/btrfs/extent-tree.h       | 75 +++++++++++++++++++++++++++++
>  fs/btrfs/super.c             |  1 +
>  include/trace/events/btrfs.h | 41 ++++++++--------
>  4 files changed, 102 insertions(+), 106 deletions(-)
> 
> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> index 17f599027c3d..defef7caddbb 100644
> --- a/fs/btrfs/extent-tree.c
> +++ b/fs/btrfs/extent-tree.c
> @@ -16,7 +16,7 @@
>  #include <linux/percpu_counter.h>
>  #include <linux/lockdep.h>
>  #include <linux/crc32c.h>
> -#include "misc.h"
> +#include "extent-tree.h"
>  #include "tree-log.h"
>  #include "disk-io.h"
>  #include "print-tree.h"
> @@ -31,7 +31,6 @@
>  #include "space-info.h"
>  #include "block-rsv.h"
>  #include "delalloc-space.h"
> -#include "block-group.h"
>  #include "discard.h"
>  #include "rcu-string.h"
>  #include "zoned.h"
> @@ -3449,81 +3448,6 @@ btrfs_release_block_group(struct btrfs_block_group *cache,
>  	btrfs_put_block_group(cache);
>  }
>  
> -enum btrfs_extent_allocation_policy {
> -	BTRFS_EXTENT_ALLOC_CLUSTERED,
> -	BTRFS_EXTENT_ALLOC_ZONED,
> -};
> -
> -/*
> - * Structure used internally for find_free_extent() function.  Wraps needed
> - * parameters.
> - */
> -struct find_free_extent_ctl {
> -	/* Basic allocation info */
> -	u64 ram_bytes;
> -	u64 num_bytes;
> -	u64 min_alloc_size;
> -	u64 empty_size;
> -	u64 flags;
> -	int delalloc;
> -
> -	/* Where to start the search inside the bg */
> -	u64 search_start;
> -
> -	/* For clustered allocation */
> -	u64 empty_cluster;
> -	struct btrfs_free_cluster *last_ptr;
> -	bool use_cluster;
> -
> -	bool have_caching_bg;
> -	bool orig_have_caching_bg;
> -
> -	/* Allocation is called for tree-log */
> -	bool for_treelog;
> -
> -	/* Allocation is called for data relocation */
> -	bool for_data_reloc;
> -
> -	/* RAID index, converted from flags */
> -	int index;
> -
> -	/*
> -	 * Current loop number, check find_free_extent_update_loop() for details
> -	 */
> -	int loop;
> -
> -	/*
> -	 * Whether we're refilling a cluster, if true we need to re-search
> -	 * current block group but don't try to refill the cluster again.
> -	 */
> -	bool retry_clustered;
> -
> -	/*
> -	 * Whether we're updating free space cache, if true we need to re-search
> -	 * current block group but don't try updating free space cache again.
> -	 */
> -	bool retry_unclustered;
> -
> -	/* If current block group is cached */
> -	int cached;
> -
> -	/* Max contiguous hole found */
> -	u64 max_extent_size;
> -
> -	/* Total free space from free space cache, not always contiguous */
> -	u64 total_free_space;
> -
> -	/* Found result */
> -	u64 found_offset;
> -
> -	/* Hint where to start looking for an empty space */
> -	u64 hint_byte;
> -
> -	/* Allocation policy */
> -	enum btrfs_extent_allocation_policy policy;
> -};
> -
> -
>  /*
>   * Helper function for find_free_extent().
>   *
> @@ -3555,8 +3479,7 @@ static int find_free_extent_clustered(struct btrfs_block_group *bg,
>  	if (offset) {
>  		/* We have a block, we're done */
>  		spin_unlock(&last_ptr->refill_lock);
> -		trace_btrfs_reserve_extent_cluster(cluster_bg,
> -				ffe_ctl->search_start, ffe_ctl->num_bytes);
> +		trace_btrfs_reserve_extent_cluster(cluster_bg, ffe_ctl);
>  		*cluster_bg_ret = cluster_bg;
>  		ffe_ctl->found_offset = offset;
>  		return 0;
> @@ -3606,10 +3529,8 @@ static int find_free_extent_clustered(struct btrfs_block_group *bg,
>  		if (offset) {
>  			/* We found one, proceed */
>  			spin_unlock(&last_ptr->refill_lock);
> -			trace_btrfs_reserve_extent_cluster(bg,
> -					ffe_ctl->search_start,
> -					ffe_ctl->num_bytes);
>  			ffe_ctl->found_offset = offset;
> +			trace_btrfs_reserve_extent_cluster(bg, ffe_ctl);
>  			return 0;
>  		}
>  	} else if (!ffe_ctl->cached && ffe_ctl->loop > LOOP_CACHING_NOWAIT &&
> @@ -4292,8 +4213,7 @@ static noinline int find_free_extent(struct btrfs_root *root,
>  	ins->objectid = 0;
>  	ins->offset = 0;
>  
> -	trace_find_free_extent(root, ffe_ctl->num_bytes, ffe_ctl->empty_size,
> -			       ffe_ctl->flags);
> +	trace_find_free_extent(root, ffe_ctl);
>  
>  	space_info = btrfs_find_space_info(fs_info, ffe_ctl->flags);
>  	if (!space_info) {
> @@ -4464,8 +4384,7 @@ static noinline int find_free_extent(struct btrfs_root *root,
>  		ins->objectid = ffe_ctl->search_start;
>  		ins->offset = ffe_ctl->num_bytes;
>  
> -		trace_btrfs_reserve_extent(block_group, ffe_ctl->search_start,
> -					   ffe_ctl->num_bytes);
> +		trace_btrfs_reserve_extent(block_group, ffe_ctl);
>  		btrfs_release_block_group(block_group, ffe_ctl->delalloc);
>  		break;
>  loop:
> diff --git a/fs/btrfs/extent-tree.h b/fs/btrfs/extent-tree.h
> index ae5425253603..f1085226d785 100644
> --- a/fs/btrfs/extent-tree.h
> +++ b/fs/btrfs/extent-tree.h
> @@ -3,6 +3,81 @@
>  #ifndef BTRFS_EXTENT_TREE_H
>  #define BTRFS_EXTENT_TREE_H
>  
> +#include "ctree.h"

The ctree.h should not be included but either all types forward declared
or with some more preparatory work.

https://lore.kernel.org/linux-btrfs/20221014122232.GG13389@twin.jikos.cz/

  parent reply	other threads:[~2022-11-18 16:51 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-16 19:22 [PATCH v2 0/4] btrfs: data block group size classes Boris Burkov
2022-11-16 19:22 ` [PATCH v2 1/4] btrfs: use ffe_ctl in btrfs allocator tracepoints Boris Burkov
2022-11-17  7:33   ` Johannes Thumshirn
2022-11-17 20:16   ` Anand Jain
2022-11-18 16:51   ` David Sterba [this message]
2022-11-16 19:22 ` [PATCH v2 2/4] btrfs: add more ffe tracepoints Boris Burkov
2022-11-18  8:35   ` Johannes Thumshirn
2022-11-16 19:22 ` [PATCH v2 3/4] btrfs: introduce size class to block group allocator Boris Burkov
2022-11-16 19:22 ` [PATCH v2 4/4] btrfs: load block group size class when caching Boris Burkov
2022-11-17  9:12   ` kernel test robot
2022-11-17  9:22   ` kernel test robot
2022-11-18 16:56 ` [PATCH v2 0/4] btrfs: data block group size classes David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221118165112.GU5824@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=boris@bur.io \
    --cc=kernel-team@fb.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.