From 9bcc41d9925b83492570a018721f82f5d1a59114 Mon Sep 17 00:00:00 2001
From: Anthony Liguori <aliguori@amazon.com>
Date: Tue, 26 Apr 2016 22:04:13 +0000
Subject: drivers/amazon: xen-blkfront: add 'persistent_grants' parameter
Persistent grants make it far more likely to exhaust domain-0's grant
table entries particularily with a high number of devices across a
high number of domains.
It is useful for an instance to be able to control disabling this
feature to help mitigate against grant starvation.
Signed-off-by: Anthony Liguori <aliguori@amazon.com>
Signed-off-by: Cristian Gafton <gafton@amazon.com>
Signed-off-by: Munehisa Kamata <kamatam@amazon.com>
Reviewed-by: Jonghun Yoo <jhyoo@amazon.de>
Reviewed-by: Marc Olson <marcolso@amazon.com>
Reviewed-by: Erik Quanstrom <quanstro@amazon.com>
Reviewed-by: Jesus Velazquez Reyes <jesuv@amazon.com>
CR: https://cr.amazon.com/r/5182736/
---
drivers/amazon/block/xen-blkfront.c | 31 +++++++++++++++++++++----------
1 file changed, 21 insertions(+), 10 deletions(-)
diff --git a/drivers/amazon/block/xen-blkfront.c b/drivers/amazon/block/xen-blkfront.c
index 9908597..0f19206 100644
--- a/drivers/amazon/block/xen-blkfront.c
+++ b/drivers/amazon/block/xen-blkfront.c
@@ -134,6 +134,10 @@ static unsigned int xen_blkif_max_queues = 4;
module_param_named(max_queues, xen_blkif_max_queues, uint, S_IRUGO);
MODULE_PARM_DESC(max_queues, "Maximum number of hardware queues/rings used per virtual disk");
+static unsigned int xen_blkif_feature_persistent = 1;
+module_param_named(persistent_grants, xen_blkif_feature_persistent, int, S_IRUGO);
+MODULE_PARM_DESC(persistent_grants, "Enable persistent grant table references (default is 1)");
+
/*
* Maximum order of pages to be used for the shared ring between front and
* backend, 4KB page granularity is used.
@@ -1836,11 +1840,14 @@ static int talk_to_blkback(struct xenbus_device *dev,
message = "writing protocol";
goto abort_transaction;
}
- err = xenbus_printf(xbt, dev->nodename,
- "feature-persistent", "%u", 1);
- if (err)
- dev_warn(&dev->dev,
- "writing persistent grants feature to xenbus");
+
+ if (xen_blkif_feature_persistent) {
+ err = xenbus_printf(xbt, dev->nodename,
+ "feature-persistent", "%u", 1);
+ if (err)
+ dev_warn(&dev->dev,
+ "writing persistent grants feature to xenbus");
+ }
err = xenbus_transaction_end(xbt, 0);
if (err) {
@@ -2341,12 +2348,16 @@ static void blkfront_gather_backend_features(struct blkfront_info *info)
if (err > 0 && discard)
blkfront_setup_discard(info);
- err = xenbus_scanf(XBT_NIL, info->xbdev->otherend,
- "feature-persistent", "%d", &persistent);
- if (err <= 0)
+ if (xen_blkif_feature_persistent) {
+ err = xenbus_gather(XBT_NIL, info->xbdev->otherend,
+ "feature-persistent", "%u", &persistent,
+ NULL);
+ if (err)
+ info->feature_persistent = 0;
+ else
+ info->feature_persistent = persistent;
+ } else
info->feature_persistent = 0;
- else
- info->feature_persistent = persistent;
err = xenbus_scanf(XBT_NIL, info->xbdev->otherend,
"feature-max-indirect-segments", "%u",
--
2.7.5