20 Mar, 2020

1 commit

  • Currently, when updating the affinity of tasks via either cpusets.cpus,
    or, sched_setaffinity(); tasks not currently running within the newly
    specified mask will be arbitrarily assigned to the first CPU within the
    mask.

    This (particularly in the case that we are restricting masks) can
    result in many tasks being assigned to the first CPUs of their new
    masks.

    This:
    1) Can induce scheduling delays while the load-balancer has a chance to
    spread them between their new CPUs.
    2) Can antogonize a poor load-balancer behavior where it has a
    difficult time recognizing that a cross-socket imbalance has been
    forced by an affinity mask.

    This change adds a new cpumask interface to allow iterated calls to
    distribute within the intersection of the provided masks.

    The cases that this mainly affects are:
    - modifying cpuset.cpus
    - when tasks join a cpuset
    - when modifying a task's affinity via sched_setaffinity(2)

    Signed-off-by: Paul Turner
    Signed-off-by: Josh Don
    Signed-off-by: Peter Zijlstra (Intel)
    Reviewed-by: Qais Yousef
    Tested-by: Qais Yousef
    Link: https://lkml.kernel.org/r/20200311010113.136465-1-joshdon@google.com

    Paul Turner
     

04 Feb, 2020

1 commit

  • New design of inner bitmap_parse() allows to avoid calculating the size of
    a null-terminated string.

    Link: http://lkml.kernel.org/r/20200102043031.30357-8-yury.norov@gmail.com
    Signed-off-by: Yury Norov
    Reviewed-by: Andy Shevchenko
    Cc: Amritha Nambiar
    Cc: Arnaldo Carvalho de Melo
    Cc: Chris Wilson
    Cc: Kees Cook
    Cc: Matthew Wilcox
    Cc: Miklos Szeredi
    Cc: Rasmus Villemoes
    Cc: Steffen Klassert
    Cc: "Tobin C . Harding"
    Cc: Vineet Gupta
    Cc: Will Deacon
    Cc: Willem de Bruijn
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Yury Norov
     

26 Sep, 2019

1 commit

  • Mask arguments can be swapped without changing anything. Make arguments
    names reflect that:

    #define for_each_cpu_and(cpu, mask1, mask2)

    Link: http://lkml.kernel.org/r/20190724183350.GA15041@avx2
    Signed-off-by: Alexey Dobriyan
    Reviewed-by: Andrew Morton
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alexey Dobriyan
     

25 Jul, 2019

3 commits

  • Re-evaluating the bitmap wheight of the online cpus bitmap in every
    invocation of num_online_cpus() over and over is a pretty useless
    exercise. Especially when num_online_cpus() is used in code paths
    like the IPI delivery of x86 or the membarrier code.

    Cache the number of online CPUs in the core and just return the cached
    variable. The accessor function provides only a snapshot when used without
    protection against concurrent CPU hotplug.

    The storage needs to use an atomic_t because the kexec and reboot code
    (ab)use set_cpu_online() in their 'shutdown' handlers without any form of
    serialization as pointed out by Mathieu. Regular CPU hotplug usage is
    properly serialized.

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Mathieu Desnoyers
    Link: https://lkml.kernel.org/r/alpine.DEB.2.21.1907091622590.1634@nanos.tec.linutronix.de

    Thomas Gleixner
     
  • The IPI code of x86 needs to evaluate whether the target cpumask is equal
    to the cpu_online_mask or equal except for the calling CPU.

    To replace the current implementation which requires the usage of a
    temporary cpumask, which might involve allocations, add a new function
    which compares a cpumask to the result of two other cpumasks which are
    or'ed together before comparison.

    This allows to make the required decision in one go and the calling code
    then can check for the calling CPU being set in the target mask with
    cpumask_test_cpu().

    Signed-off-by: Thomas Gleixner
    Acked-by: Peter Zijlstra (Intel)
    Link: https://lkml.kernel.org/r/20190722105220.585449120@linutronix.de

    Thomas Gleixner
     
  • The booted once information which is required to deal with the MCE
    broadcast issue on X86 correctly is stored in the per cpu hotplug state,
    which is perfectly fine for the intended purpose.

    X86 needs that information for supporting NMI broadcasting via shortcuts,
    but retrieving it from per cpu data is cumbersome.

    Move it to a cpumask so the information can be checked against the
    cpu_present_mask quickly.

    No functional change intended.

    Signed-off-by: Thomas Gleixner
    Acked-by: Peter Zijlstra (Intel)
    Link: https://lkml.kernel.org/r/20190722105219.818822855@linutronix.de

    Thomas Gleixner
     

