1. 28 1月, 2021 2 次提交
  2. 21 1月, 2021 4 次提交
    • S
      bpf: Split cgroup_bpf_enabled per attach type · a9ed15da
      Stanislav Fomichev 提交于
      When we attach any cgroup hook, the rest (even if unused/unattached) start
      to contribute small overhead. In particular, the one we want to avoid is
      __cgroup_bpf_run_filter_skb which does two redirections to get to
      the cgroup and pushes/pulls skb.
      
      Let's split cgroup_bpf_enabled to be per-attach to make sure
      only used attach types trigger.
      
      I've dropped some existing high-level cgroup_bpf_enabled in some
      places because BPF_PROG_CGROUP_XXX_RUN macros usually have another
      cgroup_bpf_enabled check.
      
      I also had to copy-paste BPF_CGROUP_RUN_SA_PROG_LOCK for
      GETPEERNAME/GETSOCKNAME because type for cgroup_bpf_enabled[type]
      has to be constant and known at compile time.
      Signed-off-by: NStanislav Fomichev <sdf@google.com>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Acked-by: NSong Liu <songliubraving@fb.com>
      Link: https://lore.kernel.org/bpf/20210115163501.805133-4-sdf@google.com
      a9ed15da
    • S
      bpf: Try to avoid kzalloc in cgroup/{s,g}etsockopt · 20f2505f
      Stanislav Fomichev 提交于
      When we attach a bpf program to cgroup/getsockopt any other getsockopt()
      syscall starts incurring kzalloc/kfree cost.
      
      Let add a small buffer on the stack and use it for small (majority)
      {s,g}etsockopt values. The buffer is small enough to fit into
      the cache line and cover the majority of simple options (most
      of them are 4 byte ints).
      
      It seems natural to do the same for setsockopt, but it's a bit more
      involved when the BPF program modifies the data (where we have to
      kmalloc). The assumption is that for the majority of setsockopt
      calls (which are doing pure BPF options or apply policy) this
      will bring some benefit as well.
      
      Without this patch (we remove about 1% __kmalloc):
           3.38%     0.07%  tcp_mmap  [kernel.kallsyms]  [k] __cgroup_bpf_run_filter_getsockopt
                  |
                   --3.30%--__cgroup_bpf_run_filter_getsockopt
                             |
                              --0.81%--__kmalloc
      Signed-off-by: NStanislav Fomichev <sdf@google.com>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Acked-by: NMartin KaFai Lau <kafai@fb.com>
      Link: https://lore.kernel.org/bpf/20210115163501.805133-3-sdf@google.com
      20f2505f
    • S
      bpf: Remove extra lock_sock for TCP_ZEROCOPY_RECEIVE · 9cacf81f
      Stanislav Fomichev 提交于
      Add custom implementation of getsockopt hook for TCP_ZEROCOPY_RECEIVE.
      We skip generic hooks for TCP_ZEROCOPY_RECEIVE and have a custom
      call in do_tcp_getsockopt using the on-stack data. This removes
      3% overhead for locking/unlocking the socket.
      
      Without this patch:
           3.38%     0.07%  tcp_mmap  [kernel.kallsyms]  [k] __cgroup_bpf_run_filter_getsockopt
                  |
                   --3.30%--__cgroup_bpf_run_filter_getsockopt
                             |
                              --0.81%--__kmalloc
      
      With the patch applied:
           0.52%     0.12%  tcp_mmap  [kernel.kallsyms]  [k] __cgroup_bpf_run_filter_getsockopt_kern
      
      Note, exporting uapi/tcp.h requires removing netinet/tcp.h
      from test_progs.h because those headers have confliciting
      definitions.
      Signed-off-by: NStanislav Fomichev <sdf@google.com>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Acked-by: NMartin KaFai Lau <kafai@fb.com>
      Link: https://lore.kernel.org/bpf/20210115163501.805133-2-sdf@google.com
      9cacf81f
    • G
      net: usb: cdc_ncm: don't spew notifications · de658a19
      Grant Grundler 提交于
      RTL8156 sends notifications about every 32ms.
      Only display/log notifications when something changes.
      
      This issue has been reported by others:
      	https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1832472
      	https://lkml.org/lkml/2020/8/27/1083
      
      ...
      [785962.779840] usb 1-1: new high-speed USB device number 5 using xhci_hcd
      [785962.929944] usb 1-1: New USB device found, idVendor=0bda, idProduct=8156, bcdDevice=30.00
      [785962.929949] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=6
      [785962.929952] usb 1-1: Product: USB 10/100/1G/2.5G LAN
      [785962.929954] usb 1-1: Manufacturer: Realtek
      [785962.929956] usb 1-1: SerialNumber: 000000001
      [785962.991755] usbcore: registered new interface driver cdc_ether
      [785963.017068] cdc_ncm 1-1:2.0: MAC-Address: 00:24:27:88:08:15
      [785963.017072] cdc_ncm 1-1:2.0: setting rx_max = 16384
      [785963.017169] cdc_ncm 1-1:2.0: setting tx_max = 16384
      [785963.017682] cdc_ncm 1-1:2.0 usb0: register 'cdc_ncm' at usb-0000:00:14.0-1, CDC NCM, 00:24:27:88:08:15
      [785963.019211] usbcore: registered new interface driver cdc_ncm
      [785963.023856] usbcore: registered new interface driver cdc_wdm
      [785963.025461] usbcore: registered new interface driver cdc_mbim
      [785963.038824] cdc_ncm 1-1:2.0 enx002427880815: renamed from usb0
      [785963.089586] cdc_ncm 1-1:2.0 enx002427880815: network connection: disconnected
      [785963.121673] cdc_ncm 1-1:2.0 enx002427880815: network connection: disconnected
      [785963.153682] cdc_ncm 1-1:2.0 enx002427880815: network connection: disconnected
      ...
      
      This is about 2KB per second and will overwrite all contents of a 1MB
      dmesg buffer in under 10 minutes rendering them useless for debugging
      many kernel problems.
      
      This is also an extra 180 MB/day in /var/logs (or 1GB per week) rendering
      the majority of those logs useless too.
      
      When the link is up (expected state), spew amount is >2x higher:
      ...
      [786139.600992] cdc_ncm 2-1:2.0 enx002427880815: network connection: connected
      [786139.632997] cdc_ncm 2-1:2.0 enx002427880815: 2500 mbit/s downlink 2500 mbit/s uplink
      [786139.665097] cdc_ncm 2-1:2.0 enx002427880815: network connection: connected
      [786139.697100] cdc_ncm 2-1:2.0 enx002427880815: 2500 mbit/s downlink 2500 mbit/s uplink
      [786139.729094] cdc_ncm 2-1:2.0 enx002427880815: network connection: connected
      [786139.761108] cdc_ncm 2-1:2.0 enx002427880815: 2500 mbit/s downlink 2500 mbit/s uplink
      ...
      
      Chrome OS cannot support RTL8156 until this is fixed.
      Signed-off-by: NGrant Grundler <grundler@chromium.org>
      Reviewed-by: NHayes Wang <hayeswang@realtek.com>
      Link: https://lore.kernel.org/r/20210120011208.3768105-1-grundler@chromium.orgSigned-off-by: NJakub Kicinski <kuba@kernel.org>
      de658a19
  3. 20 1月, 2021 4 次提交
    • J
      bonding: add a vlan+srcmac tx hashing option · 7b8fc010
      Jarod Wilson 提交于
      This comes from an end-user request, where they're running multiple VMs on
      hosts with bonded interfaces connected to some interest switch topologies,
      where 802.3ad isn't an option. They're currently running a proprietary
      solution that effectively achieves load-balancing of VMs and bandwidth
      utilization improvements with a similar form of transmission algorithm.
      
      Basically, each VM has it's own vlan, so it always sends its traffic out
      the same interface, unless that interface fails. Traffic gets split
      between the interfaces, maintaining a consistent path, with failover still
      available if an interface goes down.
      
      Unlike bond_eth_hash(), this hash function is using the full source MAC
      address instead of just the last byte, as there are so few components to
      the hash, and in the no-vlan case, we would be returning just the last
      byte of the source MAC as the hash value. It's entirely possible to have
      two NICs in a bond with the same last byte of their MAC, but not the same
      MAC, so this adjustment should guarantee distinct hashes in all cases.
      
      This has been rudimetarily tested to provide similar results to the
      proprietary solution it is aiming to replace. A patch for iproute2 is also
      posted, to properly support the new mode there as well.
      
      Cc: Jay Vosburgh <j.vosburgh@gmail.com>
      Cc: Veaceslav Falico <vfalico@gmail.com>
      Cc: Andy Gospodarek <andy@greyhouse.net>
      Cc: Thomas Davis <tadavis@lbl.gov>
      Signed-off-by: NJarod Wilson <jarod@redhat.com>
      Link: https://lore.kernel.org/r/20210119010927.1191922-1-jarod@redhat.comSigned-off-by: NJakub Kicinski <kuba@kernel.org>
      7b8fc010
    • X
      net: add inline function skb_csum_is_sctp · fa821170
      Xin Long 提交于
      This patch is to define a inline function skb_csum_is_sctp(), and
      also replace all places where it checks if it's a SCTP CSUM skb.
      This function would be used later in many networking drivers in
      the following patches.
      Suggested-by: NAlexander Duyck <alexander.duyck@gmail.com>
      Signed-off-by: NXin Long <lucien.xin@gmail.com>
      Reviewed-by: NAlexander Duyck <alexanderduyck@fb.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      fa821170
    • G
      mdio-bitbang: Export mdiobb_{read,write}() · 8eed01b5
      Geert Uytterhoeven 提交于
      Export mdiobb_read() and mdiobb_write(), so Ethernet controller drivers
      can call them from their MDIO read/write wrappers.
      Signed-off-by: NGeert Uytterhoeven <geert+renesas@glider.be>
      Tested-by: NWolfram Sang <wsa+renesas@sang-engineering.com>
      Reviewed-by: NFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      8eed01b5
    • A
      mdio, phy: fix -Wshadow warnings triggered by nested container_of() · 7eab14de
      Alexander Lobakin 提交于
      container_of() macro hides a local variable '__mptr' inside. This
      becomes a problem when several container_of() are nested in each
      other within single line or plain macros.
      As C preprocessor doesn't support generating random variable names,
      the sole solution is to avoid defining macros that consist only of
      container_of() calls, or they will self-shadow '__mptr' each time:
      
      In file included from ./include/linux/bitmap.h:10,
                       from drivers/net/phy/phy_device.c:12:
      drivers/net/phy/phy_device.c: In function ‘phy_device_release’:
      ./include/linux/kernel.h:693:8: warning: declaration of ‘__mptr’ shadows a previous local [-Wshadow]
        693 |  void *__mptr = (void *)(ptr);     \
            |        ^~~~~~
      ./include/linux/phy.h:647:26: note: in expansion of macro ‘container_of’
        647 | #define to_phy_device(d) container_of(to_mdio_device(d), \
            |                          ^~~~~~~~~~~~
      ./include/linux/mdio.h:52:27: note: in expansion of macro ‘container_of’
         52 | #define to_mdio_device(d) container_of(d, struct mdio_device, dev)
            |                           ^~~~~~~~~~~~
      ./include/linux/phy.h:647:39: note: in expansion of macro ‘to_mdio_device’
        647 | #define to_phy_device(d) container_of(to_mdio_device(d), \
            |                                       ^~~~~~~~~~~~~~
      drivers/net/phy/phy_device.c:217:8: note: in expansion of macro ‘to_phy_device’
        217 |  kfree(to_phy_device(dev));
            |        ^~~~~~~~~~~~~
      ./include/linux/kernel.h:693:8: note: shadowed declaration is here
        693 |  void *__mptr = (void *)(ptr);     \
            |        ^~~~~~
      ./include/linux/phy.h:647:26: note: in expansion of macro ‘container_of’
        647 | #define to_phy_device(d) container_of(to_mdio_device(d), \
            |                          ^~~~~~~~~~~~
      drivers/net/phy/phy_device.c:217:8: note: in expansion of macro ‘to_phy_device’
        217 |  kfree(to_phy_device(dev));
            |        ^~~~~~~~~~~~~
      
      As they are declared in header files, these warnings are highly
      repetitive and very annoying (along with the one from linux/pci.h).
      
      Convert the related macros from linux/{mdio,phy}.h to static inlines
      to avoid self-shadowing and potentially improve bug-catching.
      No functional changes implied.
      Signed-off-by: NAlexander Lobakin <alobakin@pm.me>
      Reviewed-by: NAndrew Lunn <andrew@lunn.ch>
      Link: https://lore.kernel.org/r/20210116161246.67075-1-alobakin@pm.meSigned-off-by: NJakub Kicinski <kuba@kernel.org>
      7eab14de
  4. 19 1月, 2021 1 次提交
  5. 15 1月, 2021 8 次提交
  6. 14 1月, 2021 7 次提交
  7. 13 1月, 2021 11 次提交
  8. 12 1月, 2021 2 次提交
  9. 10 1月, 2021 1 次提交