Skip to content

Commit

Permalink
profile: setup_profiling_timer() is moslty not implemented
Browse files Browse the repository at this point in the history
The setup_profiling_timer() is mostly un-implemented by many
architectures.  In many places it isn't guarded by CONFIG_PROFILE which is
needed for it to be used.  Make it a weak symbol in kernel/profile.c and
remove the 'return -EINVAL' implementations from the kenrel.

There are a couple of architectures which do return 0 from the
setup_profiling_timer() function but they don't seem to do anything else
with it.  To keep the /proc compatibility for now, leave these for a
future update or removal.

On ARM, this fixes the following sparse warning:
arch/arm/kernel/smp.c:793:5: warning: symbol 'setup_profiling_timer' was not declared. Should it be static?

Link: https://lkml.kernel.org/r/20220721195509.418205-1-ben-linux@fluff.org
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
  • Loading branch information
Ben Dooks authored and akpm committed Jul 27, 2022
1 parent 8c75591 commit 5f6c0fb
Show file tree
Hide file tree
Showing 16 changed files with 6 additions and 92 deletions.
6 changes: 0 additions & 6 deletions arch/alpha/kernel/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -497,12 +497,6 @@ smp_cpus_done(unsigned int max_cpus)
((bogosum + 2500) / (5000/HZ)) % 100);
}

int
setup_profiling_timer(unsigned int multiplier)
{
return -EINVAL;
}

static void
send_ipi_message(const struct cpumask *to_whom, enum ipi_message_type operation)
{
Expand Down
8 changes: 0 additions & 8 deletions arch/arc/kernel/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,6 @@ int __cpu_up(unsigned int cpu, struct task_struct *idle)
return 0;
}

/*
* not supported here
*/
int setup_profiling_timer(unsigned int multiplier)
{
return -EINVAL;
}

/*****************************************************************************/
/* Inter Processor Interrupt Handling */
/*****************************************************************************/
Expand Down
8 changes: 0 additions & 8 deletions arch/arm/kernel/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -787,14 +787,6 @@ void panic_smp_self_stop(void)
cpu_relax();
}

/*
* not supported here
*/
int setup_profiling_timer(unsigned int multiplier)
{
return -EINVAL;
}

#ifdef CONFIG_CPU_FREQ

static DEFINE_PER_CPU(unsigned long, l_p_j_ref);
Expand Down
8 changes: 0 additions & 8 deletions arch/arm64/kernel/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1078,14 +1078,6 @@ bool smp_crash_stop_failed(void)
}
#endif

/*
* not supported here
*/
int setup_profiling_timer(unsigned int multiplier)
{
return -EINVAL;
}

static bool have_cpu_die(void)
{
#ifdef CONFIG_HOTPLUG_CPU
Expand Down
5 changes: 0 additions & 5 deletions arch/csky/kernel/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,6 @@ void __init smp_cpus_done(unsigned int max_cpus)
{
}

int setup_profiling_timer(unsigned int multiplier)
{
return -EINVAL;
}

void csky_start_secondary(void)
{
struct mm_struct *mm = &init_mm;
Expand Down
5 changes: 0 additions & 5 deletions arch/hexagon/kernel/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,6 @@ void arch_send_call_function_ipi_mask(const struct cpumask *mask)
send_ipi(mask, IPI_CALL_FUNC);
}

int setup_profiling_timer(unsigned int multiplier)
{
return -EINVAL;
}

void smp_start_cpus(void)
{
int i;
Expand Down
6 changes: 0 additions & 6 deletions arch/ia64/kernel/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,3 @@ smp_send_stop (void)
{
send_IPI_allbutself(IPI_CPU_STOP);
}

int
setup_profiling_timer (unsigned int multiplier)
{
return -EINVAL;
}
6 changes: 0 additions & 6 deletions arch/openrisc/kernel/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,6 @@ void smp_send_stop(void)
smp_call_function(stop_this_cpu, NULL, 0);
}

/* not supported, yet */
int setup_profiling_timer(unsigned int multiplier)
{
return -EINVAL;
}

void __init set_smp_cross_call(void (*fn)(const struct cpumask *, unsigned int))
{
smp_cross_call = fn;
Expand Down
7 changes: 0 additions & 7 deletions arch/parisc/kernel/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -513,10 +513,3 @@ void __cpu_die(unsigned int cpu)

pdc_cpu_rendezvous_unlock();
}

#ifdef CONFIG_PROC_FS
int setup_profiling_timer(unsigned int multiplier)
{
return -EINVAL;
}
#endif
7 changes: 0 additions & 7 deletions arch/powerpc/kernel/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1674,13 +1674,6 @@ void start_secondary(void *unused)
BUG();
}

#ifdef CONFIG_PROFILING
int setup_profiling_timer(unsigned int multiplier)
{
return 0;
}
#endif

static void __init fixup_topology(void)
{
int i;
Expand Down
6 changes: 0 additions & 6 deletions arch/riscv/kernel/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,6 @@ bool arch_match_cpu_phys_id(int cpu, u64 phys_id)
return phys_id == cpuid_to_hartid_map(cpu);
}

/* Unsupported */
int setup_profiling_timer(unsigned int multiplier)
{
return -EINVAL;
}

static void ipi_stop(void)
{
set_cpu_online(smp_processor_id(), false);
Expand Down
5 changes: 0 additions & 5 deletions arch/sparc/kernel/smp_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,6 @@ void smp_call_function_interrupt(void)
irq_exit();
}

int setup_profiling_timer(unsigned int multiplier)
{
return -EINVAL;
}

void __init smp_prepare_cpus(unsigned int max_cpus)
{
int i, cpuid, extra;
Expand Down
6 changes: 0 additions & 6 deletions arch/sparc/kernel/smp_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -1186,12 +1186,6 @@ void __irq_entry smp_penguin_jailcell(int irq, struct pt_regs *regs)
preempt_enable();
}

/* /proc/profile writes can call this, don't __init it please. */
int setup_profiling_timer(unsigned int multiplier)
{
return -EINVAL;
}

void __init smp_prepare_cpus(unsigned int max_cpus)
{
}
Expand Down
2 changes: 0 additions & 2 deletions arch/x86/include/asm/apic.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ static inline bool apic_from_smp_config(void)
#include <asm/paravirt.h>
#endif

extern int setup_profiling_timer(unsigned int);

static inline void native_apic_mem_write(u32 reg, u32 v)
{
volatile u32 *addr = (volatile u32 *)(APIC_BASE + reg);
Expand Down
5 changes: 0 additions & 5 deletions arch/x86/kernel/apic/apic.c
Original file line number Diff line number Diff line change
Expand Up @@ -1115,11 +1115,6 @@ DEFINE_IDTENTRY_SYSVEC(sysvec_apic_timer_interrupt)
set_irq_regs(old_regs);
}

int setup_profiling_timer(unsigned int multiplier)
{
return -EINVAL;
}

/*
* Local APIC start and shutdown
*/
Expand Down
8 changes: 6 additions & 2 deletions kernel/profile.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,12 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
return read;
}

/* default is to not implement this call */
int __weak setup_profiling_timer(unsigned mult)
{
return -EINVAL;
}

/*
* Writing to /proc/profile resets the counters
*
Expand All @@ -435,8 +441,6 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
size_t count, loff_t *ppos)
{
#ifdef CONFIG_SMP
extern int setup_profiling_timer(unsigned int multiplier);

if (count == sizeof(int)) {
unsigned int multiplier;

Expand Down

0 comments on commit 5f6c0fb

Please sign in to comment.