15 May, 2019

1 commit

  • cpumask_parse() finds first occurrence of either or strchr() and
    strlen(). We can do it better with a single call of strchrnul().

    [akpm@linux-foundation.org: remove unneeded cast]
    Link: http://lkml.kernel.org/r/20190409204208.12190-1-ynorov@marvell.com
    Signed-off-by: Yury Norov
    Acked-by: Rasmus Villemoes
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Yury Norov
     

14 Aug, 2018

1 commit

  • The kbuild robot shows build failure on machines without CONFIG_SMP:

    drivers/net/virtio_net.c:1916:10: error:
    implicit declaration of function 'cpumask_next_wrap'

    cpumask_next_wrap is exported from lib/cpumask.o, which has

    lib-$(CONFIG_SMP) += cpumask.o

    same as other functions, also define it as static inline in the
    NR_CPUS==1 branch in include/linux/cpumask.h.

    If wrap is true and next == start, return nr_cpumask_bits, or 1.
    Else wrap across the range of valid cpus, here [0].

    Fixes: 2ca653d607ce ("virtio_net: Stripe queue affinities across cores.")
    Signed-off-by: Willem de Bruijn
    Tested-by: Krzysztof Kozlowski
    Signed-off-by: David S. Miller

    Willem de Bruijn
     

02 Jul, 2018

1 commit


16 Feb, 2018

1 commit

  • for_each_cpu_wrap() was originally added in the #else half of a
    large "#if NR_CPUS == 1" statement, but was omitted in the #if
    half. This patch adds the missing #if half to prevent compile
    errors when NR_CPUS is 1.

    Reported-by: kbuild test robot
    Signed-off-by: Michael Kelley
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: kys@microsoft.com
    Cc: martin.petersen@oracle.com
    Cc: mikelley@microsoft.com
    Fixes: c743f0a5c50f ("sched/fair, cpumask: Export for_each_cpu_wrap()")
    Link: http://lkml.kernel.org/r/SN6PR1901MB2045F087F59450507D4FCC17CBF50@SN6PR1901MB2045.namprd19.prod.outlook.com
    Signed-off-by: Ingo Molnar

    Michael Kelley
     

07 Feb, 2018

1 commit

  • CPUmasks are never big enough to warrant 64-bit code.

    Space savings:

    add/remove: 0/0 grow/shrink: 1/4 up/down: 3/-17 (-14)
    Function old new delta
    sched_init_numa 1530 1533 +3
    compat_sys_sched_setaffinity 160 159 -1
    sys_sched_getaffinity 197 195 -2
    sys_sched_setaffinity 183 176 -7
    compat_sys_sched_getaffinity 179 172 -7

    Link: http://lkml.kernel.org/r/20171204165531.GA8221@avx2
    Signed-off-by: Alexey Dobriyan
    Cc: Ingo Molnar
    Cc: Peter Zijlstra
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alexey Dobriyan
     

08 Nov, 2017

1 commit


02 Nov, 2017

