lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.DEB.2.22.394.2006301401560.1512657@chino.kir.corp.google.com>
Date:   Tue, 30 Jun 2020 14:05:24 -0700 (PDT)
From:   David Rientjes <rientjes@...gle.com>
To:     Peter Xu <peterx@...hat.com>
cc:     linux-mm@...ck.org, linux-kernel@...r.kernel.org,
        Andrew Morton <akpm@...ux-foundation.org>,
        John Hubbard <jhubbard@...dia.com>,
        Michael Ellerman <mpe@...erman.id.au>,
        Gerald Schaefer <gerald.schaefer@...ibm.com>,
        Andrea Arcangeli <aarcange@...hat.com>,
        Linus Torvalds <torvalds@...ux-foundation.org>,
        Will Deacon <will@...nel.org>
Subject: Re: [PATCH v4 01/26] mm: Do page fault accounting in
 handle_mm_fault

On Tue, 30 Jun 2020, Peter Xu wrote:

> @@ -4408,6 +4440,34 @@ vm_fault_t handle_mm_fault(struct vm_area_struct *vma, unsigned long address,
>  			mem_cgroup_oom_synchronize(false);
>  	}
>  
> +	if (ret & (VM_FAULT_RETRY | VM_FAULT_ERROR))
> +		return ret;
> +
> +	/*
> +	 * Do accounting in the common code, to avoid unnecessary
> +	 * architecture differences or duplicated code.
> +	 *
> +	 * We arbitrarily make the rules be:
> +	 *
> +	 *  - Unsuccessful faults do not count (e.g. when the address wasn't
> +	 *    valid). That includes arch_vma_access_permitted() failing above.
> +	 *
> +	 *    So this is expressly not a "this many hardware page faults"
> +	 *    counter. Use the hw profiling for that.
> +	 *
> +	 *  - Incomplete faults do not count (e.g. RETRY).  They will only
> +	 *    count once completed.
> +	 *
> +	 *  - The fault counts as a "major" fault when the final successful
> +	 *    fault is VM_FAULT_MAJOR, or if it was a retry (which implies that
> +	 *    we couldn't handle it immediately previously).
> +	 *
> +	 *  - If the fault is done for GUP, regs will be NULL and no accounting
> +	 *    will be done.
> +	 */
> +	mm_account_fault(regs, address, (ret & VM_FAULT_MAJOR) ||
> +			 (flags & FAULT_FLAG_TRIED));
> +
>  	return ret;
>  }
>  EXPORT_SYMBOL_GPL(handle_mm_fault);

Just a nit, likely not important: I wonder if it would be cleaner to pass 
the vm_fault_t into mm_account_fault() and then do the VM_FAULT_RETRY and
VM_FAULT_ERROR checks there as well as putting the comment about how 
accounting is handled in that function.  Your comment is great.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