All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] ext4: a couple writeback path fixes
@ 2010-08-31 13:56 Eric Sandeen
  2010-08-31 13:59 ` PATCH 1/2] ext4: stop looping in ext4_num_dirty_pages when max_pages reached Eric Sandeen
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Eric Sandeen @ 2010-08-31 13:56 UTC (permalink / raw)
  To: ext4 development

I've found a couple small problems in the ext4_da_writepages path;

1) ext4_num_dirty_pages() can continue looping after max_pages is reached
   - this leads to wasted cpu cycles during writeback

2) bumping nr_to_write can wrap if we started with LONG_MAX
   - Not sure of all ramifications, but nr_to_write = -8 can't be good

-Eric

^ permalink raw reply	[flat|nested] 6+ messages in thread

* PATCH 1/2] ext4: stop looping in ext4_num_dirty_pages when max_pages reached
  2010-08-31 13:56 [PATCH 0/2] ext4: a couple writeback path fixes Eric Sandeen
@ 2010-08-31 13:59 ` Eric Sandeen
  2010-08-31 14:04 ` [PATCH 2/2] ext4: don't bump nr_to_write if LONG_MAX Eric Sandeen
  2010-09-03 22:11 ` [PATCH 0/2] ext4: a couple writeback path fixes Eric Sandeen
  2 siblings, 0 replies; 6+ messages in thread
From: Eric Sandeen @ 2010-08-31 13:59 UTC (permalink / raw)
  To: ext4 development

Today we simply break out of the inner loop when we have accumulated
max_pages; this keeps scanning forwad and doing pagevec_lookup_tag()
in the while (!done) loop, this does potentially a lot of work
with no net effect.

When we have accumulated max_pages, just clean up and return.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 4b8debe..93497f6 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -1207,8 +1207,10 @@ static pgoff_t ext4_num_dirty_pages(struct inode *inode, pgoff_t idx,
 				break;
 			idx++;
 			num++;
-			if (num >= max_pages)
-				break;
+			if (num >= max_pages) {
+				pagevec_release(&pvec);
+				return num;
+			}
 		}
 		pagevec_release(&pvec);
 	}



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] ext4: don't bump nr_to_write if LONG_MAX
  2010-08-31 13:56 [PATCH 0/2] ext4: a couple writeback path fixes Eric Sandeen
  2010-08-31 13:59 ` PATCH 1/2] ext4: stop looping in ext4_num_dirty_pages when max_pages reached Eric Sandeen
@ 2010-08-31 14:04 ` Eric Sandeen
  2010-08-31 14:20   ` [PATCH 2/2 V2] " Eric Sandeen
  2010-09-03 22:11 ` [PATCH 0/2] ext4: a couple writeback path fixes Eric Sandeen
  2 siblings, 1 reply; 6+ messages in thread
From: Eric Sandeen @ 2010-08-31 14:04 UTC (permalink / raw)
  To: ext4 development

In some cases we can reach ext4_da_writepages with
wbc->nr_to_write == LONG_MAX, !range_cyclic, and range_whole=1;
in this case we will try to bump it up by a factor of 8, which
leads to a nr_to_write value of -8.

I think we still get through the logic without changing
wbc->nr_to_write because the other tests which would change
it don't trip, but it seems dangerous to overflow 
desired_nr_to_write in the interim, it's not obvious.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 93497f6..2e72a4a 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -3004,9 +3004,11 @@ static int ext4_da_writepages(struct address_space *mapping,
 	 * sbi->max_writeback_mb_bump whichever is smaller.
 	 */
 	max_pages = sbi->s_max_writeback_mb_bump << (20 - PAGE_CACHE_SHIFT);
-	if (!range_cyclic && range_whole)
-		desired_nr_to_write = wbc->nr_to_write * 8;
-	else
+	if (!range_cyclic && range_whole) {
+		desired_nr_to_write = wbc->nr_to_write;
+		if (desired_nr_to_write != LONG_MAX)
+			desired_nr_to_write *= 8;
+	} else
 		desired_nr_to_write = ext4_num_dirty_pages(inode, index,
 							   max_pages);
 	if (desired_nr_to_write > max_pages)



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2 V2] ext4: don't bump nr_to_write if LONG_MAX
  2010-08-31 14:04 ` [PATCH 2/2] ext4: don't bump nr_to_write if LONG_MAX Eric Sandeen
@ 2010-08-31 14:20   ` Eric Sandeen
  2010-09-03 21:37     ` Eric Sandeen
  0 siblings, 1 reply; 6+ messages in thread
From: Eric Sandeen @ 2010-08-31 14:20 UTC (permalink / raw)
  To: ext4 development

In some cases we can reach ext4_da_writepages() with
wbc->nr_to_write == LONG_MAX, !range_cyclic, and range_whole=1;
in this case we will try to bump it up by a factor of 8, which
leads to a desired_nr_to_write value of -8.

We still get through the logic without actually changing
wbc->nr_to_write because the other tests which would change
it don't trip due to the negative value, but it seems dangerous
to overflow  desired_nr_to_write in the interim, it's not an 
obvious situation.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

(V2 minor commit message edits)

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 93497f6..2e72a4a 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -3004,9 +3004,11 @@ static int ext4_da_writepages(struct address_space *mapping,
 	 * sbi->max_writeback_mb_bump whichever is smaller.
 	 */
 	max_pages = sbi->s_max_writeback_mb_bump << (20 - PAGE_CACHE_SHIFT);
-	if (!range_cyclic && range_whole)
-		desired_nr_to_write = wbc->nr_to_write * 8;
-	else
+	if (!range_cyclic && range_whole) {
+		desired_nr_to_write = wbc->nr_to_write;
+		if (desired_nr_to_write != LONG_MAX)
+			desired_nr_to_write *= 8;
+	} else
 		desired_nr_to_write = ext4_num_dirty_pages(inode, index,
 							   max_pages);
 	if (desired_nr_to_write > max_pages)


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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2 V2] ext4: don't bump nr_to_write if LONG_MAX
  2010-08-31 14:20   ` [PATCH 2/2 V2] " Eric Sandeen
