All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-mm@kvack.org
Subject: Re: [patch 4/8] mm: allow not updating BDI stats in end_page_writeback()
Date: Mon, 17 Mar 2008 22:04:31 -0700	[thread overview]
Message-ID: <20080317220431.a8507e29.akpm@linux-foundation.org> (raw)
In-Reply-To: <20080317191945.122011759@szeredi.hu>

On Mon, 17 Mar 2008 20:19:12 +0100 Miklos Szeredi <miklos@szeredi.hu> wrote:

> From: Miklos Szeredi <mszeredi@suse.cz>
> 
> Fuse's writepage will need to clear page writeback separately from
> updating the per BDI counters.
> 
> This patch renames end_page_writeback() to __end_page_writeback() and
> adds a boolean parameter to indicate if the per BDI stats need to be
> updated.
> 
> Regular callers get an inline end_page_writeback() without the boolean
> parameter.
> 
> ...
> 
> Index: linux/include/linux/page-flags.h
> ===================================================================
> --- linux.orig/include/linux/page-flags.h	2008-03-17 18:24:13.000000000 +0100
> +++ linux/include/linux/page-flags.h	2008-03-17 18:25:53.000000000 +0100
> @@ -300,7 +300,7 @@ struct page;	/* forward declaration */
>  
>  extern void cancel_dirty_page(struct page *page, unsigned int account_size);
>  
> -int test_clear_page_writeback(struct page *page);
> +int test_clear_page_writeback(struct page *page, bool bdi_stats);
>  int test_set_page_writeback(struct page *page);
>  
>  static inline void set_page_writeback(struct page *page)
> Index: linux/include/linux/pagemap.h
> ===================================================================
> --- linux.orig/include/linux/pagemap.h	2008-03-17 18:24:13.000000000 +0100
> +++ linux/include/linux/pagemap.h	2008-03-17 18:25:53.000000000 +0100
> @@ -223,7 +223,12 @@ static inline void wait_on_page_writebac
>  		wait_on_page_bit(page, PG_writeback);
>  }
>  
> -extern void end_page_writeback(struct page *page);
> +extern void __end_page_writeback(struct page *page, bool bdi_stats);
> +
> +static inline void end_page_writeback(struct page *page)
> +{
> +	__end_page_writeback(page, true);
> +}
>  
>  /*
>   * Fault a userspace page into pagetables.  Return non-zero on a fault.
> Index: linux/mm/filemap.c
> ===================================================================
> --- linux.orig/mm/filemap.c	2008-03-17 18:25:38.000000000 +0100
> +++ linux/mm/filemap.c	2008-03-17 18:25:53.000000000 +0100
> @@ -574,19 +574,20 @@ EXPORT_SYMBOL(unlock_page);
>  /**
>   * end_page_writeback - end writeback against a page
>   * @page: the page
> + * @bdi_stats: update the per-bdi writeback counter
>   */
> -void end_page_writeback(struct page *page)
> +void __end_page_writeback(struct page *page, bool bdi_stats)
>  {
>  	if (TestClearPageReclaim(page))
>  		rotate_reclaimable_page(page);
>  
> -	if (!test_clear_page_writeback(page))
> +	if (!test_clear_page_writeback(page, bdi_stats))
>  		BUG();
>  
>  	smp_mb__after_clear_bit();
>  	wake_up_page(page, PG_writeback);
>  }
> -EXPORT_SYMBOL(end_page_writeback);
> +EXPORT_SYMBOL(__end_page_writeback);
>  
>  /**
>   * __lock_page - get a lock on the page, assuming we need to sleep to get it
> Index: linux/mm/page-writeback.c
> ===================================================================
> --- linux.orig/mm/page-writeback.c	2008-03-17 18:25:17.000000000 +0100
> +++ linux/mm/page-writeback.c	2008-03-17 18:25:53.000000000 +0100
> @@ -1242,7 +1242,7 @@ int clear_page_dirty_for_io(struct page 
>  }
>  EXPORT_SYMBOL(clear_page_dirty_for_io);
>  
> -int test_clear_page_writeback(struct page *page)
> +int test_clear_page_writeback(struct page *page, bool bdi_stats)
>  {
>  	struct address_space *mapping = page_mapping(page);
>  	int ret;
> @@ -1257,7 +1257,7 @@ int test_clear_page_writeback(struct pag
>  			radix_tree_tag_clear(&mapping->page_tree,
>  						page_index(page),
>  						PAGECACHE_TAG_WRITEBACK);
> -			if (bdi_cap_writeback_dirty(bdi)) {
> +			if (bdi_stats && bdi_cap_writeback_dirty(bdi)) {
>  				__dec_bdi_stat(bdi, BDI_WRITEBACK);
>  				__bdi_writeout_inc(bdi);
>  			}

Adding `mode' flags to a core function is generally considered poor form. 
And it adds additional overhead and possibly stack utilisation for all
callers.

We generally prefer that a new function be created.  After all, that's what
you've done here, only the code has gone and wedged two different functions
into one.


Another approach might be to add a new bdi_cap_foo() flag.  We could then do

	if (bdi_cap_writeback_dirty(bdi) && bdi_cap_mumble(bdi)) {

here.  But even better would be to create a new BDI capability which
indicates that this address_space doesn't want this treatment in
test_clear_page_writeback(), then go fix up all the
!bdi_cap_writeback_dirty() address_spaces to set that flag.

So then the code becomes

	if (!bdi_cap_account_writeback_in_test_clear_page_writeback(bdi)) {

(good luck thinking up a better name ;))

Reason: bdi_cap_writeback_dirty() is kinda weirdly intrepreted to mean
various different things in different places and we really should separate
its multiple interpretations into separate flags.

Note that this becomes a standalone VFS cleanup patch, and the fuse code
can then just use it later on.  

WARNING: multiple messages have this Message-ID (diff)
From: Andrew Morton <akpm@linux-foundation.org>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-mm@kvack.org
Subject: Re: [patch 4/8] mm: allow not updating BDI stats in end_page_writeback()
Date: Mon, 17 Mar 2008 22:04:31 -0700	[thread overview]
Message-ID: <20080317220431.a8507e29.akpm@linux-foundation.org> (raw)
In-Reply-To: <20080317191945.122011759@szeredi.hu>

On Mon, 17 Mar 2008 20:19:12 +0100 Miklos Szeredi <miklos@szeredi.hu> wrote:

> From: Miklos Szeredi <mszeredi@suse.cz>
> 
> Fuse's writepage will need to clear page writeback separately from
> updating the per BDI counters.
> 
> This patch renames end_page_writeback() to __end_page_writeback() and
> adds a boolean parameter to indicate if the per BDI stats need to be
> updated.
> 
> Regular callers get an inline end_page_writeback() without the boolean
> parameter.
> 
> ...
> 
> Index: linux/include/linux/page-flags.h
> ===================================================================
> --- linux.orig/include/linux/page-flags.h	2008-03-17 18:24:13.000000000 +0100
> +++ linux/include/linux/page-flags.h	2008-03-17 18:25:53.000000000 +0100
> @@ -300,7 +300,7 @@ struct page;	/* forward declaration */
>  
>  extern void cancel_dirty_page(struct page *page, unsigned int account_size);
>  
> -int test_clear_page_writeback(struct page *page);
> +int test_clear_page_writeback(struct page *page, bool bdi_stats);
>  int test_set_page_writeback(struct page *page);
>  
>  static inline void set_page_writeback(struct page *page)
> Index: linux/include/linux/pagemap.h
> ===================================================================
> --- linux.orig/include/linux/pagemap.h	2008-03-17 18:24:13.000000000 +0100
> +++ linux/include/linux/pagemap.h	2008-03-17 18:25:53.000000000 +0100
> @@ -223,7 +223,12 @@ static inline void wait_on_page_writebac
>  		wait_on_page_bit(page, PG_writeback);
>  }
>  
> -extern void end_page_writeback(struct page *page);
> +extern void __end_page_writeback(struct page *page, bool bdi_stats);
> +
> +static inline void end_page_writeback(struct page *page)
> +{
> +	__end_page_writeback(page, true);
> +}
>  
>  /*
>   * Fault a userspace page into pagetables.  Return non-zero on a fault.
> Index: linux/mm/filemap.c
> ===================================================================
> --- linux.orig/mm/filemap.c	2008-03-17 18:25:38.000000000 +0100
> +++ linux/mm/filemap.c	2008-03-17 18:25:53.000000000 +0100
> @@ -574,19 +574,20 @@ EXPORT_SYMBOL(unlock_page);
>  /**
>   * end_page_writeback - end writeback against a page
>   * @page: the page
> + * @bdi_stats: update the per-bdi writeback counter
>   */
> -void end_page_writeback(struct page *page)
> +void __end_page_writeback(struct page *page, bool bdi_stats)
>  {
>  	if (TestClearPageReclaim(page))
>  		rotate_reclaimable_page(page);
>  
> -	if (!test_clear_page_writeback(page))
> +	if (!test_clear_page_writeback(page, bdi_stats))
>  		BUG();
>  
>  	smp_mb__after_clear_bit();
>  	wake_up_page(page, PG_writeback);
>  }
> -EXPORT_SYMBOL(end_page_writeback);
> +EXPORT_SYMBOL(__end_page_writeback);
>  
>  /**
>   * __lock_page - get a lock on the page, assuming we need to sleep to get it
> Index: linux/mm/page-writeback.c
> ===================================================================
> --- linux.orig/mm/page-writeback.c	2008-03-17 18:25:17.000000000 +0100
> +++ linux/mm/page-writeback.c	2008-03-17 18:25:53.000000000 +0100
> @@ -1242,7 +1242,7 @@ int clear_page_dirty_for_io(struct page 
>  }
>  EXPORT_SYMBOL(clear_page_dirty_for_io);
>  
> -int test_clear_page_writeback(struct page *page)
> +int test_clear_page_writeback(struct page *page, bool bdi_stats)
>  {
>  	struct address_space *mapping = page_mapping(page);
>  	int ret;
> @@ -1257,7 +1257,7 @@ int test_clear_page_writeback(struct pag
>  			radix_tree_tag_clear(&mapping->page_tree,
>  						page_index(page),
>  						PAGECACHE_TAG_WRITEBACK);
> -			if (bdi_cap_writeback_dirty(bdi)) {
> +			if (bdi_stats && bdi_cap_writeback_dirty(bdi)) {
>  				__dec_bdi_stat(bdi, BDI_WRITEBACK);
>  				__bdi_writeout_inc(bdi);
>  			}

Adding `mode' flags to a core function is generally considered poor form. 
And it adds additional overhead and possibly stack utilisation for all
callers.

We generally prefer that a new function be created.  After all, that's what
you've done here, only the code has gone and wedged two different functions
into one.


Another approach might be to add a new bdi_cap_foo() flag.  We could then do

	if (bdi_cap_writeback_dirty(bdi) && bdi_cap_mumble(bdi)) {

here.  But even better would be to create a new BDI capability which
indicates that this address_space doesn't want this treatment in
test_clear_page_writeback(), then go fix up all the
!bdi_cap_writeback_dirty() address_spaces to set that flag.

So then the code becomes

	if (!bdi_cap_account_writeback_in_test_clear_page_writeback(bdi)) {

(good luck thinking up a better name ;))

Reason: bdi_cap_writeback_dirty() is kinda weirdly intrepreted to mean
various different things in different places and we really should separate
its multiple interpretations into separate flags.

Note that this becomes a standalone VFS cleanup patch, and the fuse code
can then just use it later on.  

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2008-03-18  5:05 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-17 19:19 [patch 0/8] fuse: writable mmap + batched write Miklos Szeredi
2008-03-17 19:19 ` Miklos Szeredi
2008-03-17 19:19 ` [patch 1/8] mm: bdi: export bdi_writeout_inc() Miklos Szeredi
2008-03-17 19:19   ` Miklos Szeredi, Miklos Szeredi
2008-03-18 11:27   ` Peter Zijlstra
2008-03-18 11:27     ` Peter Zijlstra
2008-03-18 11:46     ` Miklos Szeredi
2008-03-18 11:46       ` Miklos Szeredi
2008-03-17 19:19 ` [patch 2/8] mm: Add NR_WRITEBACK_TEMP counter Miklos Szeredi
2008-03-17 19:19   ` Miklos Szeredi, Miklos Szeredi
2008-03-18  5:05   ` Andrew Morton
2008-03-18  5:05     ` Andrew Morton
2008-03-17 19:19 ` [patch 3/8] mm: rotate_reclaimable_page() cleanup Miklos Szeredi
2008-03-17 19:19   ` Miklos Szeredi, Miklos Szeredi
2008-03-18 11:31   ` Peter Zijlstra
2008-03-18 11:31     ` Peter Zijlstra
2008-03-18 11:56     ` Miklos Szeredi
2008-03-18 11:56       ` Miklos Szeredi
2008-03-18 16:45       ` Andrew Morton
2008-03-18 16:45         ` Andrew Morton
2008-03-17 19:19 ` [patch 4/8] mm: allow not updating BDI stats in end_page_writeback() Miklos Szeredi
2008-03-17 19:19   ` Miklos Szeredi, Miklos Szeredi
2008-03-18  5:04   ` Andrew Morton [this message]
2008-03-18  5:04     ` Andrew Morton
2008-03-18  8:11     ` Miklos Szeredi
2008-03-18  8:11       ` Miklos Szeredi
2008-03-18  8:18       ` Andrew Morton
2008-03-18  8:18         ` Andrew Morton
2008-03-18 11:33   ` Peter Zijlstra
2008-03-18 11:33     ` Peter Zijlstra
2008-03-18 11:59     ` Miklos Szeredi
2008-03-18 11:59       ` Miklos Szeredi
2008-03-18 12:29       ` Peter Zijlstra
2008-03-18 12:29         ` Peter Zijlstra
2008-03-18 12:51         ` Miklos Szeredi
2008-03-18 12:51           ` Miklos Szeredi
2008-03-18 13:08           ` Peter Zijlstra
2008-03-18 13:08             ` Peter Zijlstra
2008-03-18 13:58             ` Miklos Szeredi
2008-03-18 13:58               ` Miklos Szeredi
2008-03-18 13:59               ` Peter Zijlstra
2008-03-18 13:59                 ` Peter Zijlstra
2008-03-18 15:53                 ` Miklos Szeredi
2008-03-18 15:53                   ` Miklos Szeredi
2008-03-18 16:49                   ` Andrew Morton
2008-03-18 16:49                     ` Andrew Morton
2008-03-17 19:19 ` [patch 5/8] fuse: support writable mmap Miklos Szeredi
2008-03-17 19:19   ` Miklos Szeredi, Miklos Szeredi
2008-03-17 19:19 ` [patch 6/8] fuse: clean up setting i_size in write Miklos Szeredi
2008-03-17 19:19   ` Miklos Szeredi, Miklos Szeredi
2008-03-18  5:08   ` Andrew Morton
2008-03-18  5:08     ` Andrew Morton
2008-03-18  8:16     ` Miklos Szeredi
2008-03-18  8:16       ` Miklos Szeredi
2008-03-17 19:19 ` [patch 7/8] fuse: implement perform_write Miklos Szeredi
2008-03-17 19:19   ` Miklos Szeredi, Nick Piggin
2008-03-17 19:19 ` [patch 8/8] fuse: update file size on short read Miklos Szeredi
2008-03-17 19:19   ` Miklos Szeredi, Miklos Szeredi

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=20080317220431.a8507e29.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=miklos@szeredi.hu \
    /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.