All of lore.kernel.org
 help / color / mirror / Atom feed
From: will.deacon@arm.com (Will Deacon)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH V4 1/2] arm: mm: Introduce {pte,pmd}_isset and {pte,pmd}_isclear
Date: Fri, 20 Jun 2014 10:12:26 +0100	[thread overview]
Message-ID: <20140620091226.GJ25104@arm.com> (raw)
In-Reply-To: <1402929159-11028-2-git-send-email-steve.capper@linaro.org>

On Mon, Jun 16, 2014 at 03:32:38PM +0100, Steve Capper wrote:
> Long descriptors on ARM are 64 bits, and some pte functions such as
> pte_dirty return a bitwise-and of a flag with the pte value. If the
> flag to be tested resides in the upper 32 bits of the pte, then we run
> into the danger of the result being dropped if downcast.
> 
> For example:
> 	gather_stats(page, md, pte_dirty(*pte), 1);
> where pte_dirty(*pte) is downcast to an int.
> 
> This patch introduces a new macro pte_isset which performs the bitwise
> and, then performs a double logical invert (where needed) to ensure
> predictable downcasting. The logical inverse pte_isclear is also
> introduced.
> 
> Equivalent pmd functions for Transparent HugePages have also been
> added.
> 
> Signed-off-by: Steve Capper <steve.capper@linaro.org>
> ---
>  arch/arm/include/asm/pgtable-3level.h | 10 +++++++---
>  arch/arm/include/asm/pgtable.h        | 18 +++++++++++-------
>  2 files changed, 18 insertions(+), 10 deletions(-)
> 
> diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
> index 85c60ad..bde49f9 100644
> --- a/arch/arm/include/asm/pgtable-3level.h
> +++ b/arch/arm/include/asm/pgtable-3level.h
> @@ -207,16 +207,20 @@ static inline pmd_t *pmd_offset(pud_t *pud, unsigned long addr)
>  #define pte_huge(pte)		(pte_val(pte) && !(pte_val(pte) & PTE_TABLE_BIT))
>  #define pte_mkhuge(pte)		(__pte(pte_val(pte) & ~PTE_TABLE_BIT))
>  
> -#define pmd_young(pmd)		(pmd_val(pmd) & PMD_SECT_AF)
> +#define pmd_isset(pmd, val)	((u32)(val) == (val) ? pmd_val(pmd) & (val) \
> +						: !!(pmd_val(pmd) & (val)))

What does GCC generate for this as opposed to an unconditional !!?

Will

  reply	other threads:[~2014-06-20  9:12 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-16 14:32 [PATCH V4 0/2] PTE fixes for ARM LPAE Steve Capper
2014-06-16 14:32 ` [PATCH V4 1/2] arm: mm: Introduce {pte, pmd}_isset and {pte, pmd}_isclear Steve Capper
2014-06-20  9:12   ` Will Deacon [this message]
2014-06-20 10:04     ` [PATCH V4 1/2] arm: mm: Introduce {pte,pmd}_isset and {pte,pmd}_isclear Russell King - ARM Linux
2014-06-16 14:32 ` [PATCH V4 2/2] arm: mm: Switch back to L_PTE_WRITE Steve Capper
2014-06-20  9:21   ` Will Deacon
2014-06-20 13:23     ` Steve Capper
2014-06-20 18:17   ` Russell King - ARM Linux
2014-06-23 11:17     ` Catalin Marinas
2014-06-23 15:07     ` Steve Capper

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=20140620091226.GJ25104@arm.com \
    --to=will.deacon@arm.com \
    --cc=linux-arm-kernel@lists.infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.