Re: [RFC patch 7/7] thp, s390: architecture backend for thp on System z

Heiko Carstens
2012-08-24T08:07:13Z

On Thu, Aug 23, 2012 at 07:17:40PM +0200, Gerald Schaefer wrote:
> +#define __HAVE_ARCH_PMDP_TEST_AND_CLEAR_YOUNG
> +static inline int pmdp_test_and_clear_young(struct vm_area_struct *vma,
> + unsigned long address,
> + pmd_t *pmdp)
> +{
> + int rc = 0;
> + int counter = PTRS_PER_PTE;
> + unsigned long pmd_addr = pmd_val(*pmdp) & HPAGE_MASK;
> +
> + asm volatile(
> + "0: rrbe 0,%2\n"
> + " la %2,0(%3,%2)\n"
> + " brc 12,1f\n"
> + " lhi %0,1\n"
> + "1: brct %1,0b\n"
> + : "+d" (rc), "+d" (counter), "+a" (pmd_addr)
> + : "a" (4096UL): "cc" );
> + return rc;
> +}

Just a small side note: given that rrbe is very expensive you probably
should extend this function so it makes use of the rrbm instruction
if available.