1 commit

  • Many source files in the tree are missing licensing information, which
    makes it harder for compliance tools to determine the correct license.

    By default all files without license information are under the default
    license of the kernel, which is GPL version 2.

    Update the files which contain no license information with the 'GPL-2.0'
    SPDX license identifier. The SPDX identifier is a legally binding
    shorthand, which can be used instead of the full boiler plate text.

    This patch is based on work done by Thomas Gleixner and Kate Stewart and
    Philippe Ombredanne.

    How this work was done:

    Patches were generated and checked against linux-4.14-rc6 for a subset of
    the use cases:
    - file had no licensing information it it.
    - file was a */uapi/* one with no licensing information in it,
    - file was a */uapi/* one with existing licensing information,

    Further patches will be generated in subsequent months to fix up cases
    where non-standard license headers were used, and references to license
    had to be inferred by heuristics based on keywords.

    The analysis to determine which SPDX License Identifier to be applied to
    a file was done in a spreadsheet of side by side results from of the
    output of two independent scanners (ScanCode & Windriver) producing SPDX
    tag:value files created by Philippe Ombredanne. Philippe prepared the
    base worksheet, and did an initial spot review of a few 1000 files.

    The 4.13 kernel was the starting point of the analysis with 60,537 files
    assessed. Kate Stewart did a file by file comparison of the scanner
    results in the spreadsheet to determine which SPDX license identifier(s)
    to be applied to the file. She confirmed any determination that was not
    immediately clear with lawyers working with the Linux Foundation.

    Criteria used to select files for SPDX license identifier tagging was:
    - Files considered eligible had to be source code files.
    - Make and config files were included as candidates if they contained >5
    lines of source
    - File already had some variant of a license header in it (even if
    Reviewed-by: Philippe Ombredanne
    Reviewed-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

24 Oct, 2017

1 commit

  • cpulist_parse() uses nr_cpumask_bits as a limit to parse the
    passed buffer from kernel commandline. What nr_cpumask_bits
    represents varies depending upon the CONFIG_CPUMASK_OFFSTACK option:

    - If CONFIG_CPUMASK_OFFSTACK=n, then nr_cpumask_bits is the same as
    NR_CPUS, which might not represent the # of CPUs that really exist
    (default 64). So, there's a chance of a gap between nr_cpu_ids
    and NR_CPUS, which ultimately lead towards invalid cpulist_parse()
    operation. For example, if isolcpus=9 is passed on an 8 cpu
    system (CONFIG_CPUMASK_OFFSTACK=n) it doesn't show the error
    that it's supposed to.

    This patch fixes this bug by finding the last CPU of the passed
    isolcpus= list and checking it against nr_cpu_ids.

    It also fixes the error message where the nr_cpu_ids should be
    nr_cpu_ids-1, since CPU numbering starts from 0.

    Signed-off-by: Rakib Mullick
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: adobriyan@gmail.com
    Cc: akpm@linux-foundation.org
    Cc: longman@redhat.com
    Cc: mka@chromium.org
    Cc: tj@kernel.org
    Link: http://lkml.kernel.org/r/20171023130154.9050-1-rakib.mullick@gmail.com
    [ Enhanced the changelog and the kernel message. ]
    Signed-off-by: Ingo Molnar

    include/linux/cpumask.h | 16 ++++++++++++++++
    kernel/sched/topology.c | 4 ++--
    2 files changed, 18 insertions(+), 2 deletions(-)

    Rakib Mullick
     

09 Sep, 2017

2 commits

  • Every for_each_XXX_cpu() invocation calls cpumask_next() which is an
    inline function:

    static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
    {
    /* -1 is a legal arg here. */
    if (n != -1)
    cpumask_check(n);
    return find_next_bit(cpumask_bits(srcp), nr_cpumask_bits, n + 1);
    }

    However!

    find_next_bit() is regular out-of-line function which means "nr_cpu_ids"
    load and increment happen at the caller resulting in a lot of bloat

    x86_64 defconfig:
    add/remove: 3/0 grow/shrink: 8/373 up/down: 155/-5668 (-5513)
    x86_64 allyesconfig-ish:
    add/remove: 3/1 grow/shrink: 57/634 up/down: 3515/-28177 (-24662) !!!

    Some archs redefine find_next_bit() but it is OK:

    m68k inline but SMP is not supported
    arm out-of-line
    unicore32 out-of-line

    Function call will happen anyway, so move load and increment into callee.

    Link: http://lkml.kernel.org/r/20170824230010.GA1593@avx2
    Signed-off-by: Alexey Dobriyan
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alexey Dobriyan
     
  • First, number of CPUs can't be negative number.

    Second, different signnnedness leads to suboptimal code in the following
    cases:

    1)
    kmalloc(nr_cpu_ids * sizeof(X));

    "int" has to be sign extended to size_t.

    2)
    while (loff_t *pos < nr_cpu_ids)

    MOVSXD is 1 byte longed than the same MOV.

    Other cases exist as well. Basically compiler is told that nr_cpu_ids
    can't be negative which can't be deduced if it is "int".

    Code savings on allyesconfig kernel: -3KB

    add/remove: 0/0 grow/shrink: 25/264 up/down: 261/-3631 (-3370)
    function old new delta
    coretemp_cpu_online 450 512 +62
    rcu_init_one 1234 1272 +38
    pci_device_probe 374 399 +25

    ...

    pgdat_reclaimable_pages 628 556 -72
    select_fallback_rq 446 369 -77
    task_numa_find_cpu 1923 1807 -116

    Link: http://lkml.kernel.org/r/20170819114959.GA30580@avx2
    Signed-off-by: Alexey Dobriyan
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alexey Dobriyan
     

23 May, 2017

1 commit


15 May, 2017

1 commit

  • More users for for_each_cpu_wrap() have appeared. Promote the construct
    to generic cpumask interface.

    The implementation is slightly modified to reduce arguments.

    Signed-off-by: Peter Zijlstra (Intel)
    Cc: Lauro Ramos Venancio
    Cc: Linus Torvalds
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Rik van Riel
    Cc: Thomas Gleixner
    Cc: lwang@redhat.com
    Link: http://lkml.kernel.org/r/20170414122005.o35me2h5nowqkxbv@hirez.programming.kicks-ass.net
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     

09 May, 2017

1 commit

  • Bit searching functions accept "unsigned long" indices but
    "nr_cpumask_bits" is "int" which is signed, so inevitable sign
    extensions occur on x86_64. Those MOVSX are #1 MOVSX bloat by number of
    uses across whole kernel.

    Change "nr_cpumask_bits" to unsigned, this number can't be negative
    after all. It allows to do implicit zero-extension on x86_64 without
    MOVSX.

    Change signed comparisons into unsigned comparisons where necessary.

    Other uses looks fine because it is either argument passed to a function
    or comparison is already unsigned.

    Net win on allyesconfig type of kernel: ~2.8 KB (!)

    add/remove: 0/0 grow/shrink: 8/725 up/down: 93/-2926 (-2833)
    function old new delta
    xen_exit_mmap 691 735 +44
    qstat_read 426 440 +14
    __cpufreq_cooling_register 1678 1687 +9
    trace_rb_cpu_prepare 447 455 +8
    vermagic 54 60 +6
    nfp_driver_version 54 60 +6
    rcu_torture_stats_print 1147 1151 +4
    find_next_push_cpu 267 269 +2
    xen_irq_resume 961 960 -1
    ...
    init_vp_index 946 906 -40
    od_set_powersave_bias 328 281 -47
    power_cpu_exit 193 139 -54
    arch_show_interrupts 3538 3484 -54
    select_idle_sibling 1558 1471 -87
    Total: Before=158358910, After=158356077, chg -0.00%

    Same arguments apply to "nr_cpu_ids" but I haven't yet found enough
    courage to delve into this issue (and proper fix may require new type
    "cpu_t" which is whole separate story).

    Link: http://lkml.kernel.org/r/20170309205322.GA1728@avx2
    Signed-off-by: Alexey Dobriyan
    Cc: Rusty Russell
    Cc: Heiko Carstens
    Cc: Martin Schwidefsky
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alexey Dobriyan
     

15 Apr, 2017

1 commit

  • With CONFIG_CPUMASK_OFFSTACK=y cpumask_var_t is a struct cpumask
    pointer, otherwise a struct cpumask array with a single element.

    Some code dealing with cpumasks needs to validate that a cpumask_var_t
    is not a NULL pointer when CONFIG_CPUMASK_OFFSTACK=y. This is typically
    done by performing the check always, regardless of the underlying type
    of cpumask_var_t. This works in both cases, however clang raises a
    warning like this when CONFIG_CPUMASK_OFFSTACK=n:

    kernel/irq/manage.c:839:28: error: address of array
    'desc->irq_common_data.affinity' will always evaluate to 'true'
    [-Werror,-Wpointer-bool-conversion]

    Add the inline helper cpumask_available() which only performs the
    pointer check if CONFIG_CPUMASK_OFFSTACK=y.

    Signed-off-by: Matthias Kaehlcke
    Cc: Grant Grundler
    Cc: Rusty Russell
    Cc: Greg Hackmann
    Cc: Michael Davidson
    Cc: Andrew Morton
    Link: http://lkml.kernel.org/r/20170412182030.83657-1-mka@chromium.org
    Signed-off-by: Thomas Gleixner

    Matthias Kaehlcke
     

