diff mbox

Regression caused by using node_to_bdi()

Message ID 552A57F8.7020002@plexistor.com (mailing list archive)
State New, archived
Headers show

Commit Message

Boaz Harrosh April 12, 2015, 11:33 a.m. UTC
On 04/10/2015 02:25 PM, Zhao Lei wrote:
> Hi, Christoph Hellwig
> 
> resend: + cc lkml, linux-fsdevel
> 
> Since there is no response for my last mail, I worry that some problem in
> the mail system, please allow me to resend it.
> 
> I found regression in v4.0-rc1 caused by this patch:
>  Author: Christoph Hellwig <hch@lst.de>
>  Date:   Wed Jan 14 10:42:36 2015 +0100
>  fs: export inode_to_bdi and use it in favor of mapping->backing_dev_info
> 
<>
> Result is following:
>  v3.19-rc1: testcnt=40 average=135.677 range=[132.460,139.130] stdev=1.610 cv=1.19%
>  v4.0-rc1: testcnt=40 average=130.970 range=[127.980,132.050] stdev=1.012 cv=0.77%
> 
> Then I bisect above case between v3.19-rc1 and v4.0-rc1, and found
> this patch caused the regresstion.
> 
> Maybe it is because kernel need more time to call node_to_bdi(),
> compared with "using inode->i_mapping->backing_dev_info directly" in
> old code.
> 
> Is there some way to speed up it(inline, or some access some variant
> in struct directly, ...)?
> 

Christoph hi

Both node_to_bdi() and sb_is_blkdev_sb() 
 (and I_BDEV() && blk_get_backing_dev_info())
Are an exported function calls.

Can we not make blockdev_superblock->s_bdi == NULL,
and then optimize-out the call to sb_is_blkdev_sb() to only
that case. Something like:

---



