From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by dpdk.org (Postfix) with ESMTP id EDFDE1B80E for ; Fri, 9 Feb 2018 11:27:09 +0100 (CET) Received: by mail-wm0-f65.google.com with SMTP id v71so15309908wmv.2 for ; Fri, 09 Feb 2018 02:27:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=2wjSLI5HBA26ruju4uhlJVwjwcGrImn5MHYl5PNZH2U=; b=Yov06vsonC+Gkkb4zFCwRmV7zjs3C4y7FWVelUhch3o39WXOXeWQr0U/1ltxUX5+wZ lm7socppFvaDNaTps0M5zeDeTd1HppgqeiFyfD9zmRV9KzYqQ9b7MtvQxLf4hrgYn66s g0q1VniY5jiHM9RGsbVIeBfU3cFIOr8rLTtJQ8AVa4OvDiw0qJPoYHHnJ+y+5lE25N1u mrOzSsE/8oZkBRpU65hOYoLqiEx9G1UebEHiLMPM0X4AAOm5BcI0g4ZR6BZrsM5QvLpj 5tCQNvYTLbXkuVjR+rjR268OPnsqXS/tFDIuaROyiqmUS69bg9fqmoWUhYmegkWr9thO HaFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=2wjSLI5HBA26ruju4uhlJVwjwcGrImn5MHYl5PNZH2U=; b=WfXHwG2fUojORdPhELyyl5w/P1m/PJncYaAmInwJPGuT73uXOWGE72fOlEgJZp4zP4 eWSqhoYGr1h0QpM756rOrImJw8BdQzyxn44xjsJoyzN0PzoFVJf5He3FWoV0x1f0dFtb yJNAAwCDN/biMBV0w1LvBVz3r5chaWg1s8Hr9PxevL/3wLgZQ+kFM97Ta6ip8FCQNlGK lHVOeEoCRhf7c0PqF3v8Qn44PIVRbhfv2vWtwC2Tu9PMTBBDQcFegEuaBiXVwhzoxecp vjz51fNdo8zYgUjYTSoFddu2On6RvFWR9GntYEHXEAje5j9n89AB7qmjTotPhJBLNLNp 7hLQ== X-Gm-Message-State: APf1xPBJRexTBI/4maiFvZULr0OJn5mMHL2s+cu5QXXLO5EaLG6DMk4L fyiogsYXiasZs4yW44DBzKgUsDEh X-Google-Smtp-Source: AH8x226HxZh4jM3TNA+xnwvqDAObj22iK0MPsRYsoSo7f3UY+pPVKBBLk7LdI3IG18kTpTUsg26EXw== X-Received: by 10.28.156.67 with SMTP id f64mr1708275wme.11.1518172029686; Fri, 09 Feb 2018 02:27:09 -0800 (PST) Received: from ar771e-Precision-7520.vyatta.net ([137.221.143.78]) by smtp.gmail.com with ESMTPSA id d125sm1439610wmc.47.2018.02.09.02.27.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Feb 2018 02:27:09 -0800 (PST) From: alanrobertsonatt@gmail.com To: cristian.dumitrescu@intel.com Cc: dev@dpdk.org, Alan Robertson Date: Fri, 9 Feb 2018 10:26:59 +0000 Message-Id: <1518172019-7040-1-git-send-email-alanrobertsonatt@gmail.com> X-Mailer: git-send-email 2.7.4 Subject: [dpdk-dev] [PATCH] Improve the shaper accuracy for large packets X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Feb 2018 10:27:10 -0000 From: Alan Robertson There were 2 issues, the first was time could be lost whilst updating the traffic-class period, the second was a frame could be delayed if not enough tokens were available for the full frame. By allowing the shaper to borrow credit from the next period the throughput is improved. --- lib/librte_sched/rte_sched.c | 58 +++++++++++++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 17 deletions(-) diff --git a/lib/librte_sched/rte_sched.c b/lib/librte_sched/rte_sched.c index 634486c..e53a424 100644 --- a/lib/librte_sched/rte_sched.c +++ b/lib/librte_sched/rte_sched.c @@ -57,7 +57,7 @@ struct rte_sched_subport { /* Traffic classes (TCs) */ uint64_t tc_time; /* time of next update */ uint32_t tc_credits_per_period[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]; - uint32_t tc_credits[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]; + int32_t tc_credits[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]; uint32_t tc_period; /* TC oversubscription */ @@ -98,7 +98,7 @@ struct rte_sched_pipe { /* Traffic classes (TCs) */ uint64_t tc_time; /* time of next update */ - uint32_t tc_credits[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]; + int32_t tc_credits[RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE]; /* Weighted Round Robin (WRR) */ uint8_t wrr_tokens[RTE_SCHED_QUEUES_PER_PIPE]; @@ -1451,6 +1451,8 @@ grinder_credits_update(struct rte_sched_port *port, uint32_t pos) struct rte_sched_pipe *pipe = grinder->pipe; struct rte_sched_pipe_profile *params = grinder->pipe_params; uint64_t n_periods; + uint32_t tc; + uint64_t lapsed; /* Subport TB */ n_periods = (port->time - subport->tb_time) / subport->tb_period; @@ -1466,20 +1468,42 @@ grinder_credits_update(struct rte_sched_port *port, uint32_t pos) /* Subport TCs */ if (unlikely(port->time >= subport->tc_time)) { - subport->tc_credits[0] = subport->tc_credits_per_period[0]; - subport->tc_credits[1] = subport->tc_credits_per_period[1]; - subport->tc_credits[2] = subport->tc_credits_per_period[2]; - subport->tc_credits[3] = subport->tc_credits_per_period[3]; - subport->tc_time = port->time + subport->tc_period; + for (tc = 0; tc < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; tc++) { + if (subport->tc_credits[tc] < 0) + subport->tc_credits[tc] += + subport->tc_credits_per_period[tc]; + else + subport->tc_credits[tc] = + subport->tc_credits_per_period[tc]; + } + /* If we've run into the next period only update the clock to + * the time + tc_period so we'll replenish the tc tokens early + * in the next tc_period to compensate. */ + lapsed = port->time - subport->tc_time; + if (lapsed < subport->tc_period) + subport->tc_time += subport->tc_period; + else + subport->tc_time = port->time + subport->tc_period; } /* Pipe TCs */ if (unlikely(port->time >= pipe->tc_time)) { - pipe->tc_credits[0] = params->tc_credits_per_period[0]; - pipe->tc_credits[1] = params->tc_credits_per_period[1]; - pipe->tc_credits[2] = params->tc_credits_per_period[2]; - pipe->tc_credits[3] = params->tc_credits_per_period[3]; - pipe->tc_time = port->time + params->tc_period; + for (tc = 0; tc < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; tc++) { + if (pipe->tc_credits[tc] < 0) + pipe->tc_credits[tc] += + params->tc_credits_per_period[tc]; + else + pipe->tc_credits[tc] = + params->tc_credits_per_period[tc]; + } + /* If we've run into the next period only update the clock to + * the time + tc_period so we'll replenish the tc tokens early + * in the next tc_period to compensate. */ + lapsed = port->time - pipe->tc_time; + if (lapsed < params->tc_period) + pipe->tc_time += params->tc_period; + else + pipe->tc_time = port->time + params->tc_period; } } @@ -1586,16 +1610,16 @@ grinder_credits_check(struct rte_sched_port *port, uint32_t pos) uint32_t tc_index = grinder->tc_index; uint32_t pkt_len = pkt->pkt_len + port->frame_overhead; uint32_t subport_tb_credits = subport->tb_credits; - uint32_t subport_tc_credits = subport->tc_credits[tc_index]; + int32_t subport_tc_credits = subport->tc_credits[tc_index]; uint32_t pipe_tb_credits = pipe->tb_credits; - uint32_t pipe_tc_credits = pipe->tc_credits[tc_index]; + int32_t pipe_tc_credits = pipe->tc_credits[tc_index]; int enough_credits; /* Check queue credits */ enough_credits = (pkt_len <= subport_tb_credits) && - (pkt_len <= subport_tc_credits) && + (subport_tc_credits > 0) && (pkt_len <= pipe_tb_credits) && - (pkt_len <= pipe_tc_credits); + (pipe_tc_credits > 0); if (!enough_credits) return 0; @@ -1603,8 +1627,8 @@ grinder_credits_check(struct rte_sched_port *port, uint32_t pos) /* Update port credits */ subport->tb_credits -= pkt_len; subport->tc_credits[tc_index] -= pkt_len; - pipe->tb_credits -= pkt_len; pipe->tc_credits[tc_index] -= pkt_len; + pipe->tb_credits -= pkt_len; return 1; } -- 2.7.4