From patchwork Thu Jun 30 00:26:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Soltys X-Patchwork-Id: 642282 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3rg0kL312Nz9sCp for ; Thu, 30 Jun 2016 10:27:54 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751909AbcF3A1p (ORCPT ); Wed, 29 Jun 2016 20:27:45 -0400 Received: from drutsystem.com ([84.10.39.251]:50062 "EHLO drutsystem.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751886AbcF3A1d (ORCPT ); Wed, 29 Jun 2016 20:27:33 -0400 Received: from mott.hasevolq.tld (89-65-72-120.dynamic.chello.pl [89.65.72.120]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: nozo) by drutsystem.com (Postfix) with ESMTPSA id 617536B034; Thu, 30 Jun 2016 02:26:49 +0200 (CEST) From: Michal Soltys To: davem@davemloft.net Cc: netdev@vger.kernel.org, kaber@trash.net Subject: [net-next PATCH 1/5] net/sched/sch_hfsc.c: handle corner cases where head may change invalidating calculated deadline Date: Thu, 30 Jun 2016 02:26:44 +0200 Message-Id: <1467246408-913-2-git-send-email-soltys@ziu.info> X-Mailer: git-send-email 2.1.3 In-Reply-To: <1467246408-913-1-git-send-email-soltys@ziu.info> References: <1467246408-913-1-git-send-email-soltys@ziu.info> X-MailScanner-ID: 617536B034.AB16B X-MailScanner: Not scanned: please contact your Internet E-Mail Service Provider for details X-MailScanner-From: soltys@ziu.info X-Spam-Status: No Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Realtime scheduling implemented in HFSC uses head of the queue to make the decision about which packet to schedule next. But in case of any head drop, the deadline calculated for the previous head is not necessarily correct for the next head (unless both packets have the same length). Thanks to peek() function used during dequeue - which internally is a dequeue operation - hfsc is almost safe from this issue, as peek() dequeues and isolates the head storing it temporarily until the real dequeue happens. But there is one exception: if after the class activation a drop happens before the first dequeue operation, there's never a chance to do the peek(). Adding peek() call in enqueue - if this is the first packet in a new backlog period AND the scheduler has realtime curve defined - fixes that one corner case. The 1st hfsc_dequeue() will use that peeked packet, similarly as every subsequent hfsc_dequeue() call uses packet peeked by the previous call. Signed-off-by: Michal Soltys --- net/sched/sch_hfsc.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/net/sched/sch_hfsc.c b/net/sched/sch_hfsc.c index 8cb5eff..6d6df6b 100644 --- a/net/sched/sch_hfsc.c +++ b/net/sched/sch_hfsc.c @@ -1594,8 +1594,17 @@ hfsc_enqueue(struct sk_buff *skb, struct Qdisc *sch, struct sk_buff **to_free) return err; } - if (cl->qdisc->q.qlen == 1) + if (cl->qdisc->q.qlen == 1) { set_active(cl, qdisc_pkt_len(skb)); + /* + * If this is the first packet, isolate the head so an eventual + * head drop before the first dequeue operation has no chance + * to invalidate the deadline. + */ + if (cl->cl_flags & HFSC_RSC) + cl->qdisc->ops->peek(cl->qdisc); + + } qdisc_qstats_backlog_inc(sch, skb); sch->q.qlen++;