1. 24 7月, 2018 2 次提交
    • J
      net: sched: introduce chain object to uapi · 32a4f5ec
      Jiri Pirko 提交于
      Allow user to create, destroy, get and dump chain objects. Do that by
      extending rtnl commands by the chain-specific ones. User will now be
      able to explicitly create or destroy chains (so far this was done only
      automatically according the filter/act needs and refcounting). Also, the
      user will receive notification about any chain creation or destuction.
      Signed-off-by: NJiri Pirko <jiri@mellanox.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      32a4f5ec
    • J
      net: sched: Avoid implicit chain 0 creation · f71e0ca4
      Jiri Pirko 提交于
      Currently, chain 0 is implicitly created during block creation. However
      that does not align with chain object exposure, creation and destruction
      api introduced later on. So make the chain 0 behave the same way as any
      other chain and only create it when it is needed. Since chain 0 is
      somehow special as the qdiscs need to hold pointer to the first chain
      tp, this requires to move the chain head change callback infra to the
      block structure.
      Signed-off-by: NJiri Pirko <jiri@mellanox.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      f71e0ca4
  2. 26 6月, 2018 2 次提交
  3. 29 5月, 2018 2 次提交
    • J
      net: sched: add qstats.qlen to qlen · 6172abc1
      Jakub Kicinski 提交于
      AFAICT struct gnet_stats_queue.qlen is not used in Qdiscs.
      It may, however, be useful for offloads to report HW queue
      length there.  Add that value to the result of qdisc_qlen_sum().
      Signed-off-by: NJakub Kicinski <jakub.kicinski@netronome.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      6172abc1
    • P
      net: sched: shrink struct Qdisc · e9be0e99
      Paolo Abeni 提交于
      The struct Qdisc has a lot of holes, especially after commit
      a53851e2 ("net: sched: explicit locking in gso_cpu fallback"),
      which as a side effect, moved the fields just after 'busylock'
      on a new cacheline.
      
      Since both 'padded' and 'refcnt' are not updated frequently, and
      there is a hole before 'gso_skb', we can move such fields there,
      saving a cacheline without any performance side effect.
      
      Before this commit:
      
      pahole -C Qdisc net/sche/sch_generic.o
      	# ...
              /* size: 384, cachelines: 6, members: 25 */
              /* sum members: 236, holes: 3, sum holes: 92 */
              /* padding: 56 */
      
      After this commit:
      pahole -C Qdisc net/sche/sch_generic.o
      	# ...
      	/* size: 320, cachelines: 5, members: 25 */
      	/* sum members: 236, holes: 2, sum holes: 28 */
      	/* padding: 56 */
      Signed-off-by: NPaolo Abeni <pabeni@redhat.com>
      Acked-by: NJiri Pirko <jiri@mellanox.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      e9be0e99
  4. 18 5月, 2018 1 次提交
  5. 17 5月, 2018 1 次提交
    • P
      sched: manipulate __QDISC_STATE_RUNNING in qdisc_run_* helpers · 32f7b44d
      Paolo Abeni 提交于
      Currently NOLOCK qdiscs pay a measurable overhead to atomically
      manipulate the __QDISC_STATE_RUNNING. Such bit is flipped twice per
      packet in the uncontended scenario with packet rate below the
      line rate: on packed dequeue and on the next, failing dequeue attempt.
      
      This changeset moves the bit manipulation into the qdisc_run_{begin,end}
      helpers, so that the bit is now flipped only once per packet, with
      measurable performance improvement in the uncontended scenario.
      
      This also allows simplifying the qdisc teardown code path - since
      qdisc_is_running() is now effective for each qdisc type - and avoid a
      possible race between qdisc_run() and dev_deactivate_many(), as now
      the some_qdisc_is_busy() can properly detect NOLOCK qdiscs being busy
      dequeuing packets.
      Signed-off-by: NPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      32f7b44d
  6. 27 3月, 2018 1 次提交
    • J
      net: sched, fix OOO packets with pfifo_fast · eb82a994
      John Fastabend 提交于
      After the qdisc lock was dropped in pfifo_fast we allow multiple
      enqueue threads and dequeue threads to run in parallel. On the
      enqueue side the skb bit ooo_okay is used to ensure all related
      skbs are enqueued in-order. On the dequeue side though there is
      no similar logic. What we observe is with fewer queues than CPUs
      it is possible to re-order packets when two instances of
      __qdisc_run() are running in parallel. Each thread will dequeue
      a skb and then whichever thread calls the ndo op first will
      be sent on the wire. This doesn't typically happen because
      qdisc_run() is usually triggered by the same core that did the
      enqueue. However, drivers will trigger __netif_schedule()
      when queues are transitioning from stopped to awake using the
      netif_tx_wake_* APIs. When this happens netif_schedule() calls
      qdisc_run() on the same CPU that did the netif_tx_wake_* which
      is usually done in the interrupt completion context. This CPU
      is selected with the irq affinity which is unrelated to the
      enqueue operations.
      
      To resolve this we add a RUNNING bit to the qdisc to ensure
      only a single dequeue per qdisc is running. Enqueue and dequeue
      operations can still run in parallel and also on multi queue
      NICs we can still have a dequeue in-flight per qdisc, which
      is typically per CPU.
      
      Fixes: c5ad119f ("net: sched: pfifo_fast use skb_array")
      Reported-by: NJakob Unterwurzacher <jakob.unterwurzacher@theobroma-systems.com>
      Signed-off-by: NJohn Fastabend <john.fastabend@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      eb82a994
  7. 08 3月, 2018 1 次提交
    • A
      sch_netem: fix skb leak in netem_enqueue() · 35d889d1
      Alexey Kodanev 提交于
      When we exceed current packets limit and we have more than one
      segment in the list returned by skb_gso_segment(), netem drops
      only the first one, skipping the rest, hence kmemleak reports:
      
      unreferenced object 0xffff880b5d23b600 (size 1024):
        comm "softirq", pid 0, jiffies 4384527763 (age 2770.629s)
        hex dump (first 32 bytes):
          00 80 23 5d 0b 88 ff ff 00 00 00 00 00 00 00 00  ..#]............
          00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
        backtrace:
          [<00000000d8a19b9d>] __alloc_skb+0xc9/0x520
          [<000000001709b32f>] skb_segment+0x8c8/0x3710
          [<00000000c7b9bb88>] tcp_gso_segment+0x331/0x1830
          [<00000000c921cba1>] inet_gso_segment+0x476/0x1370
          [<000000008b762dd4>] skb_mac_gso_segment+0x1f9/0x510
          [<000000002182660a>] __skb_gso_segment+0x1dd/0x620
          [<00000000412651b9>] netem_enqueue+0x1536/0x2590 [sch_netem]
          [<0000000005d3b2a9>] __dev_queue_xmit+0x1167/0x2120
          [<00000000fc5f7327>] ip_finish_output2+0x998/0xf00
          [<00000000d309e9d3>] ip_output+0x1aa/0x2c0
          [<000000007ecbd3a4>] tcp_transmit_skb+0x18db/0x3670
          [<0000000042d2a45f>] tcp_write_xmit+0x4d4/0x58c0
          [<0000000056a44199>] tcp_tasklet_func+0x3d9/0x540
          [<0000000013d06d02>] tasklet_action+0x1ca/0x250
          [<00000000fcde0b8b>] __do_softirq+0x1b4/0x5a3
          [<00000000e7ed027c>] irq_exit+0x1e2/0x210
      
      Fix it by adding the rest of the segments, if any, to skb 'to_free'
      list. Add new __qdisc_drop_all() and qdisc_drop_all() functions
      because they can be useful in the future if we need to drop segmented
      GSO packets in other places.
      
      Fixes: 6071bd1a ("netem: Segment GSO packets on enqueue")
      Signed-off-by: NAlexey Kodanev <alexey.kodanev@oracle.com>
      Acked-by: NNeil Horman <nhorman@tuxdriver.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      35d889d1
  8. 02 3月, 2018 1 次提交
  9. 30 1月, 2018 1 次提交
    • C
      net_sched: plug in qdisc ops change_tx_queue_len · 48bfd55e
      Cong Wang 提交于
      Introduce a new qdisc ops ->change_tx_queue_len() so that
      each qdisc could decide how to implement this if it wants.
      Previously we simply read dev->tx_queue_len, after pfifo_fast
      switches to skb array, we need this API to resize the skb array
      when we change dev->tx_queue_len.
      
      To avoid handling race conditions with TX BH, we need to
      deactivate all TX queues before change the value and bring them
      back after we are done, this also makes implementation easier.
      
      Cc: John Fastabend <john.fastabend@gmail.com>
      Signed-off-by: NCong Wang <xiyou.wangcong@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      48bfd55e
  10. 25 1月, 2018 1 次提交
  11. 20 1月, 2018 3 次提交
  12. 18 1月, 2018 6 次提交
  13. 17 1月, 2018 1 次提交
    • D
      net, sched: fix panic when updating miniq {b,q}stats · 81d947e2
      Daniel Borkmann 提交于
      While working on fixing another bug, I ran into the following panic
      on arm64 by simply attaching clsact qdisc, adding a filter and running
      traffic on ingress to it:
      
        [...]
        [  178.188591] Unable to handle kernel read from unreadable memory at virtual address 810fb501f000
        [  178.197314] Mem abort info:
        [  178.200121]   ESR = 0x96000004
        [  178.203168]   Exception class = DABT (current EL), IL = 32 bits
        [  178.209095]   SET = 0, FnV = 0
        [  178.212157]   EA = 0, S1PTW = 0
        [  178.215288] Data abort info:
        [  178.218175]   ISV = 0, ISS = 0x00000004
        [  178.222019]   CM = 0, WnR = 0
        [  178.224997] user pgtable: 4k pages, 48-bit VAs, pgd = 0000000023cb3f33
        [  178.231531] [0000810fb501f000] *pgd=0000000000000000
        [  178.236508] Internal error: Oops: 96000004 [#1] SMP
        [...]
        [  178.311855] CPU: 73 PID: 2497 Comm: ping Tainted: G        W        4.15.0-rc7+ #5
        [  178.319413] Hardware name: FOXCONN R2-1221R-A4/C2U4N_MB, BIOS G31FB18A 03/31/2017
        [  178.326887] pstate: 60400005 (nZCv daif +PAN -UAO)
        [  178.331685] pc : __netif_receive_skb_core+0x49c/0xac8
        [  178.336728] lr : __netif_receive_skb+0x28/0x78
        [  178.341161] sp : ffff00002344b750
        [  178.344465] x29: ffff00002344b750 x28: ffff810fbdfd0580
        [  178.349769] x27: 0000000000000000 x26: ffff000009378000
        [...]
        [  178.418715] x1 : 0000000000000054 x0 : 0000000000000000
        [  178.424020] Process ping (pid: 2497, stack limit = 0x000000009f0a3ff4)
        [  178.430537] Call trace:
        [  178.432976]  __netif_receive_skb_core+0x49c/0xac8
        [  178.437670]  __netif_receive_skb+0x28/0x78
        [  178.441757]  process_backlog+0x9c/0x160
        [  178.445584]  net_rx_action+0x2f8/0x3f0
        [...]
      
      Reason is that sch_ingress and sch_clsact are doing mini_qdisc_pair_init()
      which sets up miniq pointers to cpu_{b,q}stats from the underlying qdisc.
      Problem is that this cannot work since they are actually set up right after
      the qdisc ->init() callback in qdisc_create(), so first packet going into
      sch_handle_ingress() tries to call mini_qdisc_bstats_cpu_update() and we
      therefore panic.
      
      In order to fix this, allocation of {b,q}stats needs to happen before we
      call into ->init(). In net-next, there's already such option through commit
      d59f5ffa ("net: sched: a dflt qdisc may be used with per cpu stats").
      However, the bug needs to be fixed in net still for 4.15. Thus, include
      these bits to reduce any merge churn and reuse the static_flags field to
      set TCQ_F_CPUSTATS, and remove the allocation from qdisc_create() since
      there is no other user left. Prashant Bhole ran into the same issue but
      for net-next, thus adding him below as well as co-author. Same issue was
      also reported by Sandipan Das when using bcc.
      
      Fixes: 46209401 ("net: core: introduce mini_Qdisc and eliminate usage of tp->q for clsact fastpath")
      Reference: https://lists.iovisor.org/pipermail/iovisor-dev/2018-January/001190.htmlReported-by: NSandipan Das <sandipan@linux.vnet.ibm.com>
      Co-authored-by: NPrashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
      Co-authored-by: NJohn Fastabend <john.fastabend@gmail.com>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      Cc: Jiri Pirko <jiri@resnulli.us>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      81d947e2
  14. 22 12月, 2017 7 次提交
  15. 16 12月, 2017 1 次提交
  16. 09 12月, 2017 6 次提交
  17. 06 12月, 2017 2 次提交
    • A
      net: sched: sch_api: fix code style issues · 0ac4bd68
      Alexander Aring 提交于
      This patch fix checkpatch issues for upcomming patches according to the
      sched api file. It changes checking on null pointer, remove unnecessary
      brackets, add variable names for parameters and adjust 80 char width.
      
      Cc: David Ahern <dsahern@gmail.com>
      Signed-off-by: NAlexander Aring <aring@mojatatu.com>
      Acked-by: NJamal Hadi Salim <jhs@mojatatu.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      0ac4bd68
    • C
      net_sched: get rid of rcu_barrier() in tcf_block_put_ext() · efbf7897
      Cong Wang 提交于
      Both Eric and Paolo noticed the rcu_barrier() we use in
      tcf_block_put_ext() could be a performance bottleneck when
      we have a lot of tc classes.
      
      Paolo provided the following to demonstrate the issue:
      
      tc qdisc add dev lo root htb
      for I in `seq 1 1000`; do
              tc class add dev lo parent 1: classid 1:$I htb rate 100kbit
              tc qdisc add dev lo parent 1:$I handle $((I + 1)): htb
              for J in `seq 1 10`; do
                      tc filter add dev lo parent $((I + 1)): u32 match ip src 1.1.1.$J
              done
      done
      time tc qdisc del dev root
      
      real    0m54.764s
      user    0m0.023s
      sys     0m0.000s
      
      The rcu_barrier() there is to ensure we free the block after all chains
      are gone, that is, to queue tcf_block_put_final() at the tail of workqueue.
      We can achieve this ordering requirement by refcnt'ing tcf block instead,
      that is, the tcf block is freed only when the last chain in this block is
      gone. This also simplifies the code.
      
      Paolo reported after this patch we get:
      
      real    0m0.017s
      user    0m0.000s
      sys     0m0.017s
      Tested-by: NPaolo Abeni <pabeni@redhat.com>
      Cc: Eric Dumazet <edumazet@google.com>
      Cc: Jiri Pirko <jiri@mellanox.com>
      Cc: Jamal Hadi Salim <jhs@mojatatu.com>
      Signed-off-by: NCong Wang <xiyou.wangcong@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      efbf7897
  18. 03 11月, 2017 1 次提交