From: Nicholas Piggin <npiggin@gmail.com>
To: Christophe Leroy <christophe.leroy@c-s.fr>,
linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH v2 4/4] powerpc/64: system call implement the bulk of the logic in C
Date: Wed, 28 Aug 2019 19:41:04 +1000 [thread overview]
Message-ID: <1566984787.11eqat0ax3.astroid@bobo.none> (raw)
In-Reply-To: <1015bea4-8b51-ea3b-7e45-8825635261bb@c-s.fr>
Christophe Leroy's on August 28, 2019 4:51 pm:
>
>
> Le 27/08/2019 à 15:55, Nicholas Piggin a écrit :
>> -#include <asm/reg.h>
>> +#include <asm/mmu.h>
>> +#include <asm/ptrace.h>
>> +
>> +static inline void kuap_check_amr(void)
>> +{
>> +#ifdef CONFIG_PPC_KUAP_DEBUG
>> + if (mmu_has_feature(MMU_FTR_RADIX_KUAP))
>
> Better:
>
> if (IS_ENABLED(CONFIG_PPC_KUAP_DEBUG) &&
> mmu_has_feature(MMU_FTR_RADIX_KUAP))
That is better.
>> + WARN_ON_ONCE(mfspr(SPRN_AMR) != AMR_KUAP_BLOCKED);
>> +#endif
>> +}
>>
>> /*
>> * We support individually allowing read or write, but we don't support nesting
>> diff --git a/arch/powerpc/include/asm/cputime.h b/arch/powerpc/include/asm/cputime.h
>> index 2431b4ada2fa..f3aa9db1a3cc 100644
>> --- a/arch/powerpc/include/asm/cputime.h
>> +++ b/arch/powerpc/include/asm/cputime.h
>> @@ -60,6 +60,28 @@ static inline void arch_vtime_task_switch(struct task_struct *prev)
>> }
>> #endif
>>
>> +static inline void account_cpu_user_entry(void)
>> +{
>> + unsigned long tb = mftb();
>> +
>> + get_accounting(current)->utime += (tb - get_accounting(current)->starttime_user);
>> + get_accounting(current)->starttime = tb;
>> +}
>
> Can you check the generated assembly ? I remember having bad result with
> get_accouting() being used several times in a arch_vtime_task_switch()
> before commit 60f1d2893ee6 ("powerpc/time: inline
> arch_vtime_task_switch()")
It's fine on 64s but it's accounting is a constant offset from r13 so
simple load/store can be done.
> Regardless, I think it would look better as:
>
> static inline void account_cpu_user_entry(void)
> {
> unsigned long tb = mftb();
> struct cpu_accounting_data *acct = get_accounting(current);
>
> acct->utime += (tb - acct->starttime_user);
> acct->starttime = tb;
> }
Yeah that's nicer.
>
>> +static inline void account_cpu_user_exit(void)
>> +{
>> + unsigned long tb = mftb();
>> +
>> + get_accounting(current)->stime += (tb - get_accounting(current)->starttime);
>> + get_accounting(current)->starttime_user = tb;
>> +}
>
> Same here.
Will do.
Thanks,
Nick
next prev parent reply other threads:[~2019-08-28 9:44 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-27 13:55 [PATCH v2 0/4] powerpc/64: syscalls in C Nicholas Piggin
2019-08-27 13:55 ` [PATCH v2 1/4] powerpc: convert to copy_thread_tls Nicholas Piggin
2019-08-27 13:55 ` [PATCH v2 2/4] powerpc/64: remove support for kernel-mode syscalls Nicholas Piggin
2019-08-27 13:55 ` [PATCH v2 3/4] powerpc/64: system call remove non-volatile GPR save optimisation Nicholas Piggin
2019-08-28 9:02 ` Christophe Leroy
2019-08-28 9:32 ` Nicholas Piggin
2019-08-27 13:55 ` [PATCH v2 4/4] powerpc/64: system call implement the bulk of the logic in C Nicholas Piggin
2019-08-28 6:51 ` Christophe Leroy
2019-08-28 9:41 ` Nicholas Piggin [this message]
2019-08-28 15:30 ` Michal Suchánek
2019-08-28 22:19 ` Nicholas Piggin
2019-08-30 18:48 ` kbuild test robot
2019-08-30 20:04 ` Michal Suchánek
2019-09-02 10:20 ` Michael Ellerman
2019-08-28 9:06 ` [PATCH v2 0/4] powerpc/64: syscalls " Christophe Leroy
2019-08-28 9:49 ` Nicholas Piggin
2019-08-28 9:55 ` Christophe Leroy
2019-08-29 9:38 ` Nicholas Piggin
2019-08-29 10:45 ` Nicholas Piggin
2019-08-29 11:51 ` Segher Boessenkool
2019-08-29 15:49 ` Nicholas Piggin
2019-08-29 22:56 ` Nicholas Piggin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1566984787.11eqat0ax3.astroid@bobo.none \
--to=npiggin@gmail.com \
--cc=christophe.leroy@c-s.fr \
--cc=linuxppc-dev@lists.ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).