Skip to content

Commit

Permalink
Tune consumer order in BufferOrch::doTask() based on dependency for w…
Browse files Browse the repository at this point in the history
…arm start (sonic-net#590)

* initBufferReadyLists will pops consumers, so warm start will not redo
* revert initBufferReadyLists()
* (comment)
* (typo)
  • Loading branch information
qiluo-msft authored Aug 24, 2018
1 parent f858b23 commit 836e10a
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 5 deletions.
32 changes: 32 additions & 0 deletions orchagent/bufferorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,38 @@ task_process_status BufferOrch::processEgressBufferProfileList(Consumer &consume
return task_process_status::task_success;
}

void BufferOrch::doTask()
{
// The hidden dependency tree:
// ref: https:/opencomputeproject/SAI/blob/master/doc/QOS/SAI-Proposal-buffers-Ver4.docx
// 2 SAI model
// 3.1 Ingress priority group (PG) configuration
// 3.2.1 Buffer profile configuration
//
// buffer pool
// └── buffer profile
// ├── buffer port ingress profile list
// ├── buffer port egress profile list
// ├── buffer queue
// └── buffer pq table

auto pool_consumer = getExecutor((CFG_BUFFER_POOL_TABLE_NAME));
pool_consumer->drain();

auto profile_consumer = getExecutor(CFG_BUFFER_PROFILE_TABLE_NAME);
profile_consumer->drain();

for(auto &it : m_consumerMap)
{
auto consumer = it.second.get();
if (consumer == profile_consumer)
continue;
if (consumer == pool_consumer)
continue;
consumer->drain();
}
}

void BufferOrch::doTask(Consumer &consumer)
{
SWSS_LOG_ENTER();
Expand Down
1 change: 1 addition & 0 deletions orchagent/bufferorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class BufferOrch : public Orch
typedef map<string, buffer_table_handler> buffer_table_handler_map;
typedef pair<string, buffer_table_handler> buffer_handler_pair;

virtual void doTask() override;
virtual void doTask(Consumer& consumer);
void initTableHandlers();
void initBufferReadyLists(DBConnector *db);
Expand Down
2 changes: 1 addition & 1 deletion orchagent/orch.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class Orch
virtual bool bake();

/* Iterate all consumers in m_consumerMap and run doTask(Consumer) */
void doTask();
virtual void doTask();

/* Run doTask against a specific executor */
virtual void doTask(Consumer &consumer) = 0;
Expand Down
16 changes: 13 additions & 3 deletions orchagent/orchdaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,11 @@ bool OrchDaemon::init()

if (WarmStart::isWarmStart())
{
warmRestoreAndSyncUp();
bool suc = warmRestoreAndSyncUp();
if (!suc)
{
return false;
}
}

return true;
Expand Down Expand Up @@ -336,7 +340,7 @@ void OrchDaemon::start()
* Try to perform orchagent state restore and dynamic states sync up if
* warm start reqeust is detected.
*/
void OrchDaemon::warmRestoreAndSyncUp()
bool OrchDaemon::warmRestoreAndSyncUp()
{
WarmStart::setWarmStartState("orchagent", WarmStart::INIT);

Expand Down Expand Up @@ -366,7 +370,12 @@ void OrchDaemon::warmRestoreAndSyncUp()
* orchagent should be in exact same state of pre-shutdown.
* Perform restore validation as needed.
*/
warmRestoreValidation();
bool suc = warmRestoreValidation();
if (!suc)
{
SWSS_LOG_ERROR("Orchagent state restore failed");
return false;
}

SWSS_LOG_NOTICE("Orchagent state restore done");

Expand All @@ -377,6 +386,7 @@ void OrchDaemon::warmRestoreAndSyncUp()
* The "RECONCILED" state of orchagent doesn't mean the state related to neighbor is up to date.
*/
WarmStart::setWarmStartState("orchagent", WarmStart::RECONCILED);
return true;
}

/*
Expand Down
2 changes: 1 addition & 1 deletion orchagent/orchdaemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class OrchDaemon

bool init();
void start();
void warmRestoreAndSyncUp();
bool warmRestoreAndSyncUp();
void getTaskToSync(vector<string> &ts);
bool warmRestoreValidation();
private:
Expand Down

0 comments on commit 836e10a

Please sign in to comment.