提交 26b47ff6 编写于 作者: M Miao Xie 提交者: Chris Mason

Btrfs: change the members' order of btrfs_space_info structure to reduce the cache miss

It is better that the position of the lock is close to the data which is
protected by it, because they may be in the same cache line, we will load
less cache lines when we access them. So we rearrange the members' position
of btrfs_space_info structure to make the lock be closer to the its data.
Signed-off-by: NMiao Xie <miaox@cn.fujitsu.com>
Reviewed-by: NDavid Sterba <dsterba@suse.cz>
Signed-off-by: NJosef Bacik <jbacik@fb.com>
Signed-off-by: NChris Mason <clm@fb.com>
上级 ffcfaf81
...@@ -1105,7 +1105,7 @@ struct btrfs_qgroup_limit_item { ...@@ -1105,7 +1105,7 @@ struct btrfs_qgroup_limit_item {
} __attribute__ ((__packed__)); } __attribute__ ((__packed__));
struct btrfs_space_info { struct btrfs_space_info {
u64 flags; spinlock_t lock;
u64 total_bytes; /* total bytes in the space, u64 total_bytes; /* total bytes in the space,
this doesn't take mirrors into account */ this doesn't take mirrors into account */
...@@ -1115,14 +1115,25 @@ struct btrfs_space_info { ...@@ -1115,14 +1115,25 @@ struct btrfs_space_info {
transaction finishes */ transaction finishes */
u64 bytes_reserved; /* total bytes the allocator has reserved for u64 bytes_reserved; /* total bytes the allocator has reserved for
current allocations */ current allocations */
u64 bytes_readonly; /* total bytes that are read only */
u64 bytes_may_use; /* number of bytes that may be used for u64 bytes_may_use; /* number of bytes that may be used for
delalloc/allocations */ delalloc/allocations */
u64 bytes_readonly; /* total bytes that are read only */
unsigned int full:1; /* indicates that we cannot allocate any more
chunks for this space */
unsigned int chunk_alloc:1; /* set if we are allocating a chunk */
unsigned int flush:1; /* set if we are trying to make space */
unsigned int force_alloc; /* set if we need to force a chunk
alloc for this space */
u64 disk_used; /* total bytes used on disk */ u64 disk_used; /* total bytes used on disk */
u64 disk_total; /* total bytes on disk, takes mirrors into u64 disk_total; /* total bytes on disk, takes mirrors into
account */ account */
u64 flags;
/* /*
* bytes_pinned is kept in line with what is actually pinned, as in * bytes_pinned is kept in line with what is actually pinned, as in
* we've called update_block_group and dropped the bytes_used counter * we've called update_block_group and dropped the bytes_used counter
...@@ -1135,21 +1146,11 @@ struct btrfs_space_info { ...@@ -1135,21 +1146,11 @@ struct btrfs_space_info {
*/ */
struct percpu_counter total_bytes_pinned; struct percpu_counter total_bytes_pinned;
unsigned int full:1; /* indicates that we cannot allocate any more
chunks for this space */
unsigned int chunk_alloc:1; /* set if we are allocating a chunk */
unsigned int flush:1; /* set if we are trying to make space */
unsigned int force_alloc; /* set if we need to force a chunk
alloc for this space */
struct list_head list; struct list_head list;
struct rw_semaphore groups_sem;
/* for block groups in our same type */ /* for block groups in our same type */
struct list_head block_groups[BTRFS_NR_RAID_TYPES]; struct list_head block_groups[BTRFS_NR_RAID_TYPES];
spinlock_t lock;
struct rw_semaphore groups_sem;
wait_queue_head_t wait; wait_queue_head_t wait;
struct kobject kobj; struct kobject kobj;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册