--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Boaz Harrosh April 12, 2015, 2:39 p.m. UTC | #1
On 04/12/2015 02:33 PM, Boaz Harrosh wrote:
> On 04/10/2015 02:25 PM, Zhao Lei wrote:
>> Hi, Christoph Hellwig
>>
<>
>>
>> Is there some way to speed up it(inline, or some access some variant
>> in struct directly, ...)?
>>
> 
> Christoph hi
> 
> Both node_to_bdi() and sb_is_blkdev_sb() 
>  (and I_BDEV() && blk_get_backing_dev_info())
> Are an exported function calls.
> 
> Can we not make blockdev_superblock->s_bdi == NULL,
> and then optimize-out the call to sb_is_blkdev_sb() to only
> that case. Something like:
> 
> ---
> 
> diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
> index 32a8bbd..e0375e1 100644
> --- a/fs/fs-writeback.c
> +++ b/fs/fs-writeback.c
> @@ -78,7 +78,7 @@ int writeback_in_progress(struct backing_dev_info *bdi)
>  }
>  EXPORT_SYMBOL(writeback_in_progress);
>  
> -struct backing_dev_info *inode_to_bdi(struct inode *inode)
> +struct backing_dev_info *__inode_to_bdi(struct inode *inode)
>  {
>  	struct super_block *sb;
>  
> @@ -92,7 +92,7 @@ struct backing_dev_info *inode_to_bdi(struct inode *inode)
>  #endif
>  	return sb->s_bdi;
>  }
> -EXPORT_SYMBOL_GPL(inode_to_bdi);
> +EXPORT_SYMBOL_GPL(__inode_to_bdi);
>  
>  static inline struct inode *wb_inode(struct list_head *head)
>  {
> diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h
> index aff923a..7d172f5 100644
> --- a/include/linux/backing-dev.h
> +++ b/include/linux/backing-dev.h
> @@ -107,7 +107,16 @@ struct backing_dev_info {
>  #endif
>  };
>  
> -struct backing_dev_info *inode_to_bdi(struct inode *inode);
> +struct backing_dev_info *__inode_to_bdi(struct inode *inode);
> +
> +static inline
> +struct backing_dev_info *inode_to_bdi(struct inode *inode)
> +{
> +	if (!inode || !inode->i_sb)
> +		return __inode_to_bdi(inode);
> +
> +	return inode->i_sb->s_bdi;
> +}
>  

This patch actually boots. Lei could you please test to see
if it fixes your slowness?

Thanks
Boaz

>  int __must_check bdi_init(struct backing_dev_info *bdi);
>  void bdi_destroy(struct backing_dev_info *bdi);
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Zhaolei April 13, 2015, 1:20 a.m. UTC | #2
Hi, Boaz

> -----Original Message-----
> From: Boaz Harrosh [mailto:boaz@plexistor.com]
> Sent: Sunday, April 12, 2015 10:39 PM
> To: Boaz Harrosh; Zhao Lei; 'Christoph Hellwig'
> Cc: linux-fsdevel@vger.kernel.org; 'Jan Kara'; 'Jens Axboe'; 'LKML'
> Subject: Re: Regression caused by using node_to_bdi()
> 
> On 04/12/2015 02:33 PM, Boaz Harrosh wrote:
> > On 04/10/2015 02:25 PM, Zhao Lei wrote:
> >> Hi, Christoph Hellwig
> >>
> <>
> >>
> >> Is there some way to speed up it(inline, or some access some variant
> >> in struct directly, ...)?
> >>
> >
> > Christoph hi
> >
> > Both node_to_bdi() and sb_is_blkdev_sb()  (and I_BDEV() &&
> > blk_get_backing_dev_info()) Are an exported function calls.
> >
> > Can we not make blockdev_superblock->s_bdi == NULL, and then
> > optimize-out the call to sb_is_blkdev_sb() to only that case.
> > Something like:
> >
> > ---
> >
> > diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index
> > 32a8bbd..e0375e1 100644
> > --- a/fs/fs-writeback.c
> > +++ b/fs/fs-writeback.c
> > @@ -78,7 +78,7 @@ int writeback_in_progress(struct backing_dev_info
> > *bdi)  }  EXPORT_SYMBOL(writeback_in_progress);
> >
> > -struct backing_dev_info *inode_to_bdi(struct inode *inode)
> > +struct backing_dev_info *__inode_to_bdi(struct inode *inode)
> >  {
> >  	struct super_block *sb;
> >
> > @@ -92,7 +92,7 @@ struct backing_dev_info *inode_to_bdi(struct inode
> > *inode)  #endif
> >  	return sb->s_bdi;
> >  }
> > -EXPORT_SYMBOL_GPL(inode_to_bdi);
> > +EXPORT_SYMBOL_GPL(__inode_to_bdi);
> >
> >  static inline struct inode *wb_inode(struct list_head *head)  { diff
> > --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h
> > index aff923a..7d172f5 100644
> > --- a/include/linux/backing-dev.h
> > +++ b/include/linux/backing-dev.h
> > @@ -107,7 +107,16 @@ struct backing_dev_info {  #endif  };
> >
> > -struct backing_dev_info *inode_to_bdi(struct inode *inode);
> > +struct backing_dev_info *__inode_to_bdi(struct inode *inode);
> > +
> > +static inline
> > +struct backing_dev_info *inode_to_bdi(struct inode *inode) {
> > +	if (!inode || !inode->i_sb)
> > +		return __inode_to_bdi(inode);
> > +
> > +	return inode->i_sb->s_bdi;
> > +}
> >
> 
> This patch actually boots. Lei could you please test to see if it fixes your
> slowness?
> 
Thanks, I'll test this patch.

Thanks
Zhaolei

> Thanks
> Boaz
> 
> >  int __must_check bdi_init(struct backing_dev_info *bdi);  void
> > bdi_destroy(struct backing_dev_info *bdi);
> >



--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Zhaolei April 13, 2015, 7 a.m. UTC | #3
Hi, Boaz

> -----Original Message-----
> From: Boaz Harrosh [mailto:boaz@plexistor.com]
> Sent: Sunday, April 12, 2015 10:39 PM
> To: Boaz Harrosh; Zhao Lei; 'Christoph Hellwig'
> Cc: linux-fsdevel@vger.kernel.org; 'Jan Kara'; 'Jens Axboe'; 'LKML'
> Subject: Re: Regression caused by using node_to_bdi()
> 
> On 04/12/2015 02:33 PM, Boaz Harrosh wrote:
> > On 04/10/2015 02:25 PM, Zhao Lei wrote:
> >> Hi, Christoph Hellwig
> >>
> <>
> >>
> >> Is there some way to speed up it(inline, or some access some variant
> >> in struct directly, ...)?
> >>
> >
> > Christoph hi
> >
> > Both node_to_bdi() and sb_is_blkdev_sb()  (and I_BDEV() &&
> > blk_get_backing_dev_info()) Are an exported function calls.
> >
> > Can we not make blockdev_superblock->s_bdi == NULL, and then
> > optimize-out the call to sb_is_blkdev_sb() to only that case.
> > Something like:
> >
> > ---
> >
> > diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index
> > 32a8bbd..e0375e1 100644
> > --- a/fs/fs-writeback.c
> > +++ b/fs/fs-writeback.c
> > @@ -78,7 +78,7 @@ int writeback_in_progress(struct backing_dev_info
> > *bdi)  }  EXPORT_SYMBOL(writeback_in_progress);
> >
> > -struct backing_dev_info *inode_to_bdi(struct inode *inode)
> > +struct backing_dev_info *__inode_to_bdi(struct inode *inode)
> >  {
> >  	struct super_block *sb;
> >
> > @@ -92,7 +92,7 @@ struct backing_dev_info *inode_to_bdi(struct inode
> > *inode)  #endif
> >  	return sb->s_bdi;
> >  }
> > -EXPORT_SYMBOL_GPL(inode_to_bdi);
> > +EXPORT_SYMBOL_GPL(__inode_to_bdi);
> >
> >  static inline struct inode *wb_inode(struct list_head *head)  { diff
> > --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h
> > index aff923a..7d172f5 100644
> > --- a/include/linux/backing-dev.h
> > +++ b/include/linux/backing-dev.h
> > @@ -107,7 +107,16 @@ struct backing_dev_info {  #endif  };
> >
> > -struct backing_dev_info *inode_to_bdi(struct inode *inode);
> > +struct backing_dev_info *__inode_to_bdi(struct inode *inode);
> > +
> > +static inline
> > +struct backing_dev_info *inode_to_bdi(struct inode *inode) {
> > +	if (!inode || !inode->i_sb)
> > +		return __inode_to_bdi(inode);
> > +
> > +	return inode->i_sb->s_bdi;
> > +}
> >
> 
> This patch actually boots. Lei could you please test to see if it fixes your
> slowness?
> 
The good news is this patch passed compile and 10-time tests.
The bad news is it have more performance down(strange)...

v3.19-rc1              : io_speed: valcnt=10 avg=214.688 range=[211.460,216.190] diff=  2.24% stdev=1.417 cv=0.66%
v4.0-rc1               : io_speed: valcnt=10 avg=204.917 range=[203.370,205.890] diff=  1.24% stdev=0.663 cv=0.32%
v4.0-rc1_00001_82ad06  : io_speed: valcnt=10 avg=189.337 range=[186.280,192.060] diff=  3.10% stdev=2.305 cv=1.22% *<- this patch

I applied this patch on top of v4.0-rc1.

> Thanks
> Boaz
> 
> >  int __must_check bdi_init(struct backing_dev_info *bdi);  void
> > bdi_destroy(struct backing_dev_info *bdi);
> >



--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Zhaolei April 13, 2015, 10:22 a.m. UTC | #4
Hi, Boaz

> -----Original Message-----
> From: Zhao Lei [mailto:zhaolei@cn.fujitsu.com]
> Sent: Monday, April 13, 2015 3:00 PM
> To: 'Boaz Harrosh'; 'Christoph Hellwig'
> Cc: 'linux-fsdevel@vger.kernel.org'; 'Jan Kara'; 'Jens Axboe'; 'LKML'
> Subject: RE: Regression caused by using node_to_bdi()
> 
> Hi, Boaz
> 
> > -----Original Message-----
> > From: Boaz Harrosh [mailto:boaz@plexistor.com]
> > Sent: Sunday, April 12, 2015 10:39 PM
> > To: Boaz Harrosh; Zhao Lei; 'Christoph Hellwig'
> > Cc: linux-fsdevel@vger.kernel.org; 'Jan Kara'; 'Jens Axboe'; 'LKML'
> > Subject: Re: Regression caused by using node_to_bdi()
> >
> > On 04/12/2015 02:33 PM, Boaz Harrosh wrote:
> > > On 04/10/2015 02:25 PM, Zhao Lei wrote:
> > >> Hi, Christoph Hellwig
> > >>
> > <>
> > >>
> > >> Is there some way to speed up it(inline, or some access some
> > >> variant in struct directly, ...)?
> > >>
> > >
> > > Christoph hi
> > >
> > > Both node_to_bdi() and sb_is_blkdev_sb()  (and I_BDEV() &&
> > > blk_get_backing_dev_info()) Are an exported function calls.
> > >
> > > Can we not make blockdev_superblock->s_bdi == NULL, and then
> > > optimize-out the call to sb_is_blkdev_sb() to only that case.
> > > Something like:
> > >
> > > ---
> > >
> > > diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index
> > > 32a8bbd..e0375e1 100644
> > > --- a/fs/fs-writeback.c
> > > +++ b/fs/fs-writeback.c
> > > @@ -78,7 +78,7 @@ int writeback_in_progress(struct backing_dev_info
> > > *bdi)  }  EXPORT_SYMBOL(writeback_in_progress);
> > >
> > > -struct backing_dev_info *inode_to_bdi(struct inode *inode)
> > > +struct backing_dev_info *__inode_to_bdi(struct inode *inode)
> > >  {
> > >  	struct super_block *sb;
> > >
> > > @@ -92,7 +92,7 @@ struct backing_dev_info *inode_to_bdi(struct inode
> > > *inode)  #endif
> > >  	return sb->s_bdi;
> > >  }
> > > -EXPORT_SYMBOL_GPL(inode_to_bdi);
> > > +EXPORT_SYMBOL_GPL(__inode_to_bdi);
> > >
> > >  static inline struct inode *wb_inode(struct list_head *head)  {
> > > diff --git a/include/linux/backing-dev.h
> > > b/include/linux/backing-dev.h index aff923a..7d172f5 100644
> > > --- a/include/linux/backing-dev.h
> > > +++ b/include/linux/backing-dev.h
> > > @@ -107,7 +107,16 @@ struct backing_dev_info {  #endif  };
> > >
> > > -struct backing_dev_info *inode_to_bdi(struct inode *inode);
> > > +struct backing_dev_info *__inode_to_bdi(struct inode *inode);
> > > +
> > > +static inline
> > > +struct backing_dev_info *inode_to_bdi(struct inode *inode) {
> > > +	if (!inode || !inode->i_sb)
> > > +		return __inode_to_bdi(inode);
> > > +
> > > +	return inode->i_sb->s_bdi;
> > > +}
> > >
> >
> > This patch actually boots. Lei could you please test to see if it
> > fixes your slowness?
> >
> The good news is this patch passed compile and 10-time tests.
> The bad news is it have more performance down(strange)...
> 
> v3.19-rc1              : io_speed: valcnt=10 avg=214.688
> range=[211.460,216.190] diff=  2.24% stdev=1.417 cv=0.66%
> v4.0-rc1               : io_speed: valcnt=10 avg=204.917
> range=[203.370,205.890] diff=  1.24% stdev=0.663 cv=0.32%
> v4.0-rc1_00001_82ad06  : io_speed: valcnt=10 avg=189.337
> range=[186.280,192.060] diff=  3.10% stdev=2.305 cv=1.22% *<- this patch
> 
> I applied this patch on top of v4.0-rc1.
> 
A new bad news:
This patch make filesystem unstable.

My env entered to following command line in booting after
apply this patch to v4.0-rc1:

Welcome to emergency mode! After logging in, type "journalctl -xb: to view
System logs, ...
Give root password for maintenance
(or press Control-D to continue)

I confirmed this error message for more than 3 times.
(and confirmed no-problem without this patch)

In previous performance test(which get result in my last mail), I hadn't 
pay attention to that message, and just type Ctrl-D and begin test.

Thanks
Zhaolei

> > Thanks
> > Boaz
> >
> > >  int __must_check bdi_init(struct backing_dev_info *bdi);  void
> > > bdi_destroy(struct backing_dev_info *bdi);
> > >



--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jan Kara April 13, 2015, 12:21 p.m. UTC | #5
On Sun 12-04-15 14:33:12, Boaz Harrosh wrote:
> On 04/10/2015 02:25 PM, Zhao Lei wrote:
> > Hi, Christoph Hellwig
> > 
> > resend: + cc lkml, linux-fsdevel
> > 
> > Since there is no response for my last mail, I worry that some problem in
> > the mail system, please allow me to resend it.
> > 
> > I found regression in v4.0-rc1 caused by this patch:
> >  Author: Christoph Hellwig <hch@lst.de>
> >  Date:   Wed Jan 14 10:42:36 2015 +0100
> >  fs: export inode_to_bdi and use it in favor of mapping->backing_dev_info
> > 
> <>
> > Result is following:
> >  v3.19-rc1: testcnt=40 average=135.677 range=[132.460,139.130] stdev=1.610 cv=1.19%
> >  v4.0-rc1: testcnt=40 average=130.970 range=[127.980,132.050] stdev=1.012 cv=0.77%
> > 
> > Then I bisect above case between v3.19-rc1 and v4.0-rc1, and found
> > this patch caused the regresstion.
> > 
> > Maybe it is because kernel need more time to call node_to_bdi(),
> > compared with "using inode->i_mapping->backing_dev_info directly" in
> > old code.
> > 
> > Is there some way to speed up it(inline, or some access some variant
> > in struct directly, ...)?
> > 
> 
> Christoph hi
> 
> Both node_to_bdi() and sb_is_blkdev_sb() 
>  (and I_BDEV() && blk_get_backing_dev_info())
> Are an exported function calls.
> 
> Can we not make blockdev_superblock->s_bdi == NULL,
> and then optimize-out the call to sb_is_blkdev_sb() to only
> that case. Something like:
> 
> ---
> 
> diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
> index 32a8bbd..e0375e1 100644
> --- a/fs/fs-writeback.c
> +++ b/fs/fs-writeback.c
> @@ -78,7 +78,7 @@ int writeback_in_progress(struct backing_dev_info *bdi)
>  }
>  EXPORT_SYMBOL(writeback_in_progress);
>  
> -struct backing_dev_info *inode_to_bdi(struct inode *inode)
> +struct backing_dev_info *__inode_to_bdi(struct inode *inode)
>  {
>  	struct super_block *sb;
>  
> @@ -92,7 +92,7 @@ struct backing_dev_info *inode_to_bdi(struct inode *inode)
>  #endif
>  	return sb->s_bdi;
>  }
> -EXPORT_SYMBOL_GPL(inode_to_bdi);
> +EXPORT_SYMBOL_GPL(__inode_to_bdi);
>  
>  static inline struct inode *wb_inode(struct list_head *head)
>  {
> diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h
> index aff923a..7d172f5 100644
> --- a/include/linux/backing-dev.h
> +++ b/include/linux/backing-dev.h
> @@ -107,7 +107,16 @@ struct backing_dev_info {
>  #endif
>  };
>  
> -struct backing_dev_info *inode_to_bdi(struct inode *inode);
> +struct backing_dev_info *__inode_to_bdi(struct inode *inode);
> +
> +static inline
> +struct backing_dev_info *inode_to_bdi(struct inode *inode)
> +{
> +	if (!inode || !inode->i_sb)
> +		return __inode_to_bdi(inode);
> +
> +	return inode->i_sb->s_bdi;
> +}
  This is wrong for block-device inodes, isn't it?

							Honza
Boaz Harrosh April 13, 2015, 12:44 p.m. UTC | #6
On 04/13/2015 03:21 PM, Jan Kara wrote:
<>
>> -struct backing_dev_info *inode_to_bdi(struct inode *inode);
>> +struct backing_dev_info *__inode_to_bdi(struct inode *inode);
>> +
>> +static inline
>> +struct backing_dev_info *inode_to_bdi(struct inode *inode)
>> +{
>> +	if (!inode || !inode->i_sb)
>> +		return __inode_to_bdi(inode);
>> +
>> +	return inode->i_sb->s_bdi;
>> +}
>   This is wrong for block-device inodes, isn't it?

Rrr yes my bad I meant

+struct backing_dev_info *inode_to_bdi(struct inode *inode)
+{
+	if (!inode || !inode->i_sb || !inode->i_sb->s_bdi)
+		return __inode_to_bdi(inode);
+
+	return inode->i_sb->s_bdi;
+}

I was hopping that blockdev_superblock->s_bdi == NULL
because what sb_is_blkdev_sb() is doing is checking
for blockdev_superblock.

From code audit I do not see where it might be set but
I might have missed it.

Thanks Jan
Boaz

> 
> 							Honza
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index 32a8bbd..e0375e1 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -78,7 +78,7 @@  int writeback_in_progress(struct backing_dev_info *bdi)
 }
 EXPORT_SYMBOL(writeback_in_progress);
 
-struct backing_dev_info *inode_to_bdi(struct inode *inode)
+struct backing_dev_info *__inode_to_bdi(struct inode *inode)
 {
 	struct super_block *sb;
 
@@ -92,7 +92,7 @@  struct backing_dev_info *inode_to_bdi(struct inode *inode)
 #endif
 	return sb->s_bdi;
 }
-EXPORT_SYMBOL_GPL(inode_to_bdi);
+EXPORT_SYMBOL_GPL(__inode_to_bdi);
 
 static inline struct inode *wb_inode(struct list_head *head)
 {
diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h
index aff923a..7d172f5 100644
--- a/include/linux/backing-dev.h
+++ b/include/linux/backing-dev.h
@@ -107,7 +107,16 @@  struct backing_dev_info {
 #endif
 };
 
-struct backing_dev_info *inode_to_bdi(struct inode *inode);
+struct backing_dev_info *__inode_to_bdi(struct inode *inode);
+
+static inline
+struct backing_dev_info *inode_to_bdi(struct inode *inode)
+{
+	if (!inode || !inode->i_sb)
+		return __inode_to_bdi(inode);
+
+	return inode->i_sb->s_bdi;
+}
 
 int __must_check bdi_init(struct backing_dev_info *bdi);
 void bdi_destroy(struct backing_dev_info *bdi);