@ 2010-09-03 21:37     ` Eric Sandeen
  0 siblings, 0 replies; 6+ messages in thread
From: Eric Sandeen @ 2010-09-03 21:37 UTC (permalink / raw)
  To: ext4 development

Eric Sandeen wrote:
> In some cases we can reach ext4_da_writepages() with
> wbc->nr_to_write == LONG_MAX, !range_cyclic, and range_whole=1;
> in this case we will try to bump it up by a factor of 8, which
> leads to a desired_nr_to_write value of -8.

Sorry Ted, hold off on this, it should have been LLONG_MAX of course,
and I'm still looking for one other bit of brokennes I see.

The 1/2 patch should be good though.

-Eric

> We still get through the logic without actually changing
> wbc->nr_to_write because the other tests which would change
> it don't trip due to the negative value, but it seems dangerous
> to overflow  desired_nr_to_write in the interim, it's not an 
> obvious situation.
> 
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---
> 
> (V2 minor commit message edits)
> 
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 93497f6..2e72a4a 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -3004,9 +3004,11 @@ static int ext4_da_writepages(struct address_space *mapping,
>  	 * sbi->max_writeback_mb_bump whichever is smaller.
>  	 */
>  	max_pages = sbi->s_max_writeback_mb_bump << (20 - PAGE_CACHE_SHIFT);
> -	if (!range_cyclic && range_whole)
> -		desired_nr_to_write = wbc->nr_to_write * 8;
> -	else
> +	if (!range_cyclic && range_whole) {
> +		desired_nr_to_write = wbc->nr_to_write;
> +		if (desired_nr_to_write != LONG_MAX)
> +			desired_nr_to_write *= 8;
> +	} else
>  		desired_nr_to_write = ext4_num_dirty_pages(inode, index,
>  							   max_pages);
>  	if (desired_nr_to_write > max_pages)
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/2] ext4: a couple writeback path fixes
  2010-08-31 13:56 [PATCH 0/2] ext4: a couple writeback path fixes Eric Sandeen
  2010-08-31 13:59 ` PATCH 1/2] ext4: stop looping in ext4_num_dirty_pages when max_pages reached Eric Sandeen
  2010-08-31 14:04 ` [PATCH 2/2] ext4: don't bump nr_to_write if LONG_MAX Eric Sandeen
@ 2010-09-03 22:11 ` Eric Sandeen
  2 siblings, 0 replies; 6+ messages in thread
From: Eric Sandeen @ 2010-09-03 22:11 UTC (permalink / raw)
  To: ext4 development

Eric Sandeen wrote:
> I've found a couple small problems in the ext4_da_writepages path;
> 
> 1) ext4_num_dirty_pages() can continue looping after max_pages is reached
>    - this leads to wasted cpu cycles during writeback
> 
> 2) bumping nr_to_write can wrap if we started with LONG_MAX
>    - Not sure of all ramifications, but nr_to_write = -8 can't be good
> 
> -Eric

sigh just nak this whole thing for now, too many errors.

Will resubmit after more careful reading, patching, and testing.

Sorry for the noise.

-Eric

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-09-03 22:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-31 13:56 [PATCH 0/2] ext4: a couple writeback path fixes Eric Sandeen
2010-08-31 13:59 ` PATCH 1/2] ext4: stop looping in ext4_num_dirty_pages when max_pages reached Eric Sandeen
2010-08-31 14:04 ` [PATCH 2/2] ext4: don't bump nr_to_write if LONG_MAX Eric Sandeen
2010-08-31 14:20   ` [PATCH 2/2 V2] " Eric Sandeen
2010-09-03 21:37     ` Eric Sandeen
2010-09-03 22:11 ` [PATCH 0/2] ext4: a couple writeback path fixes Eric Sandeen

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.