MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ff_handle_each_context

Function ff_handle_each_context

adapter/syscall/ff_socket_ops.c:569–638  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

567}
568
569void
570ff_handle_each_context()
571{
572 uint16_t i, nb_handled, tmp;
573 static uint64_t loop_count = 0;
574 static uint64_t cur_tsc, diff_tsc, drain_tsc = 0;
575
576 if (unlikely(drain_tsc == 0 && ff_global_cfg.dpdk.pkt_tx_delay)) {
577 drain_tsc = (rte_get_tsc_hz() + US_PER_S - 1) / US_PER_S * ff_global_cfg.dpdk.pkt_tx_delay;
578 ERR_LOG("ff_global_cfg.dpdk.handle_sc_delay%d, drain_tsc:%lu\n",
579 ff_global_cfg.dpdk.pkt_tx_delay, drain_tsc);
580 }
581
582 ff_event_loop_nb = 0;
583
584 cur_tsc = rte_rdtsc();
585
586 rte_spinlock_lock(&ff_so_zone->lock);
587
588 assert(ff_so_zone->count >= ff_so_zone->free);
589 tmp = nb_handled = ff_so_zone->count - ff_so_zone->free;
590
591 while(1) {
592 nb_handled = tmp;
593 if (nb_handled) {
594 for (i = 0; i < ff_so_zone->count; i++) {
595 struct ff_so_context *sc = &ff_so_zone->sc[i];
596
597 if ((loop_count & 1048575) == 0) {
598 DEBUG_LOG("so:%p, so->count:%d,%p, sc:%p, sc->inuse:%d,%p, i:%d, nb:%d, all_nb:%d\n",
599 ff_so_zone, ff_so_zone->count, &ff_so_zone->count,
600 sc, ff_so_zone->inuse[i], &ff_so_zone->inuse[i], i, nb_handled, tmp);
601 }
602
603 if (ff_so_zone->inuse[i] == 0) {
604 continue;
605 }
606
607 /* Dirty read first, and then try to lock sc and real read. */
608 if (sc->status == FF_SC_REQ) {
609 ff_handle_socket_ops(sc);
610 }
611
612 nb_handled--;
613 if (!nb_handled) {
614 break;
615 }
616 }
617 }
618
619 /*if (--ff_event_loop_nb <= 0 || ff_next_event_flag == 1) {
620 break;
621 }*/
622 diff_tsc = rte_rdtsc() - cur_tsc;
623 DEBUG_LOG("cur_tsc:%lu, diff_tsc:%lu, drain_tsc:%lu\n", cur_tsc, diff_tsc, drain_tsc);
624 if (diff_tsc >= drain_tsc) {
625 break;
626 }

Callers 1

loopFunction · 0.85

Calls 6

rte_get_tsc_hzFunction · 0.85
ff_handle_socket_opsFunction · 0.85
rte_rdtscFunction · 0.50
rte_spinlock_lockFunction · 0.50
rte_pauseFunction · 0.50
rte_spinlock_unlockFunction · 0.50

Tested by

no test coverage detected