From patchwork Fri May 6 19:44:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peilin Ye X-Patchwork-Id: 12841557 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 90C1DC433F5 for ; Fri, 6 May 2022 19:44:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389728AbiEFTsc (ORCPT ); Fri, 6 May 2022 15:48:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1388813AbiEFTsa (ORCPT ); Fri, 6 May 2022 15:48:30 -0400 Received: from mail-qt1-x82b.google.com (mail-qt1-x82b.google.com [IPv6:2607:f8b0:4864:20::82b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9065B6A04A; Fri, 6 May 2022 12:44:46 -0700 (PDT) Received: by mail-qt1-x82b.google.com with SMTP id y3so6776604qtn.8; Fri, 06 May 2022 12:44:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cXiQMICJP3bxY1/QE8ewT+olGQfAupwoldLomWdcXI4=; b=DHjktLcZ00A5m18JehZWYxviKPezFv0NNgEVI40vV2zf+mEVtMM2RFwlV4czW8Vbk5 HkgwHVFU8WT4Bs34NRF+b8B5uH+UhfXGgl6JssfI+TtBce+3vRHsPoN7F6ufk8PgZKt1 uKe0Pg1Z1MZ4Uem0T92rHGHx5jawDWJRgg9ZUbEPgL5JLeIjTrF9UA2Hc+XjlXzUv8gF e62Mqq0qWe1v7NbzaxeL4+4F5OUHFetNkhcwYnNf3m9Y56+NB9SHWiih8dVqJUupNTlN 4etfLdHmu3aj0um/UPzYTJ0Ody6BFxYipuG7Q8qTxnK/IWmHHOiLFiRXMNx8UDUBZEaD YRgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cXiQMICJP3bxY1/QE8ewT+olGQfAupwoldLomWdcXI4=; b=Uv+/JTJuu4xdWDJhgR05draA0SuLqOCYXgAyNVGGFSm9ekR/kZRwfC0DdaL12kOI97 GjtggZkn0K+4MDMwuJ7jJ6e6sKG4h577ctTMKo/67NvZhKUXQXhCzdgYkV5JlTFUj5lY 7eJnrPsB2xCg15laskXZ4wDJyRew1qmd3jRK8NIzF72nPPlNRE/NllwEH22BaTvUiucn cQrpF6SAZbnctndPR5fJpc3I9rwpZyHKEm8ZQO8TVijfhAZRNHtnqoj7iPf8AAeBUgmP kER9XyO8pD7whew+aMgpAMs8PfO2SM2mGJtEqHuCPomp+5NUSpZVVNtoWlSZlu0JT9TF bajQ== X-Gm-Message-State: AOAM533DtJWjlLKO+shoo5VEyQnjTmDGR3dXkc7cVbZsmQCwuUh6Yw1O fuzjadTBViCZ7n0DG7xkPA== X-Google-Smtp-Source: ABdhPJwJuyS5vbPmqZSAtTzTUVPVw8K2A2rWFl+k295aS7kdAos3n2zR5GOzWDnlzxzqB4tIKG2ZQg== X-Received: by 2002:a05:622a:1b8d:b0:2f2:f4a6:d9dd with SMTP id bp13-20020a05622a1b8d00b002f2f4a6d9ddmr4432083qtb.242.1651866285599; Fri, 06 May 2022 12:44:45 -0700 (PDT) Received: from bytedance.attlocal.net (ec2-52-72-174-210.compute-1.amazonaws.com. [52.72.174.210]) by smtp.gmail.com with ESMTPSA id bj32-20020a05620a192000b0069fc2a7e7a5sm2744121qkb.75.2022.05.06.12.44.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 May 2022 12:44:45 -0700 (PDT) From: Peilin Ye To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Hideaki YOSHIFUJI , David Ahern , Jamal Hadi Salim , Cong Wang , Jiri Pirko Cc: Peilin Ye , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Cong Wang , Peilin Ye Subject: [PATCH RFC v1 net-next 1/4] net: Introduce Qdisc backpressure infrastructure Date: Fri, 6 May 2022 12:44:22 -0700 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC From: Peilin Ye Currently sockets (especially UDP ones) can drop a lot of traffic at TC egress when rate limited by shaper Qdiscs like HTB. Improve it by implementing the following state machine for sockets (currently only support UDP and TCP ones): ┌────────────────┐ [a] ┌────────────────┐ [b] ┌────────────────┐ │ SK_UNTHROTTLED │─ ─ ─ >│ SK_OVERLIMIT │─ ─ ─ >│ SK_THROTTLED │ └────────────────┘ └────────────────┘ └────────────────┘ └─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ < ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─┘ [c] Take TBF as an example, [a] When TBF's inner Qdisc (e.g. bfifo) becomes full, TBF fails to enqueue an skb belonging to UNTHROTTLED socket A. socket A is marked as OVERLIMIT, and added to TBF's "backpressure_list"; [b] When TBF runs out of tokens, it marks all OVERLIMIT sockets (including A) on its backpressure_list as THROTTLED, and schedules a Qdisc watchdog timer to wait for more tokens; [c] After the timer expires, all THROTTLED sockets (including A) are removed from TBF's backpressure_list, and marked as UNTHROTTLED. UDP and TCP sleep on THROTTLED sockets in sock_wait_for_wmem() and sk_stream_wait_memory() respectively. epoll() and friends should not report EPOLL{OUT,WRNORM} for THROTTLED sockets. When unthrottling in [c], call ->sk_write_space() to wake up UDP and/or TCP waiters, and notify SOCKWQ_ASYNC_NOSPACE subscribers. For each device, backpressure_list operations are always serialized by Qdisc root_lock. When marking a socket as OVERLIMIT in [a], use a cmpxchg() to make sure that multiple CPUs do not try to add this socket to different backpressure_lists (on different devices) concurrently. After removing a THROTTLED socket from backpressure_list in [c], use a smp_store_release() to make sure changes have been committed to memory before marking the socket as UNTHROTTLED. Suggested-by: Cong Wang Signed-off-by: Peilin Ye --- include/net/sch_generic.h | 43 +++++++++++++++++++++++++++++++++++++++ include/net/sock.h | 18 +++++++++++++++- net/core/dev.c | 1 + net/core/sock.c | 6 ++++-- net/ipv4/tcp_ipv4.c | 11 +++++++--- net/sched/sch_generic.c | 4 ++++ 6 files changed, 77 insertions(+), 6 deletions(-) diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h index 9bab396c1f3b..5ddbe0b65cb6 100644 --- a/include/net/sch_generic.h +++ b/include/net/sch_generic.h @@ -19,6 +19,7 @@ #include #include #include +#include struct Qdisc_ops; struct qdisc_walker; @@ -108,6 +109,7 @@ struct Qdisc { struct gnet_stats_queue __percpu *cpu_qstats; int pad; refcount_t refcnt; + struct list_head backpressure_list; /* * For performance sake on SMP, we put highly modified fields at the end @@ -1221,6 +1223,47 @@ static inline int qdisc_drop_all(struct sk_buff *skb, struct Qdisc *sch, return NET_XMIT_DROP; } +static inline void qdisc_backpressure_overlimit(struct Qdisc *sch, struct sk_buff *skb) +{ + struct sock *sk = skb->sk; + + if (!sk || !sk_fullsock(sk)) + return; + + if (cmpxchg(&sk->sk_backpressure_status, SK_UNTHROTTLED, SK_OVERLIMIT) == SK_UNTHROTTLED) { + sock_hold(sk); + list_add_tail(&sk->sk_backpressure_node, &sch->backpressure_list); + } +} + +static inline void qdisc_backpressure_throttle(struct Qdisc *sch) +{ + struct list_head *pos; + struct sock *sk; + + list_for_each(pos, &sch->backpressure_list) { + sk = list_entry(pos, struct sock, sk_backpressure_node); + + WRITE_ONCE(sk->sk_backpressure_status, SK_THROTTLED); + } +} + +static inline void qdisc_backpressure_unthrottle(struct Qdisc *sch) +{ + struct list_head *pos, *next; + struct sock *sk; + + list_for_each_safe(pos, next, &sch->backpressure_list) { + sk = list_entry(pos, struct sock, sk_backpressure_node); + + list_del_init(pos); + smp_store_release(&sk->sk_backpressure_status, SK_UNTHROTTLED); + sk->sk_write_space(sk); + + sock_put(sk); + } +} + /* Length to Time (L2T) lookup in a qdisc_rate_table, to determine how long it will take to send a packet given its size. */ diff --git a/include/net/sock.h b/include/net/sock.h index 73063c88a249..6ed2de43dc98 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -315,6 +315,8 @@ struct sk_filter; * @sk_rcvtimeo: %SO_RCVTIMEO setting * @sk_sndtimeo: %SO_SNDTIMEO setting * @sk_txhash: computed flow hash for use on transmit + * @sk_backpressure_status: Qdisc backpressure status + * @sk_backpressure_node: linkage for Qdisc backpressure list * @sk_txrehash: enable TX hash rethink * @sk_filter: socket filtering instructions * @sk_timer: sock cleanup timer @@ -468,6 +470,8 @@ struct sock { unsigned int sk_gso_max_size; gfp_t sk_allocation; __u32 sk_txhash; + u32 sk_backpressure_status; /* see enum sk_backpressure */ + struct list_head sk_backpressure_node; /* * Because of non atomicity rules, all @@ -548,6 +552,12 @@ enum sk_pacing { SK_PACING_FQ = 2, }; +enum sk_backpressure { + SK_UNTHROTTLED = 0, + SK_OVERLIMIT = 1, + SK_THROTTLED = 2, +}; + /* Pointer stored in sk_user_data might not be suitable for copying * when cloning the socket. For instance, it can point to a reference * counted object. sk_user_data bottom bit is set if pointer must not @@ -2522,12 +2532,18 @@ static inline struct page_frag *sk_page_frag(struct sock *sk) bool sk_page_frag_refill(struct sock *sk, struct page_frag *pfrag); +static inline bool sk_is_throttled(const struct sock *sk) +{ + return READ_ONCE(sk->sk_backpressure_status) == SK_THROTTLED; +} + /* * Default write policy as shown to user space via poll/select/SIGIO */ static inline bool sock_writeable(const struct sock *sk) { - return refcount_read(&sk->sk_wmem_alloc) < (READ_ONCE(sk->sk_sndbuf) >> 1); + return !sk_is_throttled(sk) && + refcount_read(&sk->sk_wmem_alloc) < (READ_ONCE(sk->sk_sndbuf) >> 1); } static inline gfp_t gfp_any(void) diff --git a/net/core/dev.c b/net/core/dev.c index c2d73595a7c3..7c3d136725b9 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -5013,6 +5013,7 @@ static __latent_entropy void net_tx_action(struct softirq_action *h) if (!(q->flags & TCQ_F_NOLOCK)) { root_lock = qdisc_lock(q); spin_lock(root_lock); + qdisc_backpressure_unthrottle(q); } else if (unlikely(test_bit(__QDISC_STATE_DEACTIVATED, &q->state))) { /* There is a synchronize_net() between diff --git a/net/core/sock.c b/net/core/sock.c index be20a1af20e5..7ed9d2bd991f 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -2034,6 +2034,7 @@ struct sock *sk_alloc(struct net *net, int family, gfp_t priority, sock_net_set(sk, net); refcount_set(&sk->sk_wmem_alloc, 1); + INIT_LIST_HEAD(&sk->sk_backpressure_node); mem_cgroup_sk_alloc(sk); cgroup_sk_alloc(&sk->sk_cgrp_data); @@ -2589,7 +2590,8 @@ static long sock_wait_for_wmem(struct sock *sk, long timeo) break; set_bit(SOCK_NOSPACE, &sk->sk_socket->flags); prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE); - if (refcount_read(&sk->sk_wmem_alloc) < READ_ONCE(sk->sk_sndbuf)) + if (!sk_is_throttled(sk) && + refcount_read(&sk->sk_wmem_alloc) < READ_ONCE(sk->sk_sndbuf)) break; if (sk->sk_shutdown & SEND_SHUTDOWN) break; @@ -2624,7 +2626,7 @@ struct sk_buff *sock_alloc_send_pskb(struct sock *sk, unsigned long header_len, if (sk->sk_shutdown & SEND_SHUTDOWN) goto failure; - if (sk_wmem_alloc_get(sk) < READ_ONCE(sk->sk_sndbuf)) + if (!sk_is_throttled(sk) && sk_wmem_alloc_get(sk) < READ_ONCE(sk->sk_sndbuf)) break; sk_set_bit(SOCKWQ_ASYNC_NOSPACE, sk); diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 918816ec5dd4..6e905995bfa2 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -3006,9 +3006,14 @@ void tcp4_proc_exit(void) */ bool tcp_stream_memory_free(const struct sock *sk, int wake) { - const struct tcp_sock *tp = tcp_sk(sk); - u32 notsent_bytes = READ_ONCE(tp->write_seq) - - READ_ONCE(tp->snd_nxt); + const struct tcp_sock *tp; + u32 notsent_bytes; + + if (sk_is_throttled(sk)) + return false; + + tp = tcp_sk(sk); + notsent_bytes = READ_ONCE(tp->write_seq) - READ_ONCE(tp->snd_nxt); return (notsent_bytes << wake) < tcp_notsent_lowat(tp); } diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c index dba0b3e24af5..9ab314b874a7 100644 --- a/net/sched/sch_generic.c +++ b/net/sched/sch_generic.c @@ -674,6 +674,7 @@ struct Qdisc noop_qdisc = { .qlen = 0, .lock = __SPIN_LOCK_UNLOCKED(noop_qdisc.skb_bad_txq.lock), }, + .backpressure_list = LIST_HEAD_INIT(noop_qdisc.backpressure_list), }; EXPORT_SYMBOL(noop_qdisc); @@ -947,6 +948,7 @@ struct Qdisc *qdisc_alloc(struct netdev_queue *dev_queue, qdisc_skb_head_init(&sch->q); gnet_stats_basic_sync_init(&sch->bstats); spin_lock_init(&sch->q.lock); + INIT_LIST_HEAD(&sch->backpressure_list); if (ops->static_flags & TCQ_F_CPUSTATS) { sch->cpu_bstats = @@ -1025,6 +1027,8 @@ void qdisc_reset(struct Qdisc *qdisc) if (ops->reset) ops->reset(qdisc); + qdisc_backpressure_unthrottle(qdisc); + __skb_queue_purge(&qdisc->gso_skb); __skb_queue_purge(&qdisc->skb_bad_txq); From patchwork Fri May 6 19:44:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peilin Ye X-Patchwork-Id: 12841558 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1FDEAC433F5 for ; Fri, 6 May 2022 19:45:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1391526AbiEFTs5 (ORCPT ); Fri, 6 May 2022 15:48:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1388813AbiEFTs4 (ORCPT ); Fri, 6 May 2022 15:48:56 -0400 Received: from mail-qk1-x733.google.com (mail-qk1-x733.google.com [IPv6:2607:f8b0:4864:20::733]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECC0C6A009; Fri, 6 May 2022 12:45:12 -0700 (PDT) Received: by mail-qk1-x733.google.com with SMTP id 126so6641549qkm.4; Fri, 06 May 2022 12:45:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1YXdjAkPRz7R0GDRHx5qp1cZI2CVvENVv7OuXkzP9JQ=; b=JZw3DRAfFlP/GScz37EOfnmFGWu5HnV1hE15YSpgW/LbCC7v0Ovq0hX05JUbA4Bja0 d38/4A8DaHqlecmfbOgfAqadmdQd18SldlKPQyOK6pjemx6H9puQCYZSlSYrAalDIY8i /4jbOjzEKgbneWdSWNyBxHbCqofQqRGNcEWni2zSmJcpt2PWIOYR0rqWRWbu0vsg+LNX uH+za1HU3H5iHViSzT5CR3sjxkcmriZnJ9phv0wtNiTwHNRnfvnhuWoHBNomJ89rYYmV ar5XB7gmgXuXgmIakq+VNv4NccUjSidxBRr/HHkRH8YVIL/NoihVmYqfwffYG0w9saTb tacQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1YXdjAkPRz7R0GDRHx5qp1cZI2CVvENVv7OuXkzP9JQ=; b=CBwzp5vaWVvQDitpYo5LIzZ3a67PMCfD+gWtOUWRorRIwqPZex80tLBnK3URHkFkeA A9O9OquVhM1qIR4XbryKeQjSfJDM5RMKtg6nbEKtyI9IyStMroSctcD4h/rNSea8QM8F njzdJNDj4OgrqICfleTk7RjVl5L/64sDNBqjK0koHFECjQ9LnNTc2gdkjmOzXcgXrHw4 5zSVbKZAQPNLD0noC4oaq5E8pvWXcW7cw0oDxaGAORplcMUdfrKZMFJdDdL9HdUdq5ke ss/dw6KofVgf86GKHunIgbWFL+ggiTQM4Ba/gGymoM0+yx+zczmfZN73J42x/FE16oF7 6J5A== X-Gm-Message-State: AOAM530CthOYsR0zLkb0mFruRcqJ7VZ2v1REUQBzdqkgJktrHQelEoLS NUXfdbvhhWhRClPKyCM11Q== X-Google-Smtp-Source: ABdhPJwlhp9W8HQGq13lFPgo2AFK4RaLx2MrR9/OlkgRqmrr2YKDwso0Dn8UVyul19xWdnm5f4qsEg== X-Received: by 2002:a05:620a:44c6:b0:6a0:51fb:49cf with SMTP id y6-20020a05620a44c600b006a051fb49cfmr453864qkp.537.1651866312103; Fri, 06 May 2022 12:45:12 -0700 (PDT) Received: from bytedance.attlocal.net (ec2-52-72-174-210.compute-1.amazonaws.com. [52.72.174.210]) by smtp.gmail.com with ESMTPSA id t196-20020a37aacd000000b0069fc13ce1d7sm2889949qke.8.2022.05.06.12.45.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 May 2022 12:45:11 -0700 (PDT) From: Peilin Ye To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Hideaki YOSHIFUJI , David Ahern , Jamal Hadi Salim , Cong Wang , Jiri Pirko Cc: Peilin Ye , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Cong Wang , Peilin Ye Subject: [PATCH RFC v1 net-next 2/4] net/sched: sch_tbf: Use Qdisc backpressure infrastructure Date: Fri, 6 May 2022 12:44:59 -0700 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC From: Peilin Ye Recently we introduced a Qdisc backpressure infrastructure for TCP and UDP sockets. Use it in TBF. Suggested-by: Cong Wang Signed-off-by: Peilin Ye --- net/sched/sch_tbf.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c index 72102277449e..06229765290b 100644 --- a/net/sched/sch_tbf.c +++ b/net/sched/sch_tbf.c @@ -250,6 +250,7 @@ static int tbf_enqueue(struct sk_buff *skb, struct Qdisc *sch, } ret = qdisc_enqueue(skb, q->qdisc, to_free); if (ret != NET_XMIT_SUCCESS) { + qdisc_backpressure_overlimit(sch, skb); if (net_xmit_drop_count(ret)) qdisc_qstats_drop(sch); return ret; @@ -306,6 +307,7 @@ static struct sk_buff *tbf_dequeue(struct Qdisc *sch) return skb; } + qdisc_backpressure_throttle(sch); qdisc_watchdog_schedule_ns(&q->watchdog, now + max_t(long, -toks, -ptoks)); From patchwork Fri May 6 19:45:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peilin Ye X-Patchwork-Id: 12841559 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4B229C433EF for ; Fri, 6 May 2022 19:45:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389522AbiEFTtY (ORCPT ); Fri, 6 May 2022 15:49:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1391394AbiEFTtW (ORCPT ); Fri, 6 May 2022 15:49:22 -0400 Received: from mail-qv1-xf32.google.com (mail-qv1-xf32.google.com [IPv6:2607:f8b0:4864:20::f32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06D971A061; Fri, 6 May 2022 12:45:38 -0700 (PDT) Received: by mail-qv1-xf32.google.com with SMTP id eq14so6136177qvb.4; Fri, 06 May 2022 12:45:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=26UBhVESvjEt8vd9ljEpnrYxuM75PmMbuVfnsO+5kk8=; b=OideI0KaQlA/EguUnJr9tHJ2iTCxXXeRQbsI0HYlcM5BWN3ICtro3OItNuTLO68gC5 /RNF9st81UpXgFXfKYZXUH+GcRs0TdlqUi2DjKVHPlkV25fFYKIYJEh4uRqBSE+LTxqT NhWFc6gAAlMuXDViZJcXxDuIwldYAZvia8CGYwj+CzoLweSwvmHhvbgfl1BViP7vcV3F l9AXA0fn02tY5AfKDo8mdqFGoAa+99t4TCRlLPzyEOiyJuuvznATLSYFAVQtMnA41a9J Ewfh2wnVnHKwtqAhnRb5Z5YYfITvogxZO4+EAw+Hk7PTci6nX3Z7zHo/rOMRYra00dZl OxfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=26UBhVESvjEt8vd9ljEpnrYxuM75PmMbuVfnsO+5kk8=; b=u7M2lJbqpjJ7Pj04TyfTuqlQml1YQ6LATBknpmaKbGvR4FxENbOm+P7A+ddKWo3utj HHt2bFJrx5sgR2QBG0I5ihB2usecDtB5fWpYHmrRrSI2Fhgi5vBkH4PofX0rVK3/+puc P6dMriqWFsy2Lnh2v2PTSLveQYjLBrwDrFWVmTLljnNp22SCKVsjjJmGnLCDT137L3Zx 367ZhdUQ1Ix9R4jmqqmBQfr7I1LyCcjTSvoXZewK9xwqiEX0TE8Xt9J6uHNd3fub0yn9 jqDzO/qz0dMrQU+puflg0qw3b3nl5DCvVI+CV4EZ4utEbqo6piCw32dk/CCeKi6/OiD3 xTmQ== X-Gm-Message-State: AOAM532jDPjW0UlKaXrCDNTFLlIKXolE9LmB2KM6qGujsCTBTU3crUPo K3AgnBKAjar8SdpVdR/KcweGxKQttLtx X-Google-Smtp-Source: ABdhPJycrjIOghTy5gAFeYF4Lhjrq1tCpWl7yvNFArlYIg2141TlkqfJs+6F64I9fiNu3wUpk/0GgQ== X-Received: by 2002:ad4:5c6e:0:b0:45a:aefd:f551 with SMTP id i14-20020ad45c6e000000b0045aaefdf551mr3930759qvh.95.1651866337093; Fri, 06 May 2022 12:45:37 -0700 (PDT) Received: from bytedance.attlocal.net (ec2-52-72-174-210.compute-1.amazonaws.com. [52.72.174.210]) by smtp.gmail.com with ESMTPSA id x68-20020a376347000000b0069fc13ce1e2sm2914541qkb.19.2022.05.06.12.45.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 May 2022 12:45:36 -0700 (PDT) From: Peilin Ye To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Hideaki YOSHIFUJI , David Ahern , Jamal Hadi Salim , Cong Wang , Jiri Pirko Cc: Peilin Ye , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Cong Wang , Peilin Ye Subject: [PATCH RFC v1 net-next 3/4] net/sched: sch_htb: Use Qdisc backpressure infrastructure Date: Fri, 6 May 2022 12:45:24 -0700 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC From: Peilin Ye Recently we introduced a Qdisc backpressure infrastructure for TCP and UDP sockets. Use it in HTB. Suggested-by: Cong Wang Signed-off-by: Peilin Ye --- net/sched/sch_htb.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c index 23a9d6242429..21d78dff08e7 100644 --- a/net/sched/sch_htb.c +++ b/net/sched/sch_htb.c @@ -623,6 +623,7 @@ static int htb_enqueue(struct sk_buff *skb, struct Qdisc *sch, __qdisc_enqueue_tail(skb, &q->direct_queue); q->direct_pkts++; } else { + qdisc_backpressure_overlimit(sch, skb); return qdisc_drop(skb, sch, to_free); } #ifdef CONFIG_NET_CLS_ACT @@ -634,6 +635,7 @@ static int htb_enqueue(struct sk_buff *skb, struct Qdisc *sch, #endif } else if ((ret = qdisc_enqueue(skb, cl->leaf.q, to_free)) != NET_XMIT_SUCCESS) { + qdisc_backpressure_overlimit(sch, skb); if (net_xmit_drop_count(ret)) { qdisc_qstats_drop(sch); cl->drops++; @@ -978,6 +980,9 @@ static struct sk_buff *htb_dequeue(struct Qdisc *sch) goto ok; } } + + qdisc_backpressure_throttle(sch); + if (likely(next_event > q->now)) qdisc_watchdog_schedule_ns(&q->watchdog, next_event); else From patchwork Fri May 6 19:45:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peilin Ye X-Patchwork-Id: 12841560 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9AE52C433EF for ; Fri, 6 May 2022 19:46:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1391415AbiEFTtq (ORCPT ); Fri, 6 May 2022 15:49:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1391394AbiEFTtp (ORCPT ); Fri, 6 May 2022 15:49:45 -0400 Received: from mail-qv1-xf2e.google.com (mail-qv1-xf2e.google.com [IPv6:2607:f8b0:4864:20::f2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 553203668F; Fri, 6 May 2022 12:46:01 -0700 (PDT) Received: by mail-qv1-xf2e.google.com with SMTP id dv4so6111787qvb.13; Fri, 06 May 2022 12:46:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=REYumsm6kh6dG5JfkpmEJOF6iBFTzLNrYeIRsQ91Yy4=; b=VgAPfjB60nZTL9ZLu1vVz05PN2jFWEmo7BOcQM53pAaGA0tQ83p8FQCMyfMkWCUljO xrUUTVpW545iQaNOP3al4ieey6zhWj2eAeHuWQ2a7+Oe6FuuJbb4bJOvxMWgh3Qk4NmJ Wd7/6LkMCZy7RhIfUGloBVSwbRHaFkIfbkHxfCwJsHyzqaq35+SJZnVWO70KIwVhycPJ XIqvFfFfqOF8Ah2OHjTQ7nwjiYjyxgJ5OSZI+MrmKSFRl2iW4wich8ZSUpf00XWCkFxG S1F7rRgyv7T19H7c6HjBR66HLe1ZrTif7h6o1COmDeSFxKlM8AyLQSxwpijpAH+0W8hM vidQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=REYumsm6kh6dG5JfkpmEJOF6iBFTzLNrYeIRsQ91Yy4=; b=8AXbXr4j8WzxBdo/AWHMG3EPfBQITurOPqO5/M7h2dvnsSNXUMb7/buBy8MYer56ti icHa7fudZXQw4Pu1AEMZmCXH5NpT7FlHSSX7tKZD+P9PamK8+6va0fQtbR1aedMX4aBV e6eLUrLDaZdFSEygr4Q3N45KN0qFol7+0bkZCC/PoRjEpO+upXx9vsAD1wd0CsiXGH9V 211pD6NCLGlAn9eXmnqan7UaDe7EiEShaEyu0MrnYhxT1TVyupjOS7TRapJdjkFzSwDM RSpriHlXuGQ8X7yf5x4Uh4jFY0l3cdYK4c/z9onFXcrAmpX1fwnkrcybQ3EsrgH4e3ef P9Ow== X-Gm-Message-State: AOAM531je1EghQGNcld0eONcd7dTvmmQaffO3ec365c24HyMHhdmsXBh Tdzp3yjB133R5OgD00o1r/Lo5PYVHJVM X-Google-Smtp-Source: ABdhPJwn1oEegsPCYxjvx5slYAKeM9HTqK+wZHoSG8ht/TYx6MTMPYLOpdpDUgiPDZWYRYuyRGvNZg== X-Received: by 2002:ad4:5749:0:b0:459:1c08:f80a with SMTP id q9-20020ad45749000000b004591c08f80amr3892776qvx.56.1651866360484; Fri, 06 May 2022 12:46:00 -0700 (PDT) Received: from bytedance.attlocal.net (ec2-52-72-174-210.compute-1.amazonaws.com. [52.72.174.210]) by smtp.gmail.com with ESMTPSA id c14-20020ac8518e000000b002f39b99f694sm3028513qtn.46.2022.05.06.12.45.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 May 2022 12:46:00 -0700 (PDT) From: Peilin Ye To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Hideaki YOSHIFUJI , David Ahern , Jamal Hadi Salim , Cong Wang , Jiri Pirko Cc: Peilin Ye , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Cong Wang , Peilin Ye Subject: [PATCH RFC v1 net-next 4/4] net/sched: sch_cbq: Use Qdisc backpressure infrastructure Date: Fri, 6 May 2022 12:45:46 -0700 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC From: Peilin Ye Recently we introduced a Qdisc backpressure infrastructure for TCP and UDP sockets. Use it in CBQ. Suggested-by: Cong Wang Signed-off-by: Peilin Ye --- net/sched/sch_cbq.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/net/sched/sch_cbq.c b/net/sched/sch_cbq.c index 02d9f0dfe356..4a5204da49d0 100644 --- a/net/sched/sch_cbq.c +++ b/net/sched/sch_cbq.c @@ -382,6 +382,7 @@ cbq_enqueue(struct sk_buff *skb, struct Qdisc *sch, return ret; } + qdisc_backpressure_overlimit(sch, skb); if (net_xmit_drop_count(ret)) { qdisc_qstats_drop(sch); cbq_mark_toplevel(q, cl); @@ -509,6 +510,7 @@ static enum hrtimer_restart cbq_undelay(struct hrtimer *timer) time = 0; time = ktime_add_ns(time, PSCHED_TICKS2NS(now + delay)); + qdisc_backpressure_throttle(sch); hrtimer_start(&q->delay_timer, time, HRTIMER_MODE_ABS_PINNED); } @@ -851,9 +853,11 @@ cbq_dequeue(struct Qdisc *sch) if (sch->q.qlen) { qdisc_qstats_overlimit(sch); - if (q->wd_expires) + if (q->wd_expires) { + qdisc_backpressure_throttle(sch); qdisc_watchdog_schedule(&q->watchdog, now + q->wd_expires); + } } return NULL; }