From: Roger Pau Monne <roger.pau@citrix.com>
To: <xen-devel@lists.xen.org>, <linux-kernel@vger.kernel.org>
Cc: Roger Pau Monne <roger.pau@citrix.com>,
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Subject: [PATCH 1/4] xen-blkback: workaround compiler bug in gcc 4.1
Date: Fri, 21 Jun 2013 12:56:53 +0200 [thread overview]
Message-ID: <1371812216-17093-2-git-send-email-roger.pau@citrix.com> (raw)
In-Reply-To: <1371812216-17093-1-git-send-email-roger.pau@citrix.com>
The code generat with gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-54)
creates an unbound loop for the second foreach_grant_safe loop in
purge_persistent_gnt.
The workaround is to avoid having this second loop and instead
perform all the work inside the first loop by adding a new variable,
clean_used, that will be set when all the desired persistent grants
have been removed and we need to iterate over the remaining ones to
remove the WAS_ACTIVE flag.
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reported-by: Tom O'Neill <toneill@vmem.com>
Reported-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
drivers/block/xen-blkback/blkback.c | 24 ++++++++++++++----------
1 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/drivers/block/xen-blkback/blkback.c b/drivers/block/xen-blkback/blkback.c
index 4119bcd..d622d86 100644
--- a/drivers/block/xen-blkback/blkback.c
+++ b/drivers/block/xen-blkback/blkback.c
@@ -341,7 +341,7 @@ static void purge_persistent_gnt(struct xen_blkif *blkif)
struct persistent_gnt *persistent_gnt;
struct rb_node *n;
unsigned int num_clean, total;
- bool scan_used = false;
+ bool scan_used = false, clean_used = false;
struct rb_root *root;
if (blkif->persistent_gnt_c < xen_blkif_max_pgrants ||
@@ -358,9 +358,8 @@ static void purge_persistent_gnt(struct xen_blkif *blkif)
num_clean = (xen_blkif_max_pgrants / 100) * LRU_PERCENT_CLEAN;
num_clean = blkif->persistent_gnt_c - xen_blkif_max_pgrants + num_clean;
num_clean = min(blkif->persistent_gnt_c, num_clean);
- if (num_clean >
- (blkif->persistent_gnt_c -
- atomic_read(&blkif->persistent_gnt_in_use)))
+ if ((num_clean == 0) ||
+ (num_clean > (blkif->persistent_gnt_c - atomic_read(&blkif->persistent_gnt_in_use))))
return;
/*
@@ -383,6 +382,11 @@ purge_list:
BUG_ON(persistent_gnt->handle ==
BLKBACK_INVALID_HANDLE);
+ if (clean_used) {
+ clear_bit(PERSISTENT_GNT_WAS_ACTIVE, persistent_gnt->flags);
+ continue;
+ }
+
if (test_bit(PERSISTENT_GNT_ACTIVE, persistent_gnt->flags))
continue;
if (!scan_used &&
@@ -400,18 +404,18 @@ purge_list:
* grants that were used since last purge in order to cope
* with the requested num
*/
- if (!scan_used) {
+ if (!scan_used && !clean_used) {
pr_debug(DRV_PFX "Still missing %u purged frames\n", num_clean);
scan_used = true;
goto purge_list;
}
finished:
- /* Remove the "used" flag from all the persistent grants */
- foreach_grant_safe(persistent_gnt, n, root, node) {
- BUG_ON(persistent_gnt->handle ==
- BLKBACK_INVALID_HANDLE);
- clear_bit(PERSISTENT_GNT_WAS_ACTIVE, persistent_gnt->flags);
+ if (!clean_used) {
+ pr_debug(DRV_PFX "Finished scanning for grants to clean, removing used flag\n");
+ clean_used = true;
+ goto purge_list;
}
+
blkif->persistent_gnt_c -= (total - num_clean);
blkif->vbd.overflow_max_grants = 0;
--
1.7.7.5 (Apple Git-26)
next prev parent reply other threads:[~2013-06-21 10:59 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-21 10:56 [PATCH 0/4] xen-block: bug fixes for indirect-descriptors Roger Pau Monne
2013-06-21 10:56 ` Roger Pau Monne [this message]
2013-06-21 10:56 ` [PATCH 2/4] xen-blkfront: set blk_queue_max_hw_sectors correctly Roger Pau Monne
2013-06-21 10:56 ` [PATCH 3/4] xen-blkback: check the number of iovecs before allocating a bios Roger Pau Monne
2013-06-21 11:46 ` [Xen-devel] " Jan Beulich
2013-06-21 12:02 ` Roger Pau Monné
2013-06-22 7:59 ` [PATCH v2 " Roger Pau Monne
2013-06-24 13:28 ` Konrad Rzeszutek Wilk
2013-06-25 8:03 ` Roger Pau Monné
2013-06-21 10:56 ` [PATCH 4/4] xen-blkfront: increase the default number of indirect segments Roger Pau Monne
2013-06-21 11:49 ` [Xen-devel] " Jan Beulich
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=1371812216-17093-2-git-send-email-roger.pau@citrix.com \
--to=roger.pau@citrix.com \
--cc=konrad.wilk@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=xen-devel@lists.xen.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®