21 Feb, 2017

1 commit

  • Pull timer updates from Thomas Gleixner:
    "Nothing exciting, just the usual pile of fixes, updates and cleanups:

    - A bunch of clocksource driver updates

    - Removal of CONFIG_TIMER_STATS and the related /proc file

    - More posix timer slim down work

    - A scalability enhancement in the tick broadcast code

    - Math cleanups"

    * 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (23 commits)
    hrtimer: Catch invalid clockids again
    math64, tile: Fix build failure
    clocksource/drivers/arm_arch_timer:: Mark cyclecounter __ro_after_init
    timerfd: Protect the might cancel mechanism proper
    timer_list: Remove useless cast when printing
    time: Remove CONFIG_TIMER_STATS
    clocksource/drivers/arm_arch_timer: Work around Hisilicon erratum 161010101
    clocksource/drivers/arm_arch_timer: Introduce generic errata handling infrastructure
    clocksource/drivers/arm_arch_timer: Remove fsl-a008585 parameter
    clocksource/drivers/arm_arch_timer: Add dt binding for hisilicon-161010101 erratum
    clocksource/drivers/ostm: Add renesas-ostm timer driver
    clocksource/drivers/ostm: Document renesas-ostm timer DT bindings
    clocksource/drivers/tcb_clksrc: Use 32 bit tcb as sched_clock
    clocksource/drivers/gemini: Add driver for the Cortina Gemini
    clocksource: add DT bindings for Cortina Gemini
    clockevents: Add a clkevt-of mechanism like clksrc-of
    tick/broadcast: Reduce lock cacheline contention
    timers: Omit POSIX timer stuff from task_struct when disabled
    x86/timer: Make delay() work during early bootup
    delay: Add explanation of udelay() inaccuracy
    ...

    Linus Torvalds
     

09 Feb, 2017

