1. 17 1月, 2019 14 次提交
    • S
      bpftool: don't print empty key/value for maps · 04a5d323
      Stanislav Fomichev 提交于
      When doing dump or lookup, don't print key if key_size == 0 or value if
      value_size == 0. The initial usecase is queue and stack, where we have
      only values.
      
      This is for regular output only, json still has all the fields.
      
      Before:
      bpftool map create /sys/fs/bpf/q type queue value 4 entries 10 name q
      bpftool map update pinned /sys/fs/bpf/q value 0 1 2 3
      bpftool map lookup pinned /sys/fs/bpf/q
      key:   value: 00 01 02 03
      
      After:
      bpftool map create /sys/fs/bpf/q type queue value 4 entries 10 name q
      bpftool map update pinned /sys/fs/bpf/q value 0 1 2 3
      bpftool map lookup pinned /sys/fs/bpf/q
      value: 00 01 02 03
      Signed-off-by: NStanislav Fomichev <sdf@google.com>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      04a5d323
    • S
      bpftool: make key optional in lookup command · 8a89fff6
      Stanislav Fomichev 提交于
      Bpftool expects key for 'lookup' operations. For some map types, key should
      not be specified. Support looking up those map types.
      
      Before:
      bpftool map create /sys/fs/bpf/q type queue value 4 entries 10 name q
      bpftool map update pinned /sys/fs/bpf/q value 0 1 2 3
      bpftool map lookup pinned /sys/fs/bpf/q
      Error: did not find key
      
      After:
      bpftool map create /sys/fs/bpf/q type queue value 4 entries 10 name q
      bpftool map update pinned /sys/fs/bpf/q value 0 1 2 3
      bpftool map lookup pinned /sys/fs/bpf/q
      key:   value: 00 01 02 03
      Signed-off-by: NStanislav Fomichev <sdf@google.com>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      8a89fff6
    • S
      bpftool: make key and value optional in update command · 7d7209cb
      Stanislav Fomichev 提交于
      Bpftool expects both key and value for 'update' operations. For some
      map types, key should not be specified. Support updating those map types.
      
      Before:
      bpftool map create /sys/fs/bpf/q type queue value 4 entries 10 name q
      bpftool map update pinned /sys/fs/bpf/q value 0 1 2 3
      Error: did not find key
      
      After:
      bpftool map create /sys/fs/bpf/q type queue value 4 entries 10 name q
      bpftool map update pinned /sys/fs/bpf/q value 0 1 2 3
      Signed-off-by: NStanislav Fomichev <sdf@google.com>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      7d7209cb
    • D
      Merge branch 'bpf-int128-btf' · e13279e2
      Daniel Borkmann 提交于
      Yonghong Song says:
      
      ====================
      Previous maximum supported integer bit width is 64. But
      the __int128 type has been supported by most (if not all)
      64bit architectures including bpf for both gcc and clang.
      
      The kernel itself uses __int128 for x64 and arm64. Some bcc
      tools are using __int128 in bpf programs to describe ipv6
      addresses. Without 128bit int support, the vmlinux BTF won't
      work and those bpf programs using __int128 cannot utilize BTF.
      
      This patch set therefore implements BTF __int128 support.
      ====================
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      e13279e2
    • Y
      tools/bpf: support __int128 in bpftool map pretty dumper · e86e5138
      Yonghong Song 提交于
      For formatted output, currently when json is enabled, the decimal
      number is required. Similar to kernel bpffs printout,
      for int128 numbers, only hex numbers are dumped, which are
      quoted as strings.
      
      The below is an example to show plain and json pretty print
      based on the map in test_btf pretty print test.
      
        $ bpftool m s
        75: hash  name pprint_test_has  flags 0x0
              key 4B  value 112B  max_entries 4  memlock 4096B
        $ bpftool m d id 75
        ......
          {
              "key": 3,
              "value": {
                  "ui32": 3,
                  "ui16": 0,
                  "si32": -3,
                  "unused_bits2a": 0x3,
                  "bits28": 0x3,
                  "unused_bits2b": 0x3,
                  "": {
                      "ui64": 3,
                      "ui8a": [3,0,0,0,0,0,0,0
                      ]
                  },
                  "aenum": 3,
                  "ui32b": 4,
                  "bits2c": 0x1,
                  "si128a": 0x3,
                  "si128b": 0xfffffffd,
                  "bits3": 0x3,
                  "bits80": 0x10000000000000003,
                  "ui128": 0x20000000000000003
              }
          },
        ......
      
        $ bptfool -p -j m d id 75
        ......
        {
              "key": ["0x03","0x00","0x00","0x00"
              ],
              "value": ["0x03","0x00","0x00","0x00","0x00","0x00","0x00","0x00",
                        "0xfd","0xff","0xff","0xff","0x0f","0x00","0x00","0xc0",
                        "0x03","0x00","0x00","0x00","0x00","0x00","0x00","0x00",
                        "0x03","0x00","0x00","0x00","0x04","0x00","0x00","0x00",
                        "0x01","0x00","0x00","0x00","0x00","0x00","0x00","0x00",
                        "0x00","0x00","0x00","0x00","0x00","0x00","0x00","0x00",
                        "0x03","0x00","0x00","0x00","0x00","0x00","0x00","0x00",
                        "0x00","0x00","0x00","0x00","0x00","0x00","0x00","0x00",
                        "0xfd","0xff","0xff","0xff","0x00","0x00","0x00","0x00",
                        "0x00","0x00","0x00","0x00","0x00","0x00","0x00","0x00",
                        "0x1b","0x00","0x00","0x00","0x00","0x00","0x00","0x00",
                        "0x08","0x00","0x00","0x00","0x00","0x00","0x00","0x00",
                        "0x03","0x00","0x00","0x00","0x00","0x00","0x00","0x00",
                        "0x02","0x00","0x00","0x00","0x00","0x00","0x00","0x00"
              ],
              "formatted": {
                  "key": 3,
                  "value": {
                      "ui32": 3,
                      "ui16": 0,
                      "si32": -3,
                      "unused_bits2a": "0x3",
                      "bits28": "0x3",
                      "unused_bits2b": "0x3",
                      "": {
                          "ui64": 3,
                          "ui8a": [3,0,0,0,0,0,0,0
                          ]
                      },
                      "aenum": 3,
                      "ui32b": 4,
                      "bits2c": "0x1",
                      "si128a": "0x3",
                      "si128b": "0xfffffffd",
                      "bits3": "0x3",
                      "bits80": "0x10000000000000003",
                      "ui128": "0x20000000000000003"
                  }
              }
          }
        ......
      Acked-by: NMartin KaFai Lau <kafai@fb.com>
      Signed-off-by: NYonghong Song <yhs@fb.com>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      e86e5138
    • Y
      tools/bpf: add bpffs pretty print test for int128 · 4df3a1d0
      Yonghong Song 提交于
      The bpffs pretty print test is extended to cover int128 types.
      Tested on an x64 machine.
        $ test_btf -p
        ......
        BTF pretty print array(#3)......OK
        PASS:9 SKIP:0 FAIL:0
      Acked-by: NMartin KaFai Lau <kafai@fb.com>
      Signed-off-by: NYonghong Song <yhs@fb.com>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      4df3a1d0
    • Y
      tools/bpf: refactor test_btf pretty printing for multiple map value formats · ce6ec47a
      Yonghong Song 提交于
      The test_btf pretty print is refactored in order to easily
      support multiple map value formats. The next patch will
      add __int128 type tests which needs macro guard __SIZEOF_INT128__.
      There is no functionality change with this patch.
      Acked-by: NMartin KaFai Lau <kafai@fb.com>
      Signed-off-by: NYonghong Song <yhs@fb.com>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      ce6ec47a
    • Y
      tools/bpf: add int128 raw test in test_btf · a80eba20
      Yonghong Song 提交于
      Several int128 raw type tests are added to test_btf.
      Currently these tests are enabled only for x64 and arm64
      for which kernel has CONFIG_ARCH_SUPPORTS_INT128 set.
      
        $ test_btf
        ......
        BTF raw test[106] (128-bit int): OK
        BTF raw test[107] (struct, 128-bit int member): OK
        BTF raw test[108] (struct, 120-bit int member bitfield): OK
        BTF raw test[109] (struct, kind_flag, 128-bit int member): OK
        BTF raw test[110] (struct, kind_flag, 120-bit int member bitfield): OK
        ......
      Acked-by: NMartin KaFai Lau <kafai@fb.com>
      Signed-off-by: NYonghong Song <yhs@fb.com>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      a80eba20
    • Y
      bpf: btf: support 128 bit integer type · b1e8818c
      Yonghong Song 提交于
      Currently, btf only supports up to 64-bit integer.
      On the other hand, 128bit support for gcc and clang
      has existed for a long time. For example, both gcc 4.8
      and llvm 3.7 supports types "__int128" and
      "unsigned __int128" for virtually all 64bit architectures
      including bpf.
      
      The requirement for __int128 support comes from two areas:
        . bpf program may use __int128. For example, some bcc tools
          (https://github.com/iovisor/bcc/tree/master/tools),
          mostly tcp v6 related, tcpstates.py, tcpaccept.py, etc.,
          are using __int128 to represent the ipv6 addresses.
        . linux itself is using __int128 types. Hence supporting
          __int128 type in BTF is required for vmlinux BTF,
          which will be used by "compile once and run everywhere"
          and other projects.
      
      For 128bit integer, instead of base-10, hex numbers are pretty
      printed out as large decimal number is hard to decipher, e.g.,
      for ipv6 addresses.
      Acked-by: NMartin KaFai Lau <kafai@fb.com>
      Signed-off-by: NYonghong Song <yhs@fb.com>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      b1e8818c
    • S
      libbpf: don't define CC and AR · eeedd352
      Stanislav Fomichev 提交于
      We are already including tools/scripts/Makefile.include which correctly
      handles CROSS_COMPILE, no need to define our own vars.
      
      See related commit 7ed1c190 ("tools: fix cross-compile var clobbering")
      for more details.
      Signed-off-by: NStanislav Fomichev <sdf@google.com>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      eeedd352
    • R
      networking: Documentation: fix snmp_counters.rst Sphinx warnings · ae5220c6
      Randy Dunlap 提交于
      Fix over 100 documentation warnings in snmp_counter.rst by
      extending the underline string lengths and inserting a blank line
      after bullet items.
      
      Examples:
      
      Documentation/networking/snmp_counter.rst:1: WARNING: Title overline too short.
      Documentation/networking/snmp_counter.rst:14: WARNING: Bullet list ends without a blank line; unexpected unindent.
      
      Fixes: 2b965472 ("add document for TCP OFO, PAWS and skip ACK counters")
      Fixes: 8e2ea53a ("add snmp counters document")
      Fixes: 712ee16c ("add documents for snmp counters")
      Fixes: 80cc4950 ("net: Add part of TCP counts explanations in snmp_counters.rst")
      Fixes: b08794a9 ("documentation of some IP/ICMP snmp counters")
      Signed-off-by: NRandy Dunlap <rdunlap@infradead.org>
      Cc: yupeng <yupeng0921@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      ae5220c6
    • G
      net, decnet: use struct_size() in kzalloc() · bb3e16ad
      Gustavo A. R. Silva 提交于
      One of the more common cases of allocation size calculations is finding the
      size of a structure that has a zero-sized array at the end, along with memory
      for some number of elements for that array. For example:
      
      struct foo {
          int stuff;
          struct boo entry[];
      };
      
      instance = kzalloc(sizeof(struct foo) + count * sizeof(struct boo), GFP_KERNEL);
      
      Instead of leaving these open-coded and prone to type mistakes, we can now
      use the new struct_size() helper:
      
      instance = kzalloc(struct_size(instance, entry, count), GFP_KERNEL);
      
      This code was detected with the help of Coccinelle.
      Signed-off-by: NGustavo A. R. Silva <gustavo@embeddedor.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      bb3e16ad
    • G
      mlxsw: spectrum_nve: Use struct_size() in kzalloc() · faa311e9
      Gustavo A. R. Silva 提交于
      One of the more common cases of allocation size calculations is finding
      the size of a structure that has a zero-sized array at the end, along
      with memory for some number of elements for that array. For example:
      
      struct foo {
          int stuff;
          struct boo entry[];
      };
      
      instance = kzalloc(sizeof(struct foo) + count * sizeof(struct boo), GFP_KERNEL);
      
      Instead of leaving these open-coded and prone to type mistakes, we can
      now use the new struct_size() helper:
      
      instance = kzalloc(struct_size(instance, entry, count), GFP_KERNEL);
      
      This issue was detected with the help of Coccinelle.
      Signed-off-by: NGustavo A. R. Silva <gustavo@embeddedor.com>
      Reviewed-by: NIdo Schimmel <idosch@mellanox.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      faa311e9
    • G
      mlxsw: spectrum_acl_bloom_filter: use struct_size() in kzalloc() · 2285ec87
      Gustavo A. R. Silva 提交于
      One of the more common cases of allocation size calculations is finding
      the size of a structure that has a zero-sized array at the end, along
      with memory for some number of elements for that array. For example:
      
      struct foo {
          int stuff;
          void *entry[];
      };
      
      instance = kzalloc(sizeof(struct foo) + sizeof(void *) * count, GFP_KERNEL);
      
      Instead of leaving these open-coded and prone to type mistakes, we can
      now use the new struct_size() helper:
      
      instance = kzalloc(struct_size(instance, entry, count), GFP_KERNEL);
      
      This issue was detected with the help of Coccinelle.
      Reviewed-by: NIdo Schimmel <idosch@mellanox.com>
      Signed-off-by: NGustavo A. R. Silva <gustavo@embeddedor.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      2285ec87
  2. 16 1月, 2019 21 次提交
  3. 15 1月, 2019 5 次提交
    • M
      sbitmap: Protect swap_lock from hardirq · fe76fc6a
      Ming Lei 提交于
      Because we may call blk_mq_get_driver_tag() directly from
      blk_mq_dispatch_rq_list() without holding any lock, then HARDIRQ may
      come and the above DEADLOCK is triggered.
      
      Commit ab53dcfb3e7b ("sbitmap: Protect swap_lock from hardirq") tries to
      fix this issue by using 'spin_lock_bh', which isn't enough because we
      complete request from hardirq context direclty in case of multiqueue.
      
      Cc: Clark Williams <williams@redhat.com>
      Fixes: ab53dcfb3e7b ("sbitmap: Protect swap_lock from hardirq")
      Cc: Jens Axboe <axboe@kernel.dk>
      Cc: Ming Lei <ming.lei@redhat.com>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Signed-off-by: NMing Lei <ming.lei@redhat.com>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      fe76fc6a
    • S
      sbitmap: Protect swap_lock from softirqs · 37198768
      Steven Rostedt (VMware) 提交于
      The swap_lock used by sbitmap has a chain with locks taken from softirq,
      but the swap_lock is not protected from being preempted by softirqs.
      
      A chain exists of:
      
       sbq->ws[i].wait -> dispatch_wait_lock -> swap_lock
      
      Where the sbq->ws[i].wait lock can be taken from softirq context, which
      means all locks below it in the chain must also be protected from
      softirqs.
      Reported-by: NClark Williams <williams@redhat.com>
      Fixes: 58ab5e32 ("sbitmap: silence bogus lockdep IRQ warning")
      Fixes: ea86ea2c ("sbitmap: amortize cost of clearing bits")
      Cc: Jens Axboe <axboe@kernel.dk>
      Cc: Ming Lei <ming.lei@redhat.com>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Signed-off-by: NSteven Rostedt (VMware) <rostedt@goodmis.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      37198768
    • L
      Merge tag 'gpio-v5.0-2' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio · c962cb32
      Linus Torvalds 提交于
      Pull GPIO fixes from Linus Walleij:
       "The patch hitting the MMC/SD subsystem is fixing up my own mess when
        moving semantics from MMC/SD over to gpiolib. Ulf is on vacation but I
        managed to reach him on chat and obtain his ACK.
      
        The other two are early-rc fixes that are not super serious but pretty
        annoying so I'd like to get rid of them.
      
        Summary:
      
         - Get rid of some WARN_ON() from the ACPI code
      
         - Staticize a symbol
      
         - Fix MMC polarity detection"
      
      * tag 'gpio-v5.0-2' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio:
        mmc: core: don't override the CD GPIO level when "cd-inverted" is set
        gpio: pca953x: Make symbol 'pca953x_i2c_regmap' static
        gpiolib-acpi: Remove unnecessary WARN_ON from acpi_gpiochip_free_interrupts
      c962cb32
    • L
      Merge tag 'mfd-next-4.21' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd · 9deb9e16
      Linus Torvalds 提交于
      Pull MFD updates from Lee Jones:
       "New Device Support
         - Add support for Power Supply to AXP813
         - Add support for GPIO, ADC, AC and Battery Power Supply to AXP803
         - Add support for UART to Exynos LPASS
      
        Fix-ups:
         - Use supplied MACROS; ti_am335x_tscadc
         - Trivial spelling/whitespace/alignment; tmio, axp20x, rave-sp
         - Regmap changes; bd9571mwv, wm5110-tables
         - Kconfig dependencies; MFD_AT91_USART
         - Supply shared data for child-devices; madera-core
         - Use new of_node_name_eq() API call; max77620, stmpe
         - Use managed resources (devm_*); tps65218
         - Comment descriptions; ingenic-tcu
         - Coding style; madera-core
      
        Bug Fixes:
         - Fix section mismatches; twl-core, db8500-prcmu
         - Correct error path related issues; mt6397-core, ab8500-core, mc13xxx-core
         - IRQ related fixes; tps6586x
         - Ensure proper initialisation sequence; qcom_rpm
         - Repair potential memory leak; cros_ec_dev"
      
      * tag 'mfd-next-4.21' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd: (25 commits)
        mfd: exynos-lpass: Enable UART module support
        mfd: mc13xxx: Fix a missing check of a register-read failure
        mfd: cros_ec: Add commands to control codec
        mfd: madera: Remove spurious semicolon in while loop
        mfd: rave-sp: Fix typo in rave_sp_checksum comment
        mfd: ingenic-tcu: Fix bit field description in header
        mfd: tps65218: Use devm_regmap_add_irq_chip and clean up error path in probe()
        mfd: Use of_node_name_eq() for node name comparisons
        mfd: cros_ec_dev: Add missing mfd_remove_devices() call in remove
        mfd: axp20x: Add supported cells for AXP803
        mfd: axp20x: Re-align MFD cell entries
        mfd: axp20x: Add AC power supply cell for AXP813
        mfd: wm5110: Add missing ASRC rate register
        mfd: qcom_rpm: write fw_version to CTRL_REG
        mfd: tps6586x: Handle interrupts on suspend
        mfd: madera: Add shared data for accessory detection
        mfd: at91-usart: Add platform dependency
        mfd: bd9571mwv: Add volatile register to make DVFS work
        mfd: ab8500-core: Return zero in get_register_interruptible()
        mfd: tmio: Typo s/use use/use/
        ...
      9deb9e16
    • L
      Merge tag 'backlight-next-4.21' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight · 3a73e73a
      Linus Torvalds 提交于
      Pull backlight updates from Lee Jones:
       "Fix-ups:
         - Use new of_node_name_eq() API call
      
        Bug Fixes:
         - Internally track 'enabled' state in pwm_bl
         - Fix auto-generated pwm_bl brightness tables parsed by DT
      
      * tag 'backlight-next-4.21' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight:
        backlight: 88pm860x_bl: Use of_node_name_eq for node name comparisons
        backlight: pwm_bl: Fix devicetree parsing with auto-generated brightness tables
        backlight: pwm_bl: Re-add driver internal enabled tracking
      3a73e73a