Skip to contentSkip to conversation

Add API to get wq occupancy

PATCH In review ramesh.thomas at intel.com 2 participants 7 messages Aug 11, 2021

lore
Share & tools
lore

ramesh.thomas at intel.com

#0 lore raw

cover Add API to get wq occupancy

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Adds API to get wq occupancy attribute and include in wq listing.

Ramesh Thomas (2):
accel-config: Add accfg_wq_get_occupancy API to library
accel-config: Add occupancy attribute to json wq object

 accfg/lib/libaccel-config.sym | 5 +++++
 accfg/lib/libaccfg.c          | 2 ++
 accfg/lib/private.h           | 1 +
 accfg/libaccel_config.h       | 1 +
 util/json.c                   | 7 +++++++
 5 files changed, 16 insertions(+)
Signature · 1 line
2.26.3
#1 lore raw

PATCH 1/2 accel-config: Add accfg_wq_get_occupancy API to library

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Add library implementation of API to get wq occupancy

Signed-off-by Ramesh Thomas <ramesh.thomas(a)intel.com>
---
 accfg/lib/libaccel-config.sym | 5 +++++
 accfg/lib/libaccfg.c          | 2 ++
 accfg/lib/private.h           | 1 +
 accfg/libaccel_config.h       | 1 +
 4 files changed, 9 insertions(+)
accfg/lib/libaccel-config.sym +5 -0
index f44a3ca..7d6b396 100644
@@ -161,3 +161,8 @@ global:
 	accfg_ctx_get_last_error_group;
 	accfg_ctx_get_last_error_engine;
 } LIBACCFG_9;
+
+LIBACCFG_11 {
+global:
+	accfg_wq_get_occupancy;
+} LIBACCFG_10;
accfg/lib/libaccfg.c +2 -0
index 5b63b62..d41a6b3 100644
@@ -801,6 +801,7 @@ static void *add_wq(void *parent, int id, const char *wq_base,
 	wq->max_batch_size =  accfg_get_param_long(ctx, dfd, "max_batch_size");
 	wq->max_transfer_size =  accfg_get_param_long(ctx, dfd, "max_transfer_size");
 	wq->ats_disable = accfg_get_param_long(ctx, dfd, "ats_disable");
+	wq->occupancy = accfg_get_param_long(ctx, dfd, "occupancy");
 
 	wq_parse_type(wq, wq_type);
 	free(wq_type);
@@ -2452,6 +2453,7 @@ accfg_wq_get_field(wq, threshold)
 accfg_wq_get_field(wq, group_id)
 accfg_wq_get_field(wq, block_on_fault)
 accfg_wq_get_field(wq, ats_disable)
+accfg_wq_get_field(wq, occupancy)
 
 ACCFG_EXPORT int accfg_wq_set_mode(struct accfg_wq *wq,
 		enum accfg_wq_mode wq_mode)
accfg/lib/private.h +1 -0
index 57aa1ed..579fa6b 100644
@@ -127,6 +127,7 @@ struct accfg_wq {
 	unsigned int max_batch_size;
 	uint64_t max_transfer_size;
 	int ats_disable;
+	int occupancy;
 };
 
 #define ACCFG_EXPORT __attribute__ ((visibility("default")))
accfg/libaccel_config.h +1 -0
index f8b9bf9..92b1da5 100644
@@ -277,6 +277,7 @@ uint64_t accfg_wq_get_max_transfer_size(struct accfg_wq *wq);
 int accfg_wq_get_threshold(struct accfg_wq *wq);
 int accfg_wq_get_clients(struct accfg_wq *wq);
 int accfg_wq_get_ats_disable(struct accfg_wq *wq);
+int accfg_wq_get_occupancy(struct accfg_wq *wq);
 int accfg_wq_is_enabled(struct accfg_wq *wq);
 int accfg_wq_set_size(struct accfg_wq *wq, int val);
 int accfg_wq_set_priority(struct accfg_wq *wq, int val);
Signature · 1 line
2.26.3
#2 lore raw

[Accel-config] Re: [PATCH 1/2] accel-config: Add accfg_wq_get_occupancy API to library

Quoted 30 lines · ramesh.thomas(a)intel.com

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Add library implementation of API to get wq occupancy

Signed-off-by Ramesh Thomas <ramesh.thomas(a)intel.com>
---
  accfg/lib/libaccel-config.sym | 5 +++++
  accfg/lib/libaccfg.c          | 2 ++
  accfg/lib/private.h           | 1 +
  accfg/libaccel_config.h       | 1 +
  4 files changed, 9 insertions(+)
accfg/lib/libaccel-config.sym +5 -0
index f44a3ca..7d6b396 100644
@@ -161,3 +161,8 @@ global:
  	accfg_ctx_get_last_error_group;
  	accfg_ctx_get_last_error_engine;
  } LIBACCFG_9;
+
+LIBACCFG_11 {
+global:
+	accfg_wq_get_occupancy;
+} LIBACCFG_10;
accfg/lib/libaccfg.c +0 -0
index 5b63b62..d41a6b3 100644

