Skip to content

Commit c2ff230

Browse files
authored
Tune consumer order in BufferOrch::doTask() based on dependency for warm start (sonic-net#590)
* initBufferReadyLists will pops consumers, so warm start will not redo * revert initBufferReadyLists() * (comment) * (typo)
1 parent 5b2b6aa commit c2ff230

5 files changed

Lines changed: 48 additions & 5 deletions

File tree

orchagent/bufferorch.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,38 @@ task_process_status BufferOrch::processEgressBufferProfileList(Consumer &consume
635635
return task_process_status::task_success;
636636
}
637637

638+
void BufferOrch::doTask()
639+
{
640+
// The hidden dependency tree:
641+
// ref: https://github.com/opencomputeproject/SAI/blob/master/doc/QOS/SAI-Proposal-buffers-Ver4.docx
642+
// 2 SAI model
643+
// 3.1 Ingress priority group (PG) configuration
644+
// 3.2.1 Buffer profile configuration
645+
//
646+
// buffer pool
647+
// └── buffer profile
648+
// ├── buffer port ingress profile list
649+
// ├── buffer port egress profile list
650+
// ├── buffer queue
651+
// └── buffer pq table
652+
653+
auto pool_consumer = getExecutor((CFG_BUFFER_POOL_TABLE_NAME));
654+
pool_consumer->drain();
655+
656+
auto profile_consumer = getExecutor(CFG_BUFFER_PROFILE_TABLE_NAME);
657+
profile_consumer->drain();
658+
659+
for(auto &it : m_consumerMap)
660+
{
661+
auto consumer = it.second.get();
662+
if (consumer == profile_consumer)
663+
continue;
664+
if (consumer == pool_consumer)
665+
continue;
666+
consumer->drain();
667+
}
668+
}
669+
638670
void BufferOrch::doTask(Consumer &consumer)
639671
{
640672
SWSS_LOG_ENTER();

orchagent/bufferorch.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class BufferOrch : public Orch
3535
typedef map<string, buffer_table_handler> buffer_table_handler_map;
3636
typedef pair<string, buffer_table_handler> buffer_handler_pair;
3737

38+
virtual void doTask() override;
3839
virtual void doTask(Consumer& consumer);
3940
void initTableHandlers();
4041
void initBufferReadyLists(DBConnector *db);

orchagent/orch.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ class Orch
182182
virtual bool bake();
183183

184184
/* Iterate all consumers in m_consumerMap and run doTask(Consumer) */
185-
void doTask();
185+
virtual void doTask();
186186

187187
/* Run doTask against a specific executor */
188188
virtual void doTask(Consumer &consumer) = 0;

orchagent/orchdaemon.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,11 @@ bool OrchDaemon::init()
264264

265265
if (WarmStart::isWarmStart())
266266
{
267-
warmRestoreAndSyncUp();
267+
bool suc = warmRestoreAndSyncUp();
268+
if (!suc)
269+
{
270+
return false;
271+
}
268272
}
269273

270274
return true;
@@ -336,7 +340,7 @@ void OrchDaemon::start()
336340
* Try to perform orchagent state restore and dynamic states sync up if
337341
* warm start reqeust is detected.
338342
*/
339-
void OrchDaemon::warmRestoreAndSyncUp()
343+
bool OrchDaemon::warmRestoreAndSyncUp()
340344
{
341345
WarmStart::setWarmStartState("orchagent", WarmStart::INIT);
342346

@@ -366,7 +370,12 @@ void OrchDaemon::warmRestoreAndSyncUp()
366370
* orchagent should be in exact same state of pre-shutdown.
367371
* Perform restore validation as needed.
368372
*/
369-
warmRestoreValidation();
373+
bool suc = warmRestoreValidation();
374+
if (!suc)
375+
{
376+
SWSS_LOG_ERROR("Orchagent state restore failed");
377+
return false;
378+
}
370379

371380
SWSS_LOG_NOTICE("Orchagent state restore done");
372381

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

382392
/*

orchagent/orchdaemon.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class OrchDaemon
3434

3535
bool init();
3636
void start();
37-
void warmRestoreAndSyncUp();
37+
bool warmRestoreAndSyncUp();
3838
void getTaskToSync(vector<string> &ts);
3939
bool warmRestoreValidation();
4040
private:

0 commit comments

Comments
 (0)