1. 20 3月, 2023 1 次提交
  2. 12 3月, 2023 1 次提交
    • L
      cpumask: relax sanity checking constraints · e7304080
      Linus Torvalds 提交于
      The cpumask_check() was unnecessarily tight, and causes problems for the
      users of cpumask_next().
      
      We have a number of users that take the previous return value of one of
      the bit scanning functions and subtract one to keep it in "range".  But
      since the scanning functions end up returning up to 'small_cpumask_bits'
      instead of the tighter 'nr_cpumask_bits', the range really needs to be
      using that widened form.
      
      [ This "previous-1" behavior is also the reason we have all those
        comments about /* -1 is a legal arg here. */ and separate checks for
        that being ok.  So we could have just made "small_cpumask_bits-1"
        be a similar special "don't check this" value.
      
        Tetsuo Handa even suggested a patch that only does that for
        cpumask_next(), since that seems to be the only actual case that
        triggers, but that all makes it even _more_ magical and special. So
        just relax the check ]
      
      One example of this kind of pattern being the 'c_start()' function in
      arch/x86/kernel/cpu/proc.c, but also duplicated in various forms on
      other architectures.
      
      Reported-by: syzbot+96cae094d90877641f32@syzkaller.appspotmail.com
      Link: https://syzkaller.appspot.com/bug?extid=96cae094d90877641f32Reported-by: NTetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
      Link: https://lore.kernel.org/lkml/c1f4cc16-feea-b83c-82cf-1a1f007b7eb9@I-love.SAKURA.ne.jp/
      Fixes: 596ff4a0 ("cpumask: re-introduce constant-sized cpumask optimizations")
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      e7304080
  3. 08 3月, 2023 1 次提交
    • L
      cpumask: be more careful with 'cpumask_setall()' · 63355b98
      Linus Torvalds 提交于
      Commit 596ff4a0 ("cpumask: re-introduce constant-sized cpumask
      optimizations") changed cpumask_setall() to use "bitmap_set()" instead
      of "bitmap_fill()", because bitmap_fill() would explicitly set all the
      bits of a constant sized small bitmap, and that's exactly what we don't
      want: we want to only set bits up to 'nr_cpu_ids', which is what
      "bitmap_set()" does.
      
      However, Yury correctly points out that while "bitmap_set()" does indeed
      only set bits up to the required bitmap size, it doesn't _clear_ bits
      above that size, so the upper bits would still not have well-defined
      values.
      
      Now, none of this should really matter, since any bits set past
      'nr_cpu_ids' should always be ignored in the first place.  Yes, the bit
      scanning functions might return them as a result, but since users should
      always consider the ">= nr_cpu_ids" condition to mean "no more bits",
      that shouldn't have any actual effect (see previous commit 8ca09d5f
      "cpumask: fix incorrect cpumask scanning result checks").
      
      But let's just do it right, the way the code was _intended_ to work.  We
      have had enough lazy code that works but bites us in the *rse later
      (again, see previous commit) that there's no reason to not just do this
      properly.
      
      It turns out that "bitmap_fill()" gets this all right for the complex
      case, and really only fails for the inlined optimized case that just
      fills the whole word.  And while we could just fix bitmap_fill() to use
      the proper last word mask, there's two issues with that:
      
       - the cpumask case wants to do the _optimization_ based on "NR_CPUS is
         a small constant", but then wants to do the actual bit _fill_ based
         on "nr_cpu_ids" that isn't necessarily that same constant
      
       - we have lots of non-cpumask users of bitmap_fill(), and while they
         hopefully don't care, and probably would want the proper semantics
         anyway ("only set bits up to the limit"), I do not want the cpumask
         changes to impact other parts
      
      So this ends up just doing the single-word optimization by hand in the
      cpumask code.  If our cpumask is fundamentally limited to a single word,
      just do the proper "fill in that word" exactly.  And if it's the more
      complex multi-word case, then the generic bitmap_fill() will DTRT.
      
      This is all an example of how our bitmap function optimizations really
      are somewhat broken.  They conflate the "this is size of the bitmap"
      optimizations with the actual bit(s) we want to set.
      
      In many cases we really want to have the two be separate things:
      sometimes we base our optimizations on the size of the whole bitmap ("I
      know this whole bitmap fits in a single word, so I'll just use
      single-word accesses"), and sometimes we base them on the bit we are
      looking at ("this is just acting on bits that are in the first word, so
      I'll use single-word accesses").
      
      Notice how the end result of the two optimizations are the same, but the
      way we get to them are quite different.
      
      And all our cpumask optimization games are really about that fundamental
      distinction, and we'd often really want to pass in both the "this is the
      bit I'm working on" (which _can_ be a small constant but might be
      variable), and "I know it's in this range even if it's variable" (based
      on CONFIG_NR_CPUS).
      
      So this cpumask_setall() implementation just makes that explicit.  It
      checks the "I statically know the size is small" using the known static
      size of the cpumask (which is what that 'small_cpumask_bits' is all
      about), but then sets the actual bits using the exact number of cpus we
      have (ie 'nr_cpumask_bits')
      
      Of course, in a perfect world, the compiler would have done all the
      range analysis (possibly with help from us just telling it that
      "this value is always in this range"), and would do all of this for us.
      But that is not the world we live in.
      
      While we dream of that perfect world, this does that manual logic to
      make it all work out.  And this was a very long explanation for a small
      code change that shouldn't even matter.
      Reported-by: NYury Norov <yury.norov@gmail.com>
      Link: https://lore.kernel.org/lkml/ZAV9nGG9e1%2FrV+L%2F@yury-laptop/Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      63355b98
  4. 07 3月, 2023 1 次提交
  5. 06 3月, 2023 1 次提交
    • L
      cpumask: re-introduce constant-sized cpumask optimizations · 596ff4a0
      Linus Torvalds 提交于
      Commit aa47a7c2 ("lib/cpumask: deprecate nr_cpumask_bits") resulted
      in the cpumask operations potentially becoming hugely less efficient,
      because suddenly the cpumask was always considered to be variable-sized.
      
      The optimization was then later added back in a limited form by commit
      6f9c07be ("lib/cpumask: add FORCE_NR_CPUS config option"), but that
      FORCE_NR_CPUS option is not useful in a generic kernel and more of a
      special case for embedded situations with fixed hardware.
      
      Instead, just re-introduce the optimization, with some changes.
      
      Instead of depending on CPUMASK_OFFSTACK being false, and then always
      using the full constant cpumask width, this introduces three different
      cpumask "sizes":
      
       - the exact size (nr_cpumask_bits) remains identical to nr_cpu_ids.
      
         This is used for situations where we should use the exact size.
      
       - the "small" size (small_cpumask_bits) is the NR_CPUS constant if it
         fits in a single word and the bitmap operations thus end up able
         to trigger the "small_const_nbits()" optimizations.
      
         This is used for the operations that have optimized single-word
         cases that get inlined, notably the bit find and scanning functions.
      
       - the "large" size (large_cpumask_bits) is the NR_CPUS constant if it
         is an sufficiently small constant that makes simple "copy" and
         "clear" operations more efficient.
      
         This is arbitrarily set at four words or less.
      
      As a an example of this situation, without this fixed size optimization,
      cpumask_clear() will generate code like
      
              movl    nr_cpu_ids(%rip), %edx
              addq    $63, %rdx
              shrq    $3, %rdx
              andl    $-8, %edx
              callq   memset@PLT
      
      on x86-64, because it would calculate the "exact" number of longwords
      that need to be cleared.
      
      In contrast, with this patch, using a MAX_CPU of 64 (which is quite a
      reasonable value to use), the above becomes a single
      
      	movq $0,cpumask
      
      instruction instead, because instead of caring to figure out exactly how
      many CPU's the system has, it just knows that the cpumask will be a
      single word and can just clear it all.
      
      Note that this does end up tightening the rules a bit from the original
      version in another way: operations that set bits in the cpumask are now
      limited to the actual nr_cpu_ids limit, whereas we used to do the
      nr_cpumask_bits thing almost everywhere in the cpumask code.
      
      But if you just clear bits, or scan for bits, we can use the simpler
      compile-time constants.
      
      In the process, remove 'cpumask_complement()' and 'for_each_cpu_not()'
      which were not useful, and which fundamentally have to be limited to
      'nr_cpu_ids'.  Better remove them now than have somebody introduce use
      of them later.
      
      Of course, on x86-64 with MAXSMP there is no sane small compile-time
      constant for the cpumask sizes, and we end up using the actual CPU bits,
      and will generate the above kind of horrors regardless.  Please don't
      use MAXSMP unless you really expect to have machines with thousands of
      cores.
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      596ff4a0
  6. 08 2月, 2023 1 次提交
  7. 13 1月, 2023 1 次提交
  8. 17 10月, 2022 1 次提交
  9. 06 10月, 2022 1 次提交
    • V
      cpumask: Introduce for_each_cpu_andnot() · 5f75ff29
      Valentin Schneider 提交于
      for_each_cpu_and() is very convenient as it saves having to allocate a
      temporary cpumask to store the result of cpumask_and(). The same issue
      applies to cpumask_andnot() which doesn't actually need temporary storage
      for iteration purposes.
      
      Following what has been done for for_each_cpu_and(), introduce
      for_each_cpu_andnot().
      Signed-off-by: NValentin Schneider <vschneid@redhat.com>
      5f75ff29
  10. 02 10月, 2022 3 次提交
  11. 27 9月, 2022 2 次提交
    • Y
      cpumask: add cpumask_nth_{,and,andnot} · 944c417d
      Yury Norov 提交于
      Add cpumask_nth_{,and,andnot} as wrappers around corresponding
      find functions, and use it in cpumask_local_spread().
      Signed-off-by: NYury Norov <yury.norov@gmail.com>
      944c417d
    • Y
      lib/bitmap: add bitmap_weight_and() · 24291caf
      Yury Norov 提交于
      The function calculates Hamming weight of (bitmap1 & bitmap2). Now we
      have to do like this:
      	tmp = bitmap_alloc(nbits);
      	bitmap_and(tmp, map1, map2, nbits);
      	weight = bitmap_weight(tmp, nbits);
      	bitmap_free(tmp);
      
      This requires additional memory, adds pressure on alloc subsystem, and
      way less cache-friendly than just:
      	weight = bitmap_weight_and(map1, map2, nbits);
      
      The following patches apply it for cpumask functions.
      Signed-off-by: NYury Norov <yury.norov@gmail.com>
      24291caf
  12. 22 9月, 2022 1 次提交
    • P
      drivers/base: Fix unsigned comparison to -1 in CPUMAP_FILE_MAX_BYTES · d7f06bdd
      Phil Auld 提交于
      As PAGE_SIZE is unsigned long, -1 > PAGE_SIZE when NR_CPUS <= 3.
      This leads to very large file sizes:
      
      topology$ ls -l
      total 0
      -r--r--r-- 1 root root 18446744073709551615 Sep  5 11:59 core_cpus
      -r--r--r-- 1 root root                 4096 Sep  5 11:59 core_cpus_list
      -r--r--r-- 1 root root                 4096 Sep  5 10:58 core_id
      -r--r--r-- 1 root root 18446744073709551615 Sep  5 10:10 core_siblings
      -r--r--r-- 1 root root                 4096 Sep  5 11:59 core_siblings_list
      -r--r--r-- 1 root root 18446744073709551615 Sep  5 11:59 die_cpus
      -r--r--r-- 1 root root                 4096 Sep  5 11:59 die_cpus_list
      -r--r--r-- 1 root root                 4096 Sep  5 11:59 die_id
      -r--r--r-- 1 root root 18446744073709551615 Sep  5 11:59 package_cpus
      -r--r--r-- 1 root root                 4096 Sep  5 11:59 package_cpus_list
      -r--r--r-- 1 root root                 4096 Sep  5 10:58 physical_package_id
      -r--r--r-- 1 root root 18446744073709551615 Sep  5 10:10 thread_siblings
      -r--r--r-- 1 root root                 4096 Sep  5 11:59 thread_siblings_list
      
      Adjust the inequality to catch the case when NR_CPUS is configured
      to a small value.
      
      Fixes: 7ee951ac ("drivers/base: fix userspace break from using bin_attributes for cpumap and cpulist")
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Yury Norov <yury.norov@gmail.com>
      Cc: stable@vger.kernel.org
      Cc: feng xiangjun <fengxj325@gmail.com>
      Reported-by: Nfeng xiangjun <fengxj325@gmail.com>
      Signed-off-by: NPhil Auld <pauld@redhat.com>
      Signed-off-by: NYury Norov <yury.norov@gmail.com>
      Link: https://lore.kernel.org/r/20220906203542.1796629-1-pauld@redhat.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d7f06bdd
  13. 21 9月, 2022 1 次提交
    • Y
      lib/cpumask: add FORCE_NR_CPUS config option · 6f9c07be
      Yury Norov 提交于
      The size of cpumasks is hard-limited by compile-time parameter NR_CPUS,
      but defined at boot-time when kernel parses ACPI/DT tables, and stored in
      nr_cpu_ids. In many practical cases, number of CPUs for a target is known
      at compile time, and can be provided with NR_CPUS.
      
      In that case, compiler may be instructed to rely on NR_CPUS as on actual
      number of CPUs, not an upper limit. It allows to optimize many cpumask
      routines and significantly shrink size of the kernel image.
      
      This patch adds FORCE_NR_CPUS option to teach the compiler to rely on
      NR_CPUS and enable corresponding optimizations.
      
      If FORCE_NR_CPUS=y, kernel will not set nr_cpu_ids at boot, but only check
      that the actual number of possible CPUs is equal to NR_CPUS, and WARN if
      that doesn't hold.
      
      The new option is especially useful in embedded applications because
      kernel configurations are unique for each SoC, the number of CPUs is
      constant and known well, and memory limitations are typically harder.
      
      For my 4-CPU ARM64 build with NR_CPUS=4, FORCE_NR_CPUS=y saves 46KB:
        add/remove: 3/4 grow/shrink: 46/729 up/down: 652/-46952 (-46300)
      Signed-off-by: NYury Norov <yury.norov@gmail.com>
      6f9c07be
  14. 20 9月, 2022 3 次提交
    • Y
      lib/cpumask: deprecate nr_cpumask_bits · aa47a7c2
      Yury Norov 提交于
      Cpumask code is written in assumption that when CONFIG_CPUMASK_OFFSTACK
      is enabled, all cpumasks have boot-time defined size, otherwise the size
      is always NR_CPUS.
      
      The latter is wrong because the number of possible cpus is always
      calculated on boot, and it may be less than NR_CPUS.
      
      On my 4-cpu arm64 VM the nr_cpu_ids is 4, as expected, and nr_cpumask_bits
      is 256, which corresponds to NR_CPUS. This not only leads to useless
      traversing of cpumask bits greater than 4, this also makes some cpumask
      routines fail.
      
      For example, cpumask_full(0b1111000..000) would erroneously return false
      in the example above because tail bits in the mask are all unset.
      
      This patch deprecates nr_cpumask_bits and wires it to nr_cpu_ids
      unconditionally, so that cpumask routines will not waste time traversing
      unused part of cpu masks. It also fixes cpumask_full() and similar
      routines.
      
      As a side effect, because now a length of cpumasks is defined at run-time
      even if CPUMASK_OFFSTACK is disabled, compiler can't optimize corresponding
      functions.
      
      It increases kernel size by ~2.5KB if OFFSTACK is off. This is addressed in
      the following patch.
      Signed-off-by: NYury Norov <yury.norov@gmail.com>
      aa47a7c2
    • Y
      lib/cpumask: delete misleading comment · 7102b3bb
      Yury Norov 提交于
      The comment says that HOTPLUG config option enables all cpus in
      cpu_possible_mask up to NR_CPUs. This is wrong. Even if HOTPLUG is
      enabled, the mask is populated on boot with respect to ACPI/DT records.
      Signed-off-by: NYury Norov <yury.norov@gmail.com>
      7102b3bb
    • Y
      smp: add set_nr_cpu_ids() · 38bef8e5
      Yury Norov 提交于
      In preparation to support compile-time nr_cpu_ids, add a setter for
      the variable.
      
      This is a no-op for all arches.
      Signed-off-by: NYury Norov <yury.norov@gmail.com>
      38bef8e5
  15. 09 9月, 2022 1 次提交
    • P
      drivers/base: Fix unsigned comparison to -1 in CPUMAP_FILE_MAX_BYTES · b9be19ee
      Phil Auld 提交于
      As PAGE_SIZE is unsigned long, -1 > PAGE_SIZE when NR_CPUS <= 3.
      This leads to very large file sizes:
      
      topology$ ls -l
      total 0
      -r--r--r-- 1 root root 18446744073709551615 Sep  5 11:59 core_cpus
      -r--r--r-- 1 root root                 4096 Sep  5 11:59 core_cpus_list
      -r--r--r-- 1 root root                 4096 Sep  5 10:58 core_id
      -r--r--r-- 1 root root 18446744073709551615 Sep  5 10:10 core_siblings
      -r--r--r-- 1 root root                 4096 Sep  5 11:59 core_siblings_list
      -r--r--r-- 1 root root 18446744073709551615 Sep  5 11:59 die_cpus
      -r--r--r-- 1 root root                 4096 Sep  5 11:59 die_cpus_list
      -r--r--r-- 1 root root                 4096 Sep  5 11:59 die_id
      -r--r--r-- 1 root root 18446744073709551615 Sep  5 11:59 package_cpus
      -r--r--r-- 1 root root                 4096 Sep  5 11:59 package_cpus_list
      -r--r--r-- 1 root root                 4096 Sep  5 10:58 physical_package_id
      -r--r--r-- 1 root root 18446744073709551615 Sep  5 10:10 thread_siblings
      -r--r--r-- 1 root root                 4096 Sep  5 11:59 thread_siblings_list
      
      Adjust the inequality to catch the case when NR_CPUS is configured
      to a small value.
      
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Yury Norov <yury.norov@gmail.com>
      Cc: stable@vger.kernel.org
      Cc: feng xiangjun <fengxj325@gmail.com>
      Fixes: 7ee951ac ("drivers/base: fix userspace break from using bin_attributes for cpumap and cpulist")
      Reported-by: Nfeng xiangjun <fengxj325@gmail.com>
      Signed-off-by: NPhil Auld <pauld@redhat.com>
      Signed-off-by: NYury Norov <yury.norov@gmail.com>
      b9be19ee
  16. 16 8月, 2022 2 次提交
  17. 18 7月, 2022 3 次提交
  18. 15 7月, 2022 5 次提交
    • P
      drivers/base: fix userspace break from using bin_attributes for cpumap and cpulist · 7ee951ac
      Phil Auld 提交于
      Using bin_attributes with a 0 size causes fstat and friends to return that
      0 size. This breaks userspace code that retrieves the size before reading
      the file. Rather than reverting 75bd50fa ("drivers/base/node.c: use
      bin_attribute to break the size limitation of cpumap ABI") let's put in a
      size value at compile time.
      
      For cpulist the maximum size is on the order of
      	NR_CPUS * (ceil(log10(NR_CPUS)) + 1)/2
      
      which for 8192 is 20480 (8192 * 5)/2. In order to get near that you'd need
      a system with every other CPU on one node. For example: (0,2,4,8, ... ).
      To simplify the math and support larger NR_CPUS in the future we are using
      (NR_CPUS * 7)/2. We also set it to a min of PAGE_SIZE to retain the older
      behavior for smaller NR_CPUS.
      
      The cpumap file the size works out to be NR_CPUS/4 + NR_CPUS/32 - 1
      (or NR_CPUS * 9/32 - 1) including the ","s.
      
      Add a set of macros for these values to cpumask.h so they can be used in
      multiple places. Apply these to the handful of such files in
      drivers/base/topology.c as well as node.c.
      
      As an example, on an 80 cpu 4-node system (NR_CPUS == 8192):
      
      before:
      
      -r--r--r--. 1 root root 0 Jul 12 14:08 system/node/node0/cpulist
      -r--r--r--. 1 root root 0 Jul 11 17:25 system/node/node0/cpumap
      
      after:
      
      -r--r--r--. 1 root root 28672 Jul 13 11:32 system/node/node0/cpulist
      -r--r--r--. 1 root root  4096 Jul 13 11:31 system/node/node0/cpumap
      
      CONFIG_NR_CPUS = 16384
      -r--r--r--. 1 root root 57344 Jul 13 14:03 system/node/node0/cpulist
      -r--r--r--. 1 root root  4607 Jul 13 14:02 system/node/node0/cpumap
      
      The actual number of cpus doesn't matter for the reported size since they
      are based on NR_CPUS.
      
      Fixes: 75bd50fa ("drivers/base/node.c: use bin_attribute to break the size limitation of cpumap ABI")
      Fixes: bb9ec13d ("topology: use bin_attribute to break the size limitation of cpumap ABI")
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Cc: Yury Norov <yury.norov@gmail.com>
      Cc: stable@vger.kernel.org
      Acked-by: Yury Norov <yury.norov@gmail.com> (for include/linux/cpumask.h)
      Signed-off-by: NPhil Auld <pauld@redhat.com>
      Link: https://lore.kernel.org/r/20220715134924.3466194-1-pauld@redhat.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7ee951ac
    • Y
      lib/cpumask: move some one-line wrappers to header file · f0dd891d
      Yury Norov 提交于
      After moving gfp flags to a separate header, it's possible to move some
      cpumask allocators into headers, and avoid creating real functions.
      Signed-off-by: NYury Norov <yury.norov@gmail.com>
      f0dd891d
    • Y
      lib/cpumask: move trivial wrappers around find_bit to the header · 9b2e7086
      Yury Norov 提交于
      To avoid circular dependencies, cpumask keeps simple (almost) one-line
      wrappers around find_bit() in a c-file.
      
      Commit 47d8c156 ("include: move find.h from asm_generic to linux")
      moved find.h header out of asm_generic include path, and it helped to fix
      many circular dependencies, including some in cpumask.h.
      
      This patch moves those one-liners to header files.
      Signed-off-by: NYury Norov <yury.norov@gmail.com>
      9b2e7086
    • Y
      lib/cpumask: change return types to unsigned where appropriate · 8b6b795d
      Yury Norov 提交于
      Switch return types to unsigned int where return values cannot be negative.
      Signed-off-by: NYury Norov <yury.norov@gmail.com>
      8b6b795d
    • Y
      cpumask: change return types to bool where appropriate · cb32c285
      Yury Norov 提交于
      Some cpumask functions have integer return types where return values
      are naturally booleans.
      Signed-off-by: NYury Norov <yury.norov@gmail.com>
      cb32c285
  19. 13 2月, 2022 1 次提交
  20. 26 1月, 2022 1 次提交
  21. 16 1月, 2022 2 次提交
  22. 21 9月, 2021 1 次提交
  23. 13 8月, 2021 1 次提交
    • T
      cpumask: introduce cpumap_print_list/bitmask_to_buf to support large bitmask and list · 1fae5629
      Tian Tao 提交于
      The existing cpumap_print_to_pagebuf() is used by cpu topology and other
      drivers to export hexadecimal bitmask and decimal list to userspace by
      sysfs ABI.
      
      Right now, those drivers are using a normal attribute for this kind of
      ABIs. A normal attribute typically has show entry as below:
      
      static ssize_t example_dev_show(struct device *dev,
                      struct device_attribute *attr, char *buf)
      {
      	...
      	return cpumap_print_to_pagebuf(true, buf, &pmu_mmdc->cpu);
      }
      show entry of attribute has no offset and count parameters and this
      means the file is limited to one page only.
      
      cpumap_print_to_pagebuf() API works terribly well for this kind of
      normal attribute with buf parameter and without offset, count:
      
      static inline ssize_t
      cpumap_print_to_pagebuf(bool list, char *buf, const struct cpumask *mask)
      {
      	return bitmap_print_to_pagebuf(list, buf, cpumask_bits(mask),
      				       nr_cpu_ids);
      }
      
      The problem is once we have many cpus, we have a chance to make bitmask
      or list more than one page. Especially for list, it could be as complex
      as 0,3,5,7,9,...... We have no simple way to know it exact size.
      
      It turns out bin_attribute is a way to break this limit. bin_attribute
      has show entry as below:
      static ssize_t
      example_bin_attribute_show(struct file *filp, struct kobject *kobj,
                   struct bin_attribute *attr, char *buf,
                   loff_t offset, size_t count)
      {
      	...
      }
      
      With the new offset and count parameters, this makes sysfs ABI be able
      to support file size more than one page. For example, offset could be
      >= 4096.
      
      This patch introduces cpumap_print_bitmask/list_to_buf() and their bitmap
      infrastructure bitmap_print_bitmask/list_to_buf() so that those drivers
      can move to bin_attribute to support large bitmask and list. At the same
      time, we have to pass those corresponding parameters such as offset, count
      from bin_attribute to this new API.
      
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Randy Dunlap <rdunlap@infradead.org>
      Cc: Stefano Brivio <sbrivio@redhat.com>
      Cc: Alexander Gordeev <agordeev@linux.ibm.com>
      Cc: "Ma, Jianpeng" <jianpeng.ma@intel.com>
      Cc: Yury Norov <yury.norov@gmail.com>
      Cc: Valentin Schneider <valentin.schneider@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
      Reviewed-by: NJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: NTian Tao <tiantao6@hisilicon.com>
      Signed-off-by: NBarry Song <song.bao.hua@hisilicon.com>
      Link: https://lore.kernel.org/r/20210806110251.560-2-song.bao.hua@hisilicon.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1fae5629
  24. 09 7月, 2021 1 次提交
  25. 16 4月, 2021 2 次提交
  26. 06 3月, 2021 1 次提交