Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1290589 > unrolled thread
| Started by | Chen Gang <chengang@emindsoft.com.cn> |
|---|---|
| First post | 2015-12-13 10:20 +0100 |
| Last post | 2015-12-13 16:50 +0100 |
| Articles | 2 — 1 participant |
Back to article view | Back to linux.kernel
[PATCH] include/asm-generic/pgtable.h: Check once and return for pgprot_modify Chen Gang <chengang@emindsoft.com.cn> - 2015-12-13 10:20 +0100
Re: [PATCH] include/asm-generic/pgtable.h: Check once and return for pgprot_modify Chen Gang <chengang@emindsoft.com.cn> - 2015-12-13 16:50 +0100
| From | Chen Gang <chengang@emindsoft.com.cn> |
|---|---|
| Date | 2015-12-13 10:20 +0100 |
| Subject | [PATCH] include/asm-generic/pgtable.h: Check once and return for pgprot_modify |
| Message-ID | <qFaYV-6rZ-7@gated-at.bofh.it> |
pgprot_val() likes an empty operation, and all three checking statements
are related with oldprot, so only check once is enough, the reason is:
- if both "oldprot == pgprot_noncached(oldprot)" and "oldprot ==
pgprot_writecombine(oldprot)" are satisfied.
- So "pgprot_noncached(oldprot) == pgprot_writecombine(oldprot)", too.
- So as the result, it is still equal to check once (for pgprot_device
can get the same result).
Then can return directly.
Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
---
include/asm-generic/pgtable.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
index 069536a..cd9e7c4 100644
--- a/include/asm-generic/pgtable.h
+++ b/include/asm-generic/pgtable.h
@@ -306,11 +306,11 @@ static inline int pmd_same(pmd_t pmd_a, pmd_t pmd_b)
static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
{
if (pgprot_val(oldprot) == pgprot_val(pgprot_noncached(oldprot)))
- newprot = pgprot_noncached(newprot);
+ return pgprot_noncached(newprot);
if (pgprot_val(oldprot) == pgprot_val(pgprot_writecombine(oldprot)))
- newprot = pgprot_writecombine(newprot);
+ return pgprot_writecombine(newprot);
if (pgprot_val(oldprot) == pgprot_val(pgprot_device(oldprot)))
- newprot = pgprot_device(newprot);
+ return pgprot_device(newprot);
return newprot;
}
#endif
--
1.9.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Chen Gang <chengang@emindsoft.com.cn> |
|---|---|
| Date | 2015-12-13 16:50 +0100 |
| Subject | Re: [PATCH] include/asm-generic/pgtable.h: Check once and return for pgprot_modify |
| Message-ID | <qFh4l-1L3-5@gated-at.bofh.it> |
| In reply to | #1290589 |
Oh, after check again, it looks my original comments are not precise:
they check oldprot, but set newprot.
After check pgprot_noncached, pgprot_writecombine, and pgprot_device
again, for me, if still in order: 1st noncached, 2nd writecombine, 3rd
device, we can still treate them exclusive with each other:
- For pgprot_device, Only amd64 redefine it, which is exclusive with
the others (or the precisely same as one of the others).
- For pgprot_writecombine, except metag and x86, all the other archs
are exclusive with (or same as) pgprot_noncached.
for metag arch, pgprot_writecombine is the part of pgprot_noncached.
for x86 arch, it has its own pgprot_modify.
Thanks.
On 12/13/15 17:12, Chen Gang wrote:
>
> pgprot_val() likes an empty operation, and all three checking statements
> are related with oldprot, so only check once is enough, the reason is:
>
> - if both "oldprot == pgprot_noncached(oldprot)" and "oldprot ==
> pgprot_writecombine(oldprot)" are satisfied.
>
> - So "pgprot_noncached(oldprot) == pgprot_writecombine(oldprot)", too.
>
> - So as the result, it is still equal to check once (for pgprot_device
> can get the same result).
>
> Then can return directly.
>
> Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
> ---
> include/asm-generic/pgtable.h | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
> index 069536a..cd9e7c4 100644
> --- a/include/asm-generic/pgtable.h
> +++ b/include/asm-generic/pgtable.h
> @@ -306,11 +306,11 @@ static inline int pmd_same(pmd_t pmd_a, pmd_t pmd_b)
> static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
> {
> if (pgprot_val(oldprot) == pgprot_val(pgprot_noncached(oldprot)))
> - newprot = pgprot_noncached(newprot);
> + return pgprot_noncached(newprot);
> if (pgprot_val(oldprot) == pgprot_val(pgprot_writecombine(oldprot)))
> - newprot = pgprot_writecombine(newprot);
> + return pgprot_writecombine(newprot);
> if (pgprot_val(oldprot) == pgprot_val(pgprot_device(oldprot)))
> - newprot = pgprot_device(newprot);
> + return pgprot_device(newprot);
> return newprot;
> }
> #endif
>
--
Chen Gang (陈刚)
Open, share, and attitude like air, water, and life which God blessed
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web