1 commit

  • Commit 513e3d2d11c9 ("cpumask: always use nr_cpu_ids in formatting and
    parsing functions") converted both cpumask printing and parsing
    functions to use nr_cpu_ids instead of nr_cpumask_bits. While this was
    okay for the printing functions as it just picked one of the two output
    formats that we were alternating between depending on a kernel config,
    doing the same for parsing wasn't okay.

    nr_cpumask_bits can be either nr_cpu_ids or NR_CPUS. We can always use
    nr_cpu_ids but that is a variable while NR_CPUS is a constant, so it can
    be more efficient to use NR_CPUS when we can get away with it.
    Converting the printing functions to nr_cpu_ids makes sense because it
    affects how the masks get presented to userspace and doesn't break
    anything; however, using nr_cpu_ids for parsing functions can
    incorrectly leave the higher bits uninitialized while reading in these
    masks from userland. As all testing and comparison functions use
    nr_cpumask_bits which can be larger than nr_cpu_ids, the parsed cpumasks
    can erroneously yield false negative results.

    This made the taskstats interface incorrectly return -EINVAL even when
    the inputs were correct.

    Fix it by restoring the parse functions to use nr_cpumask_bits instead
    of nr_cpu_ids.

    Link: http://lkml.kernel.org/r/20170206182442.GB31078@htj.duckdns.org
    Fixes: 513e3d2d11c9 ("cpumask: always use nr_cpu_ids in formatting and parsing functions")
    Signed-off-by: Tejun Heo
    Reported-by: Martin Steigerwald
    Debugged-by: Ben Hutchings
    Cc: [4.0+]
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tejun Heo
     

04 Feb, 2017

1 commit

  • It was observed that on an Intel x86 system without the ARAT (Always
    running APIC timer) feature and with fairly large number of CPUs as
    well as CPUs coming in and out of intel_idle frequently, the lock
    contention on the tick_broadcast_lock can become significant.

    To reduce contention, the lock is put into its own cacheline and all
    the cpumask_var_t variables are put into the __read_mostly section.

    Running the SP benchmark of the NAS Parallel Benchmarks on a 4-socket
    16-core 32-thread Nehalam system, the performance number improved
    from 3353.94 Mop/s to 3469.31 Mop/s when this patch was applied on
    a 4.9.6 kernel. This is a 3.4% improvement.

    Signed-off-by: Waiman Long
    Cc: "Peter Zijlstra (Intel)"
    Cc: Andrew Morton
    Link: http://lkml.kernel.org/r/1485799063-20857-1-git-send-email-longman@redhat.com
    Signed-off-by: Thomas Gleixner

    Waiman Long
     

15 Dec, 2016

1 commit

  • prefill_possible_map() reinitializes the cpu_possible_map by setting the
    possible cpu bits and clearing all other bits up to NR_CPUS.

    This is technically always correct because cpu_possible_map is statically
    allocated and sized NR_CPUS. With CPUMASK_OFFSTACK and DEBUG_PER_CPU_MAPS
    enabled the bounds check of cpu masks happens on nr_cpu_ids. nr_cpu_ids is
    initialized to NR_CPUS and only limited after the set/clear bit loops have
    been executed.

    But if the system was booted with "nr_cpus=N" on the command line, where N
    is < NR_CPUS then nr_cpu_ids is limited in the parameter parsing function
    before prefill_possible_map() is invoked. As a consequence the cpumask
    bounds check triggers when clearing the bits past nr_cpu_ids.

    Add a helper which allows to reset cpu_possible_map w/o the bounds check
    and then set only the possible bits which are well inside bounds.

    Reported-by: Dmitry Safonov
    Cc: Rusty Russell
    Cc: 0x7f454c46@gmail.com
    Cc: Jan Beulich
    Link: http://lkml.kernel.org/r/alpine.DEB.2.20.1612131836050.3415@nanos
    Signed-off-by: Thomas Gleixner

    Thomas Gleixner
     

03 Aug, 2016

1 commit

  • Fix code comment for cpumask_parse().

    Link: http://lkml.kernel.org/r/71aae2c60ae5dae0cf554199ce6aea8f88c69347.1465380581.git.geliangtang@gmail.com
    Signed-off-by: Geliang Tang
    Acked-by: Rusty Russell
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Geliang Tang
     

06 May, 2016

1 commit

  • In order to enable symmetric hotplug, we must mirror the online &&
    !active state of cpu-down on the cpu-up side.

    However, to retain sanity, limit this state to per-cpu kthreads.

    Aside from the change to set_cpus_allowed_ptr(), which allow moving
    the per-cpu kthreads on, the other critical piece is the cpu selection
    for pinned tasks in select_task_rq(). This avoids dropping into
    select_fallback_rq().

    select_fallback_rq() cannot be allowed to select !active cpus because
    its used to migrate user tasks away. And we do not want to move user
    tasks onto cpus that are in transition.

    Requested-by: Thomas Gleixner
    Signed-off-by: Peter Zijlstra (Intel)
    Tested-by: Thomas Gleixner
    Cc: Lai Jiangshan
    Cc: Jan H. Schönherr
    Cc: Oleg Nesterov
    Cc: rt@linutronix.de
    Link: http://lkml.kernel.org/r/20160301152303.GV6356@twins.programming.kicks-ass.net
    Signed-off-by: Thomas Gleixner

    Peter Zijlstra (Intel)
     

23 Mar, 2016

1 commit


21 Jan, 2016

3 commits

  • Almost all callers of the set_cpu_* functions pass an explicit true or
    false. Making them static inline thus replaces the function calls with a
    simple set_bit/clear_bit, saving some .text.

    Signed-off-by: Rasmus Villemoes
    Acked-by: Rusty Russell
    Cc: Greg Kroah-Hartman
    Cc: Michael Ellerman
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rasmus Villemoes
     
  • Replace the variables cpu_possible_mask, cpu_online_mask, cpu_present_mask
    and cpu_active_mask with macros expanding to expressions of the same type
    and value, eliminating some indirection.

    Signed-off-by: Rasmus Villemoes
    Acked-by: Rusty Russell
    Cc: Greg Kroah-Hartman
    Cc: Michael Ellerman
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rasmus Villemoes
     
  • Exporting the cpumasks __cpu_possible_mask and friends will allow us to
    remove the extra indirection through the cpu_*_mask variables. It will
    also allow the set_cpu_* functions to become static inlines, which will
    give a .text reduction.

    Signed-off-by: Rasmus Villemoes
    Acked-by: Rusty Russell
    Cc: Greg Kroah-Hartman
    Cc: Michael Ellerman
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rasmus Villemoes
     

28 May, 2015

1 commit

  • da91309e0a7e (cpumask: Utility function to set n'th cpu...) created a
    genuinely weird function. I never saw it before, it went through DaveM.
    (He only does this to make us other maintainers feel better about our own
    mistakes.)

    cpumask_set_cpu_local_first's purpose is say "I need to spread things
    across N online cpus, choose the ones on this numa node first"; you call
    it in a loop.

    It can fail. One of the two callers ignores this, the other aborts and
    fails the device open.

    It can fail in two ways: allocating the off-stack cpumask, or through a
    convoluted codepath which AFAICT can only occur if cpu_online_mask
    changes. Which shouldn't happen, because if cpu_online_mask can change
    while you call this, it could return a now-offline cpu anyway.

    It contains a nonsensical test "!cpumask_of_node(numa_node)". This was
    drawn to my attention by Geert, who said this causes a warning on Sparc.
    It sets a single bit in a cpumask instead of returning a cpu number,
    because that's what the callers want.

    It could be made more efficient by passing the previous cpu rather than
    an index, but that would be more invasive to the callers.

    Fixes: da91309e0a7e8966d916a74cce42ed170fde06bf
    Signed-off-by: Rusty Russell (then rebased)
    Tested-by: Amir Vadai
    Acked-by: Amir Vadai
    Acked-by: David S. Miller

    Rusty Russell
     

16 Apr, 2015

1 commit


31 Mar, 2015

1 commit

  • The Subtlety (1) referred to vanished with 6ba2ef7baac2 ("cpumask:
    Move deprecated functions to end of header."). That used to mention
    some suboptimal code generation by a, by now, rather ancient gcc. With
    gcc 4.7, I don't see any change in the generated code by making it a
    static inline, so let's add type checking and get rid of the ghost
    reference.

    Signed-off-by: Rasmus Villemoes
    Signed-off-by: Rusty Russell

    Rasmus Villemoes
     

10 Mar, 2015

2 commits


05 Mar, 2015

1 commit


14 Feb, 2015

3 commits

  • Now that all bitmap formatting usages have been converted to
    '%*pb[l]', the separate formatting functions are unnecessary. The
    following functions are removed.

    * bitmap_scn[list]printf()
    * cpumask_scnprintf(), cpulist_scnprintf()
    * [__]nodemask_scnprintf(), [__]nodelist_scnprintf()
    * seq_bitmap[_list](), seq_cpumask[_list](), seq_nodemask[_list]()
    * seq_buf_bitmask()

    Signed-off-by: Tejun Heo
    Cc: Rusty Russell
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tejun Heo
     
  • printf family of functions can now format bitmaps using '%*pb[l]' and
    all cpumask and nodemask formatting will be converted to use it. To
    ease printing these masks with '%*pb[l]' which require two params -
    the number of bits and the actual bitmap, this patch implement
    cpumask_pr_args() and nodemask_pr_args() which can be used to provide
    arguments for '%*pb[l]'

    Signed-off-by: Tejun Heo
    Cc: Rusty Russell
    Cc: "David S. Miller"
    Cc: "James E.J. Bottomley"
    Cc: "John W. Linville"
    Cc: "Paul E. McKenney"
    Cc: Benjamin Herrenschmidt
    Cc: Chris Metcalf
    Cc: Chris Zankel
    Cc: Christoph Lameter
    Cc: Dmitry Torokhov
    Cc: Fenghua Yu
    Cc: Greg Kroah-Hartman
    Cc: Ingo Molnar
    Cc: Li Zefan
    Cc: Max Filippov
    Cc: Mike Travis
    Cc: Pekka Enberg
    Cc: Peter Zijlstra
    Cc: Russell King
    Cc: Steffen Klassert
    Cc: Steven Rostedt
    Cc: Thomas Gleixner
    Cc: Tony Luck
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tejun Heo
     
  • bitmap implements two variants of scnprintf functions to format a bitmap
    into a string and cpumask and nodemask wrap them to provide equivalent
    interfaces. The scnprintf family of functions require a string buffer as
    an output target which complicates code paths which just want to print out
    the mask through printk for informational or debug purposes as they have
    to worry about how large the buffer should be and whether it's too large
    to allocate on stack.

    Neither cpumask or nodemask provides a guildeline on how large the target
    buffer should be forcing users come up with their own solutions - some
    allocate an arbitrarily sized buffer which is small enough to allocate on
    stack but may be too short in corner cases, other come up with a custom
    upper limit calculation considering the output format, some allocate the
    buffer dynamically while one resorted to using lock to synchronize access
    to a static buffer.

    This is an artificial problem which is being solved repeatedly for no
    benefit. In a lot of cases, the output area already exists and can be
    targeted directly making the intermediate buffer unnecessary. This
    patchset teaches printf family of functions how to format bitmaps and
    replace the dedicated formatting functions with it.

    Pointer formatting is extended to cover bitmap formatting. It uses the
    field width for the number of bits instead of precision. The format used
    is '%*pb[l]', with the optional trailing 'l' specifying list format
    instead of hex masks. For more details, please see 0002.

    This patch (of 31):

    Currently, the formatting and parsing functions in cpumask.h use
    nr_cpumask_bits like other cpumask functions; however, nr_cpumask_bits
    is either NR_CPUS or nr_cpu_ids depending on CONFIG_CPUMASK_OFFSTACK.
    This leads to inconsistent behaviors.

    With CONFIG_NR_CPUS=512 and !CONFIG_CPUMASK_OFFSTACK

    # cat /sys/devices/virtual/net/lo/queues/rx-0/rps_cpus
    00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000
    # cat /proc/self/status | grep Cpus_allowed:
    Cpus_allowed: f

    With CONFIG_NR_CPUS=1024 and CONFIG_CPUMASK_OFFSTACK (fedora default)

    # cat /sys/devices/virtual/net/lo/queues/rx-0/rps_cpus
    0
    # cat /proc/self/status | grep Cpus_allowed:
    Cpus_allowed: f

    Note that /proc/self/status is always using nr_cpu_ids regardless of
    config. This is because seq cpumask formattings functions always use
    nr_cpu_ids.

    Given that the same output fields may switch between the two forms,
    converging on nr_cpu_ids always isn't too likely to surprise userland.
    This patch updates the formatting and parsing functions in cpumask.h
    to always use nr_cpu_ids. There's no point in dealing with CPUs which
    aren't even possible on the machine.

    Signed-off-by: Tejun Heo
    Cc: "David S. Miller"
    Cc: "James E.J. Bottomley"
    Cc: "John W. Linville"
    Cc: "Paul E. McKenney"
    Cc: Benjamin Herrenschmidt
    Cc: Chris Metcalf
    Cc: Chris Zankel
    Cc: Christoph Lameter
    Cc: Dmitry Torokhov
    Cc: Fenghua Yu
    Cc: Greg Kroah-Hartman
    Cc: Ingo Molnar
    Cc: Li Zefan
    Cc: Max Filippov
    Cc: Mike Travis
    Cc: Pekka Enberg
    Cc: Peter Zijlstra
    Cc: Russell King
    Acked-by: Rusty Russell
    Cc: Steffen Klassert
    Cc: Steven Rostedt
    Cc: Thomas Gleixner
    Cc: Tony Luck
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tejun Heo
     

13 Feb, 2015

1 commit