Commit cbe481a1 authored by Breno Leitao's avatar Breno Leitao Committed by Jakub Kicinski

net: dql: Separate queue function responsibilities

The dql_queued() function currently handles both queuing object counts
and populating bitmaps for reporting stalls.

This commit splits the bitmap population into a separate function,
allowing for conditional invocation in scenarios where the feature is
disabled.

This refactor maintains functionality while improving code
organization.
Signed-off-by: default avatarBreno Leitao <leitao@debian.org>
Link: https://lore.kernel.org/r/20240411192241.2498631-3-leitao@debian.orgSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 4854b463
...@@ -83,28 +83,11 @@ struct dql { ...@@ -83,28 +83,11 @@ struct dql {
#define DQL_MAX_OBJECT (UINT_MAX / 16) #define DQL_MAX_OBJECT (UINT_MAX / 16)
#define DQL_MAX_LIMIT ((UINT_MAX / 2) - DQL_MAX_OBJECT) #define DQL_MAX_LIMIT ((UINT_MAX / 2) - DQL_MAX_OBJECT)
/* /* Populate the bitmap to be processed later in dql_check_stall() */
* Record number of objects queued. Assumes that caller has already checked static inline void dql_queue_stall(struct dql *dql)
* availability in the queue with dql_avail.
*/
static inline void dql_queued(struct dql *dql, unsigned int count)
{ {
unsigned long map, now, now_hi, i; unsigned long map, now, now_hi, i;
if (WARN_ON_ONCE(count > DQL_MAX_OBJECT))
return;
dql->last_obj_cnt = count;
/* We want to force a write first, so that cpu do not attempt
* to get cache line containing last_obj_cnt, num_queued, adj_limit
* in Shared state, but directly does a Request For Ownership
* It is only a hint, we use barrier() only.
*/
barrier();
dql->num_queued += count;
now = jiffies; now = jiffies;
now_hi = now / BITS_PER_LONG; now_hi = now / BITS_PER_LONG;
...@@ -134,6 +117,29 @@ static inline void dql_queued(struct dql *dql, unsigned int count) ...@@ -134,6 +117,29 @@ static inline void dql_queued(struct dql *dql, unsigned int count)
WRITE_ONCE(DQL_HIST_ENT(dql, now_hi), map | BIT_MASK(now)); WRITE_ONCE(DQL_HIST_ENT(dql, now_hi), map | BIT_MASK(now));
} }
/*
* Record number of objects queued. Assumes that caller has already checked
* availability in the queue with dql_avail.
*/
static inline void dql_queued(struct dql *dql, unsigned int count)
{
if (WARN_ON_ONCE(count > DQL_MAX_OBJECT))
return;
dql->last_obj_cnt = count;
/* We want to force a write first, so that cpu do not attempt
* to get cache line containing last_obj_cnt, num_queued, adj_limit
* in Shared state, but directly does a Request For Ownership
* It is only a hint, we use barrier() only.
*/
barrier();
dql->num_queued += count;
dql_queue_stall(dql);
}
/* Returns how many objects can be queued, < 0 indicates over limit. */ /* Returns how many objects can be queued, < 0 indicates over limit. */
static inline int dql_avail(const struct dql *dql) static inline int dql_avail(const struct dql *dql)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment