Skip to content

Commit

Permalink
exit: Remove profile_task_exit & profile_munmap
Browse files Browse the repository at this point in the history
When I say remove I mean remove.  All profile_task_exit and
profile_munmap do is call a blocking notifier chain.  The helpers
profile_task_register and profile_task_unregister are not called
anywhere in the tree.  Which means this is all dead code.

So remove the dead code and make it easier to read do_exit.

Reviewed-by: Christoph Hellwig <[email protected]>
Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: "Eric W. Biederman" <[email protected]>
  • Loading branch information
ebiederm committed Jan 8, 2022
1 parent 6410349 commit 2d4bcf8
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 78 deletions.
26 changes: 0 additions & 26 deletions include/linux/profile.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ static inline int create_proc_profile(void)
}
#endif

enum profile_type {
PROFILE_TASK_EXIT,
PROFILE_MUNMAP
};

#ifdef CONFIG_PROFILING

extern int prof_on __read_mostly;
Expand Down Expand Up @@ -66,23 +61,14 @@ static inline void profile_hit(int type, void *ip)
struct task_struct;
struct mm_struct;

/* task is in do_exit() */
void profile_task_exit(struct task_struct * task);

/* task is dead, free task struct ? Returns 1 if
* the task was taken, 0 if the task should be freed.
*/
int profile_handoff_task(struct task_struct * task);

/* sys_munmap */
void profile_munmap(unsigned long addr);

int task_handoff_register(struct notifier_block * n);
int task_handoff_unregister(struct notifier_block * n);

int profile_event_register(enum profile_type, struct notifier_block * n);
int profile_event_unregister(enum profile_type, struct notifier_block * n);

#else

#define prof_on 0
Expand Down Expand Up @@ -117,19 +103,7 @@ static inline int task_handoff_unregister(struct notifier_block * n)
return -ENOSYS;
}

static inline int profile_event_register(enum profile_type t, struct notifier_block * n)
{
return -ENOSYS;
}

static inline int profile_event_unregister(enum profile_type t, struct notifier_block * n)
{
return -ENOSYS;
}

#define profile_task_exit(a) do { } while (0)
#define profile_handoff_task(a) (0)
#define profile_munmap(a) do { } while (0)

#endif /* CONFIG_PROFILING */

Expand Down
1 change: 0 additions & 1 deletion kernel/exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,6 @@ void __noreturn do_exit(long code)
*/
force_uaccess_begin();

profile_task_exit(tsk);
kcov_task_exit(tsk);

coredump_task_exit(tsk);
Expand Down
50 changes: 0 additions & 50 deletions kernel/profile.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,7 @@ int __ref profile_init(void)

/* Profile event notifications */

static BLOCKING_NOTIFIER_HEAD(task_exit_notifier);
static ATOMIC_NOTIFIER_HEAD(task_free_notifier);
static BLOCKING_NOTIFIER_HEAD(munmap_notifier);

void profile_task_exit(struct task_struct *task)
{
blocking_notifier_call_chain(&task_exit_notifier, 0, task);
}

int profile_handoff_task(struct task_struct *task)
{
Expand All @@ -151,11 +144,6 @@ int profile_handoff_task(struct task_struct *task)
return (ret == NOTIFY_OK) ? 1 : 0;
}

void profile_munmap(unsigned long addr)
{
blocking_notifier_call_chain(&munmap_notifier, 0, (void *)addr);
}

int task_handoff_register(struct notifier_block *n)
{
return atomic_notifier_chain_register(&task_free_notifier, n);
Expand All @@ -168,44 +156,6 @@ int task_handoff_unregister(struct notifier_block *n)
}
EXPORT_SYMBOL_GPL(task_handoff_unregister);

int profile_event_register(enum profile_type type, struct notifier_block *n)
{
int err = -EINVAL;

switch (type) {
case PROFILE_TASK_EXIT:
err = blocking_notifier_chain_register(
&task_exit_notifier, n);
break;
case PROFILE_MUNMAP:
err = blocking_notifier_chain_register(
&munmap_notifier, n);
break;
}

return err;
}
EXPORT_SYMBOL_GPL(profile_event_register);

int profile_event_unregister(enum profile_type type, struct notifier_block *n)
{
int err = -EINVAL;

switch (type) {
case PROFILE_TASK_EXIT:
err = blocking_notifier_chain_unregister(
&task_exit_notifier, n);
break;
case PROFILE_MUNMAP:
err = blocking_notifier_chain_unregister(
&munmap_notifier, n);
break;
}

return err;
}
EXPORT_SYMBOL_GPL(profile_event_unregister);

#if defined(CONFIG_SMP) && defined(CONFIG_PROC_FS)
/*
* Each cpu has a pair of open-addressed hashtables for pending
Expand Down
1 change: 0 additions & 1 deletion mm/mmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -2928,7 +2928,6 @@ EXPORT_SYMBOL(vm_munmap);
SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
{
addr = untagged_addr(addr);
profile_munmap(addr);
return __vm_munmap(addr, len, true);
}

Expand Down

0 comments on commit 2d4bcf8

Please sign in to comment.