fs/ext4/bitmap.c | 5 ----- fs/ext4/ext4.h | 6 +++++- 2 files changed, 5 insertions(+), 6 deletions(-)
`ext4_count_free` is a one-line helper that is clearly better off
being inlined. This saves a handful instructions in `vmlinux` on x86.
Instruction estimates use `wc -l` on `objdump`
Before: 8539271
After : 8539248
So saves roughly 20 instructions
Signed-off-by: Noah Goldstein <goldstein.w.n@gmail.com>
---
fs/ext4/bitmap.c | 5 -----
fs/ext4/ext4.h | 6 +++++-
2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/fs/ext4/bitmap.c b/fs/ext4/bitmap.c
index f63e028c638c..c3cd2b878bbd 100644
--- a/fs/ext4/bitmap.c
+++ b/fs/ext4/bitmap.c
@@ -11,11 +11,6 @@
#include <linux/buffer_head.h>
#include "ext4.h"
-unsigned int ext4_count_free(char *bitmap, unsigned int numchars)
-{
- return numchars * BITS_PER_BYTE - memweight(bitmap, numchars);
-}
-
int ext4_inode_bitmap_csum_verify(struct super_block *sb, ext4_group_t group,
struct ext4_group_desc *gdp,
struct buffer_head *bh, int sz)
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 08b29c289da4..6e1d3c175a70 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -2675,7 +2675,11 @@ struct mmpd_data {
# define NORET_AND noreturn,
/* bitmap.c */
-extern unsigned int ext4_count_free(char *bitmap, unsigned numchars);
+static inline unsigned int ext4_count_free(char *bitmap, unsigned int numchars)
+{
+ return numchars * BITS_PER_BYTE - memweight(bitmap, numchars);
+}
+
void ext4_inode_bitmap_csum_set(struct super_block *sb, ext4_group_t group,
struct ext4_group_desc *gdp,
struct buffer_head *bh, int sz);
--
2.34.1
On Thu 20-04-23 20:47:49, Noah Goldstein wrote:
> `ext4_count_free` is a one-line helper that is clearly better off
> being inlined. This saves a handful instructions in `vmlinux` on x86.
>
> Instruction estimates use `wc -l` on `objdump`
> Before: 8539271
> After : 8539248
>
> So saves roughly 20 instructions
>
> Signed-off-by: Noah Goldstein <goldstein.w.n@gmail.com>
Looks fine. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> fs/ext4/bitmap.c | 5 -----
> fs/ext4/ext4.h | 6 +++++-
> 2 files changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/fs/ext4/bitmap.c b/fs/ext4/bitmap.c
> index f63e028c638c..c3cd2b878bbd 100644
> --- a/fs/ext4/bitmap.c
> +++ b/fs/ext4/bitmap.c
> @@ -11,11 +11,6 @@
> #include <linux/buffer_head.h>
> #include "ext4.h"
>
> -unsigned int ext4_count_free(char *bitmap, unsigned int numchars)
> -{
> - return numchars * BITS_PER_BYTE - memweight(bitmap, numchars);
> -}
> -
> int ext4_inode_bitmap_csum_verify(struct super_block *sb, ext4_group_t group,
> struct ext4_group_desc *gdp,
> struct buffer_head *bh, int sz)
> diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
> index 08b29c289da4..6e1d3c175a70 100644
> --- a/fs/ext4/ext4.h
> +++ b/fs/ext4/ext4.h
> @@ -2675,7 +2675,11 @@ struct mmpd_data {
> # define NORET_AND noreturn,
>
> /* bitmap.c */
> -extern unsigned int ext4_count_free(char *bitmap, unsigned numchars);
> +static inline unsigned int ext4_count_free(char *bitmap, unsigned int numchars)
> +{
> + return numchars * BITS_PER_BYTE - memweight(bitmap, numchars);
> +}
> +
> void ext4_inode_bitmap_csum_set(struct super_block *sb, ext4_group_t group,
> struct ext4_group_desc *gdp,
> struct buffer_head *bh, int sz);
> --
> 2.34.1
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
On Mon, Apr 24, 2023 at 11:24 AM Jan Kara <jack@suse.cz> wrote:
>
> On Thu 20-04-23 20:47:49, Noah Goldstein wrote:
> > `ext4_count_free` is a one-line helper that is clearly better off
> > being inlined. This saves a handful instructions in `vmlinux` on x86.
> >
> > Instruction estimates use `wc -l` on `objdump`
> > Before: 8539271
> > After : 8539248
> >
> > So saves roughly 20 instructions
> >
> > Signed-off-by: Noah Goldstein <goldstein.w.n@gmail.com>
>
> Looks fine. Feel free to add:
>
> Reviewed-by: Jan Kara <jack@suse.cz>
>
Done, thank you.
> Honza
>
> > ---
> > fs/ext4/bitmap.c | 5 -----
> > fs/ext4/ext4.h | 6 +++++-
> > 2 files changed, 5 insertions(+), 6 deletions(-)
> >
> > diff --git a/fs/ext4/bitmap.c b/fs/ext4/bitmap.c
> > index f63e028c638c..c3cd2b878bbd 100644
> > --- a/fs/ext4/bitmap.c
> > +++ b/fs/ext4/bitmap.c
> > @@ -11,11 +11,6 @@
> > #include <linux/buffer_head.h>
> > #include "ext4.h"
> >
> > -unsigned int ext4_count_free(char *bitmap, unsigned int numchars)
> > -{
> > - return numchars * BITS_PER_BYTE - memweight(bitmap, numchars);
> > -}
> > -
> > int ext4_inode_bitmap_csum_verify(struct super_block *sb, ext4_group_t group,
> > struct ext4_group_desc *gdp,
> > struct buffer_head *bh, int sz)
> > diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
> > index 08b29c289da4..6e1d3c175a70 100644
> > --- a/fs/ext4/ext4.h
> > +++ b/fs/ext4/ext4.h
> > @@ -2675,7 +2675,11 @@ struct mmpd_data {
> > # define NORET_AND noreturn,
> >
> > /* bitmap.c */
> > -extern unsigned int ext4_count_free(char *bitmap, unsigned numchars);
> > +static inline unsigned int ext4_count_free(char *bitmap, unsigned int numchars)
> > +{
> > + return numchars * BITS_PER_BYTE - memweight(bitmap, numchars);
> > +}
> > +
> > void ext4_inode_bitmap_csum_set(struct super_block *sb, ext4_group_t group,
> > struct ext4_group_desc *gdp,
> > struct buffer_head *bh, int sz);
> > --
> > 2.34.1
> >
> --
> Jan Kara <jack@suse.com>
> SUSE Labs, CR
`ext4_count_free` is a one-line helper that is clearly better off
being inlined. This saves a handful instructions in `vmlinux` on x86.
Instruction estimates use `wc -l` on `objdump`
Before: 8539271
After : 8539248
So saves roughly 20 instructions
Signed-off-by: Noah Goldstein <goldstein.w.n@gmail.com>
Reviewed-by: Jan Kara <jack@suse.cz>
---
fs/ext4/bitmap.c | 5 -----
fs/ext4/ext4.h | 6 +++++-
2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/fs/ext4/bitmap.c b/fs/ext4/bitmap.c
index f63e028c638c..c3cd2b878bbd 100644
--- a/fs/ext4/bitmap.c
+++ b/fs/ext4/bitmap.c
@@ -11,11 +11,6 @@
#include <linux/buffer_head.h>
#include "ext4.h"
-unsigned int ext4_count_free(char *bitmap, unsigned int numchars)
-{
- return numchars * BITS_PER_BYTE - memweight(bitmap, numchars);
-}
-
int ext4_inode_bitmap_csum_verify(struct super_block *sb, ext4_group_t group,
struct ext4_group_desc *gdp,
struct buffer_head *bh, int sz)
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 08b29c289da4..6e1d3c175a70 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -2675,7 +2675,11 @@ struct mmpd_data {
# define NORET_AND noreturn,
/* bitmap.c */
-extern unsigned int ext4_count_free(char *bitmap, unsigned numchars);
+static inline unsigned int ext4_count_free(char *bitmap, unsigned int numchars)
+{
+ return numchars * BITS_PER_BYTE - memweight(bitmap, numchars);
+}
+
void ext4_inode_bitmap_csum_set(struct super_block *sb, ext4_group_t group,
struct ext4_group_desc *gdp,
struct buffer_head *bh, int sz);
--
2.34.1
© 2016 - 2025 Red Hat, Inc.