Re: [Question] arch-independent way to differentiate between user and kernel

Steven Rostedt
2005-08-03T12:21:01Z

On Wed, 2005-08-03 at 12:48 +0200, Ingo Molnar wrote:
>
> i dont think there's any. user_mode(regs) gets the closest - it might
> make sense to generalize it over all arches.
>
> update_process_times() gets an arch-independent 'was the tick user-space
> or kernel-space' flag, so the best starting point would be to look at
> the output of:
>
> for N in `find . -name '*.c' | xargs grep update_process_times |
> grep arch`; do echo $N; done | grep update_process_times |
> sort | uniq -c
>
> which gives:
>
> 2 update_process_times()
> 1 update_process_times(CHOOSE_MODE(user_context(UPT_SP(regs)),
> 6 update_process_times(user);
> 1 update_process_times(user_mode(fp));
> 33 update_process_times(user_mode(regs));
> 2 update_process_times(user_mode_vm(regs));
>
> so ~33 calls use user_mode(regs), and the rest needs to be reviewed and
> possibly changed. Looks doable.

Ingo,

Thanks for the starting point. For now I'll submit a patch that doesn't
do the user_mode checks as discussed before. Then if I can find
something here, I'll send another patch on top of the first patch later.

-- Steve