Skip to content

Commit

Permalink
Full sleep wait change for PFC watchdog (sonic-net#465)
Browse files Browse the repository at this point in the history
* Sleep wait change for pfc watchdog, which still has plugins in place so
isEmpty() always returns true.

When issuing 'pfcwd stop' cli to stop PFC watchdog, it only clears the counter id list for physical ports under the hood, leaving lua script plugins still installed and ieEmpty() returns false.

So even when PFC watchdog is stopped, the flex counter thread would wake up every 200 ms.

Jun 4 17:58:51.273413 str-a7050-acs-1 ERR syncd#syncd: :- flexCounterThread: End of flex counter thread FC PFC_WD, took 33 ms
Jun 4 17:58:51.471288 str-a7050-acs-1 ERR syncd#syncd: :- flexCounterThread: End of flex counter thread FC PFC_WD, took 30 ms
Jun 4 17:58:51.672930 str-a7050-acs-1 ERR syncd#syncd: :- flexCounterThread: End of flex counter thread FC PFC_WD, took 31 ms
Jun 4 17:58:51.882972 str-a7050-acs-1 ERR syncd#syncd: :- flexCounterThread: End of flex counter thread FC PFC_WD, took 40 ms
Jun 4 17:58:52.074862 str-a7050-acs-1 ERR syncd#syncd: :- flexCounterThread: End of flex counter thread FC PFC_WD, took 31 ms

This PR is to address the above observation:

Fine granularize the isEmpty() to two functions---isIdsEmpty() and isPluginsEmpty(), and use the emptiness check of the counter id list, isIdsEmpty(), as the criteria for full sleep wait. This approach is generally valid because current flex counter use cases would have the presence of non-empty counter id list to be meaningful, followed by an optional execution of the Lua script plugins if they are installed.

Signed-off-by: Wenda Ni <[email protected]>
  • Loading branch information
wendani authored and lguohan committed Jun 7, 2019
1 parent 86e6caf commit 12fc982
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
21 changes: 17 additions & 4 deletions syncd/syncd_flex_counter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -836,16 +836,29 @@ bool FlexCounter::isEmpty()
{
SWSS_LOG_ENTER();

return allIdsEmpty() && allPluginsEmpty();
}

bool FlexCounter::allIdsEmpty()
{
SWSS_LOG_ENTER();

return m_priorityGroupCounterIdsMap.empty() &&
m_priorityGroupAttrIdsMap.empty() &&
m_priorityGroupPlugins.empty() &&
m_queueCounterIdsMap.empty() &&
m_queueAttrIdsMap.empty() &&
m_portCounterIdsMap.empty() &&
m_rifCounterIdsMap.empty() &&
m_queueAttrIdsMap.empty() &&
m_bufferPoolCounterIdsMap.empty();
}

bool FlexCounter::allPluginsEmpty()
{
SWSS_LOG_ENTER();

return m_priorityGroupPlugins.empty() &&
m_queuePlugins.empty() &&
m_portPlugins.empty() &&
m_bufferPoolCounterIdsMap.empty() &&
m_bufferPoolPlugins.empty();
}

Expand Down Expand Up @@ -1308,7 +1321,7 @@ void FlexCounter::flexCounterThread(void)
{
return;
}
while (!m_enable || isEmpty() || (m_pollInterval == 0))
while (!m_enable || allIdsEmpty() || (m_pollInterval == 0))
{
if (!m_runFlexCounterThread)
{
Expand Down
2 changes: 2 additions & 0 deletions syncd/syncd_flex_counter.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ class FlexCounter
bool isRifCounterSupported(sai_router_interface_stat_t counter) const;
bool isBufferPoolCounterSupported(sai_buffer_pool_stat_t counter) const;
bool isEmpty();
bool allIdsEmpty();
bool allPluginsEmpty();

// Key is a Virtual ID
std::map<sai_object_id_t, std::shared_ptr<PortCounterIds>> m_portCounterIdsMap;
Expand Down

0 comments on commit 12fc982

Please sign in to comment.