25 Feb, 2014

3 commits

  • The name __smp_call_function_single() doesn't tell much about the
    properties of this function, especially when compared to
    smp_call_function_single().

    The comments above the implementation are also misleading. The main
    point of this function is actually not to be able to embed the csd
    in an object. This is actually a requirement that result from the
    purpose of this function which is to raise an IPI asynchronously.

    As such it can be called with interrupts disabled. And this feature
    comes at the cost of the caller who then needs to serialize the
    IPIs on this csd.

    Lets rename the function and enhance the comments so that they reflect
    these properties.

    Suggested-by: Christoph Hellwig
    Cc: Andrew Morton
    Cc: Christoph Hellwig
    Cc: Ingo Molnar
    Cc: Jan Kara
    Cc: Jens Axboe
    Signed-off-by: Frederic Weisbecker
    Signed-off-by: Jens Axboe

    Frederic Weisbecker
     
  • The main point of calling __smp_call_function_single() is to send
    an IPI in a pure asynchronous way. By embedding a csd in an object,
    a caller can send the IPI without waiting for a previous one to complete
    as is required by smp_call_function_single() for example. As such,
    sending this kind of IPI can be safe even when irqs are disabled.

    This flexibility comes at the expense of the caller who then needs to
    synchronize the csd lifecycle by himself and make sure that IPIs on a
    single csd are serialized.

    This is how __smp_call_function_single() works when wait = 0 and this
    usecase is relevant.

    Now there don't seem to be any usecase with wait = 1 that can't be
    covered by smp_call_function_single() instead, which is safer. Lets look
    at the two possible scenario:

    1) The user calls __smp_call_function_single(wait = 1) on a csd embedded
    in an object. It looks like a nice and convenient pattern at the first
    sight because we can then retrieve the object from the IPI handler easily.

    But actually it is a waste of memory space in the object since the csd
    can be allocated from the stack by smp_call_function_single(wait = 1)
    and the object can be passed an the IPI argument.

    Besides that, embedding the csd in an object is more error prone
    because the caller must take care of the serialization of the IPIs
    for this csd.

    2) The user calls __smp_call_function_single(wait = 1) on a csd that
    is allocated on the stack. It's ok but smp_call_function_single()
    can do it as well and it already takes care of the allocation on the
    stack. Again it's more simple and less error prone.

    Therefore, using the underscore prepend API version with wait = 1
    is a bad pattern and a sign that the caller can do safer and more
    simple.

    There was a single user of that which has just been converted.
    So lets remove this option to discourage further users.

    Cc: Andrew Morton
    Cc: Christoph Hellwig
    Cc: Ingo Molnar
    Cc: Jan Kara
    Cc: Jens Axboe
    Signed-off-by: Frederic Weisbecker
    Signed-off-by: Jens Axboe

    Frederic Weisbecker
     
  • Align __smp_call_function_single() with smp_call_function_single() so
    that it also checks whether requested cpu is still online.

    Signed-off-by: Jan Kara
    Cc: Andrew Morton
    Cc: Christoph Hellwig
    Cc: Ingo Molnar
    Cc: Jens Axboe
    Signed-off-by: Frederic Weisbecker
    Signed-off-by: Jens Axboe

    Jan Kara
     

15 Nov, 2013

1 commit


12 Sep, 2013

3 commits

  • All of the other non-trivial !SMP versions of functions in smp.h are
    out-of-line in up.c. Move on_each_cpu() there as well.

    This allows us to get rid of the #include . The
    drawback is that this makes both the x86_64 and i386 defconfig !SMP
    kernels about 200 bytes larger each.

    Signed-off-by: David Daney
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    David Daney
     
  • The SMP version of this function doesn't unconditionally enable irqs, so
    neither should this !SMP version. There are no know problems caused by
    this, but we make the change for consistency's sake.

    Signed-off-by: David Daney
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    David Daney
     
  • As in commit f21afc25f9ed ("smp.h: Use local_irq_{save,restore}() in
    !SMP version of on_each_cpu()"), we don't want to enable irqs if they
    are not already enabled. There are currently no known problematical
    callers of these functions, but since it is a known failure pattern, we
    preemptively fix them.

    Since they are not trivial functions, make them non-inline by moving
    them to up.c. This also makes it so we don't have to fix #include
    dependancies for preempt_{disable,enable}.

    Signed-off-by: David Daney
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    David Daney
     

31 Oct, 2011

1 commit

  • The changed files were only including linux/module.h for the
    EXPORT_SYMBOL infrastructure, and nothing else. Revector them
    onto the isolated export header for faster compile times.

    Nothing to see here but a whole lot of instances of:

    -#include
    +#include

    This commit is only changing the kernel dir; next targets
    will probably be mm, fs, the arch dirs, etc.

    Signed-off-by: Paul Gortmaker

    Paul Gortmaker
     

12 Jan, 2009

1 commit


11 Jan, 2009

2 commits

  • Impact: build fix on Alpha

    kernel/up.c: In function 'smp_call_function_single':
    kernel/up.c:12: error: 'cpuid' undeclared (first use in this function)
    kernel/up.c:12: error: (Each undeclared identifier is reported only once
    kernel/up.c:12: error: for each function it appears in.)

    The typo didnt show up on x86 because 'cpuid' happens to be a
    function address as well ...

    Signed-off-by: Ingo Molnar

    Ingo Molnar
     
  • If you do

    smp_call_function_single(expression-with-side-effects, ...)

    then expression-with-side-effects never gets evaluated on UP builds.

    As always, implementing it in C is the correct thing to do.

    While we're there, uninline it for size and possible header dependency
    reasons.

    And create a new kernel/up.c, as a place in which to put
    uniprocessor-specific code and storage. It should mirror kernel/smp.c.

    Signed-off-by: Andrew Morton
    Signed-off-by: Ingo Molnar

    Andrew Morton