accfg/lib/libaccfg.c static void *add_wq(void *parent, int id, const char *wq_base, · line 804

Quoted 4 lines
accfg/lib/libaccfg.c +1 -0
@@ -801,6 +801,7 @@ static void *add_wq(void *parent, int id, const char *wq_base,
  	wq->max_batch_size =  accfg_get_param_long(ctx, dfd, "max_batch_size");
  	wq->max_transfer_size =  accfg_get_param_long(ctx, dfd, "max_transfer_size");
  	wq->ats_disable = accfg_get_param_long(ctx, dfd, "ats_disable");
+	wq->occupancy = accfg_get_param_long(ctx, dfd, "occupancy");

We need to read this value real time. When the user calls it, we need to read from sysfs directly. We don't need to store it though.

Quoted 35 lines
accfg/lib/libaccfg.c +1 -0
  	wq_parse_type(wq, wq_type);
  	free(wq_type);
@@ -2452,6 +2453,7 @@ accfg_wq_get_field(wq, threshold)
  accfg_wq_get_field(wq, group_id)
  accfg_wq_get_field(wq, block_on_fault)
  accfg_wq_get_field(wq, ats_disable)
+accfg_wq_get_field(wq, occupancy)
 
  ACCFG_EXPORT int accfg_wq_set_mode(struct accfg_wq *wq,
  		enum accfg_wq_mode wq_mode)
accfg/lib/private.h +1 -0
index 57aa1ed..579fa6b 100644
@@ -127,6 +127,7 @@ struct accfg_wq {
  	unsigned int max_batch_size;
  	uint64_t max_transfer_size;
  	int ats_disable;
+	int occupancy;
  };
 
  #define ACCFG_EXPORT __attribute__ ((visibility("default")))
accfg/libaccel_config.h +1 -0
index f8b9bf9..92b1da5 100644
@@ -277,6 +277,7 @@ uint64_t accfg_wq_get_max_transfer_size(struct accfg_wq *wq);
  int accfg_wq_get_threshold(struct accfg_wq *wq);
  int accfg_wq_get_clients(struct accfg_wq *wq);
  int accfg_wq_get_ats_disable(struct accfg_wq *wq);
+int accfg_wq_get_occupancy(struct accfg_wq *wq);
  int accfg_wq_is_enabled(struct accfg_wq *wq);
  int accfg_wq_set_size(struct accfg_wq *wq, int val);
  int accfg_wq_set_priority(struct accfg_wq *wq, int val);
#3 lore raw

PATCH 2/2 accel-config: Add occupancy attribute to json wq object

In reply to ramesh.thomas at intel.com

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Add a json object for occupancy attribute in wq properties.

Signed-off-by Ramesh Thomas <ramesh.thomas(a)intel.com>
---
 util/json.c | 7 +++++++
 1 file changed, 7 insertions(+)
util/json.c +7 -0
index 09d3a10..bd3f1ba 100644
@@ -461,6 +461,13 @@ struct json_object *util_wq_to_json(struct accfg_wq *wq,
 	if (jobj)
 		json_object_object_add(jaccfg, "ats_disable", jobj);
 
+	int_val = accfg_wq_get_occupancy(wq);
+	if (int_val >= 0) {
+		jobj = json_object_new_int(int_val);
+		if (jobj)
+			json_object_object_add(jaccfg, "occupancy", jobj);
+	}
+
 	if (!(flags & UTIL_JSON_SAVE)) {
 
 		switch (wq_state) {
Signature · 1 line
2.26.3
#4 lore raw

[Accel-config] Re: [PATCH 2/2] accel-config: Add occupancy attribute to json wq object

Quoted 3 lines · ramesh.thomas(a)intel.com

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Add a json object for occupancy attribute in wq properties.

Not sure if we should bother. This value is only useful in the moment. There's not much value to display the stale output.

Quoted 24 lines
Signed-off-by Ramesh Thomas <ramesh.thomas(a)intel.com>
---
  util/json.c | 7 +++++++
  1 file changed, 7 insertions(+)
util/json.c +7 -0
index 09d3a10..bd3f1ba 100644
@@ -461,6 +461,13 @@ struct json_object *util_wq_to_json(struct accfg_wq *wq,
  	if (jobj)
  		json_object_object_add(jaccfg, "ats_disable", jobj);
 
+	int_val = accfg_wq_get_occupancy(wq);
+	if (int_val >= 0) {
+		jobj = json_object_new_int(int_val);
+		if (jobj)
+			json_object_object_add(jaccfg, "occupancy", jobj);
+	}
+
  	if (!(flags & UTIL_JSON_SAVE)) {
 
  		switch (wq_state) {
#5 lore raw
In reply to ramesh.thomas at intel.com
Quoted 1 line

Adds API to get wq occupancy attribute and include in wq listing.

What do we mean by "occupancy"? To me that sounds like "how many of the available slots in the WQ are in use?"

Does the h/w provide that information? It seems like it would be transient (i.e. the device will process descriptors and change the value almost as fast as it can be read).

-Tony

#6 lore raw
Quoted 2 lines · Tony
Quoted 1 line

Adds API to get wq occupancy attribute and include in wq listing.

What do we mean by "occupancy"? To me that sounds like "how many of the available slots in the WQ are in use?"

Correct.

Quoted 4 lines

Does the h/w provide that information? It seems like it would be transient (i.e. the device will process descriptors and change the value almost as fast as it can be read).

Yes the hw provides that. And yes it's transient. user library people wanted to use that as a way to guesstimate flow control I believe.