Received: by 2002:a05:7412:8598:b0:f9:33c2:5753 with SMTP id n24csp351266rdh; Tue, 19 Dec 2023 00:17:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IE+xbciyTGNOZY2/9hc8pOMTT6/gvVrU4aPiLeRJ8K3bdh8ytODEvj3s1g2afcHhzBLDu7J X-Received: by 2002:a17:906:34db:b0:a23:354d:b35b with SMTP id h27-20020a17090634db00b00a23354db35bmr2231897ejb.81.1702973873005; Tue, 19 Dec 2023 00:17:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702973872; cv=none; d=google.com; s=arc-20160816; b=lLDcXVwaq7wJ6wWlWoWQbuzbipobGzjsuNKaCTBYFYDwNMVZxdb7SbnTdA9E52zxQw QNY2dNRd4NZxnAETdPwBkBkLis87cxHdpwtHe6+NYUqFRdnU0uz8rSAygRPT820nc2Lw ukZ39cVbnRzr1s1JjG/QDuSta56bs1voUCpfyCeZWLLNsDRF1j3C5Npo5ax091keUOX8 ZU/MtAkNMoLyYkds8yGxC4M1YGAAVsWTMqxnICkUwZCOnxZb9eLHK3lb2gCp57M1doWt 2oPLWrtajXB4Rxhj5tViu2x8oyr8xv3AiVK7ADp4kOiZ+Z7osxaOyShDUpxQ3ohydl39 TLOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=vy+qO4feppCktJSfuP+uEJ2An7TSZaSpBADQ4eHxKp4=; fh=vFOAT8HIDv/DnUdUUcMPjRVwikTIIqbaEbo+VvQyfA8=; b=UQblu5550SoSJu0ught7xMqy+fM3Twvsb1bPB69JIMoemJgdQavV9guAhDjSLERj7K 7m63zOlem1H4e3bKcOoCatD9waTRLhH9GU6YJMAuRl3fjI1W8Vaz3933lZyHpFJmM8oC qrx95J7CT1MWaf4obQMF6ozjStD5zPtqJQ8EvPJ7srVmqJP9oMhLLeOUIFJv57SKo5fw TE1NH9xu4dW6GzuuGytVS9rilmKazQl6/nLaoWiCQ3PdALzXSSnsVkHU7PBN1yLYlfPl JMtzuqeTUKshS1lGflEooeaGcb91/ahztsaSzx11Z68BFFv4xP0tIukdQEjei3zrPXzN huSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=WCIsToeM; spf=pass (google.com: domain of linux-kernel+bounces-4871-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4871-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id e18-20020a170906045200b00a24901b6057si235176eja.392.2023.12.19.00.17.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 00:17:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-4871-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=WCIsToeM; spf=pass (google.com: domain of linux-kernel+bounces-4871-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4871-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id C15B11F24AE0 for ; Tue, 19 Dec 2023 08:17:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 31DE612B7B; Tue, 19 Dec 2023 08:17:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="WCIsToeM" X-Original-To: linux-kernel@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 03F4E11CBF; Tue, 19 Dec 2023 08:17:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1702973849; x=1734509849; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=eprSKxW1IRUgwnlytJGk1l5+3qPhJHvreOABgX1Ah2I=; b=WCIsToeM+t1RU4mhoJVnikANqwHnz0Dmw4NN4S8ywz8dU5+mwoXsPo/U CrA25euqQyzABy/5f2if6hqVbbmhknOfGUMazLdzW88nrPDLmutDdWCkV QuFRUMn8Z5ufIOJhkcQfGFkTsO4cfXN0S0p6yfNbxOIZEY9WpcjIDYavu llC7yHKupY4s/IAQr7DvpsltgaP5zSI2saMc+omO0kvAqb0rojc+bSbRB G12hvl0P4O+xBYUEvUGNLiiQReX7M7LQWu5tpl5+bzrd9uS2RDjqvSL2O vBm3sZ0Q4oFZKTofJzpAdQb9HxNhOAtTrxVx/OUgCVTw3Y3k83lJeJRus w==; X-IronPort-AV: E=McAfee;i="6600,9927,10928"; a="2717413" X-IronPort-AV: E=Sophos;i="6.04,287,1695711600"; d="scan'208";a="2717413" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Dec 2023 00:17:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10928"; a="894193921" X-IronPort-AV: E=Sophos;i="6.04,287,1695711600"; d="scan'208";a="894193921" Received: from linux.intel.com ([10.54.29.200]) by fmsmga002.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Dec 2023 00:17:25 -0800 Received: from mohdfai2-iLBPG12-1.png.intel.com (mohdfai2-iLBPG12-1.png.intel.com [10.88.227.73]) by linux.intel.com (Postfix) with ESMTP id 9BE50580C25; Tue, 19 Dec 2023 00:17:22 -0800 (PST) From: Faizal Rahim To: Vladimir Oltean , Vinicius Costa Gomes , Jamal Hadi Salim , Cong Wang , Jiri Pirko , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 net 1/4] net/sched: taprio: fix too early schedules switching Date: Tue, 19 Dec 2023 03:14:50 -0500 Message-Id: <20231219081453.718489-2-faizal.abdul.rahim@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231219081453.718489-1-faizal.abdul.rahim@linux.intel.com> References: <20231219081453.718489-1-faizal.abdul.rahim@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Switching the schedule prematurely leads to a situation where the last entry from oper schedule is still running, during this period, calls to taprio_skb_exceeds_queue_max_sdu() in the enqueue path, such as taprio_enqueue_segmented(), will inspect q->oper_sched. At this point, q->oper_sched refers to the new admin schedule instead of the ongoing oper schedule. Fixes: a878fd46fe43 ("net/sched: keep the max_frm_len information inside struct sched_gate_list") Signed-off-by: Faizal Rahim --- net/sched/sch_taprio.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index 31a8252bd09c..bbcaf05d40ba 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -41,6 +41,7 @@ static struct static_key_false taprio_have_working_mqprio; #define TXTIME_ASSIST_IS_ENABLED(flags) ((flags) & TCA_TAPRIO_ATTR_FLAG_TXTIME_ASSIST) #define FULL_OFFLOAD_IS_ENABLED(flags) ((flags) & TCA_TAPRIO_ATTR_FLAG_FULL_OFFLOAD) #define TAPRIO_FLAGS_INVALID U32_MAX +#define CYCLE_TIME_CORRECTION_UNSPEC S64_MIN struct sched_entry { /* Durations between this GCL entry and the GCL entry where the @@ -75,6 +76,7 @@ struct sched_gate_list { ktime_t cycle_end_time; s64 cycle_time; s64 cycle_time_extension; + s64 cycle_time_correction; s64 base_time; }; @@ -213,6 +215,11 @@ static void switch_schedules(struct taprio_sched *q, *admin = NULL; } +static bool sched_switch_pending(const struct sched_gate_list *oper) +{ + return oper->cycle_time_correction != CYCLE_TIME_CORRECTION_UNSPEC; +} + /* Get how much time has been already elapsed in the current cycle. */ static s32 get_cycle_time_elapsed(struct sched_gate_list *sched, ktime_t time) { @@ -940,7 +947,7 @@ static enum hrtimer_restart advance_sched(struct hrtimer *timer) admin = rcu_dereference_protected(q->admin_sched, lockdep_is_held(&q->current_entry_lock)); - if (!oper) + if (!oper || sched_switch_pending(oper)) switch_schedules(q, &admin, &oper); /* This can happen in two cases: 1. this is the very first run @@ -981,7 +988,7 @@ static enum hrtimer_restart advance_sched(struct hrtimer *timer) * schedule runs. */ end_time = sched_base_time(admin); - switch_schedules(q, &admin, &oper); + oper->cycle_time_correction = 0; } next->end_time = end_time; @@ -1174,6 +1181,7 @@ static int parse_taprio_schedule(struct taprio_sched *q, struct nlattr **tb, } taprio_calculate_gate_durations(q, new); + new->cycle_time_correction = CYCLE_TIME_CORRECTION_UNSPEC; return 0; } -- 2.25.1