[SRU][Bionic][PATCH 5/5] s390/zcrypt: Show load of cards and queues in sysfs

Frank Heimes frank.heimes at canonical.com
Fri Nov 2 19:35:29 UTC 2018

From: Harald Freudenberger <freude at de.ibm.com>

BugLink: http://bugs.launchpad.net/bugs/1799184

Show the current load value of cards and queues in sysfs.
The load value for each card and queue is maintained by
the zcrypt device driver for dispatching and load
balancing requests over the available devices.

This patch provides the load value to userspace via a
new read only sysfs attribute 'load' per card and queue.

Signed-off-by: Harald Freudenberger <freude at de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky at de.ibm.com>
(cherry-picked from commit 4a07750ba8f3f45f0be730f7370c2c21a7491cd7)
Signed-off-by: Frank Heimes <frank.heimes at canonical.com>

diff --git a/drivers/s390/crypto/zcrypt_card.c
index 233e1e6..da2c8df 100644
--- a/drivers/s390/crypto/zcrypt_card.c
+++ b/drivers/s390/crypto/zcrypt_card.c
@@ -83,9 +83,21 @@ static ssize_t zcrypt_card_online_store(struct device
 static DEVICE_ATTR(online, 0644, zcrypt_card_online_show,

+static ssize_t zcrypt_card_load_show(struct device *dev,
+                                    struct device_attribute *attr,
+                                    char *buf)
+       struct zcrypt_card *zc = to_ap_card(dev)->private;
+       return snprintf(buf, PAGE_SIZE, "%d\n", atomic_read(&zc->load));
+static DEVICE_ATTR(load, 0444, zcrypt_card_load_show, NULL);
 static struct attribute *zcrypt_card_attrs[] = {
+       &dev_attr_load.attr,

diff --git a/drivers/s390/crypto/zcrypt_queue.c
index 720434e..91a52f2 100644
--- a/drivers/s390/crypto/zcrypt_queue.c
+++ b/drivers/s390/crypto/zcrypt_queue.c
@@ -75,8 +75,20 @@ static ssize_t zcrypt_queue_online_store(struct device
 static DEVICE_ATTR(online, 0644, zcrypt_queue_online_show,

+static ssize_t zcrypt_queue_load_show(struct device *dev,
+                                     struct device_attribute *attr,
+                                     char *buf)
+       struct zcrypt_queue *zq = to_ap_queue(dev)->private;
+       return snprintf(buf, PAGE_SIZE, "%d\n", atomic_read(&zq->load));
+static DEVICE_ATTR(load, 0444, zcrypt_queue_load_show, NULL);
 static struct attribute *zcrypt_queue_attrs[] = {
+       &dev_attr_load.attr,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/kernel-team/attachments/20181102/63dc5e49/attachment.html>

More information about the kernel-team mailing list