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: <CAJd=RBBa-ZoZ3GhYQ-aM=TJ9Zw6ZSu177PWw+s8+zyFnzyUV_w@mail.gmail.com>
Date:	Mon, 21 Nov 2011 21:47:22 +0800
From:	Hillf Danton <dhillf@...il.com>
To:	Hugh Dickins <hughd@...gle.com>
Cc:	Michel Lespinasse <walken@...gle.com>,
	Andrea Arcangeli <aarcange@...hat.com>,
	Andrew Morton <akpm@...ux-foundation.org>, linux-mm@...ck.org,
	LKML <linux-kernel@...r.kernel.org>,
	Michal Hocko <mhocko@...e.cz>
Subject: Re: [PATCH] ksm: use FAULT_FLAG_ALLOW_RETRY in breaking COW

On Mon, Nov 21, 2011 at 12:16 PM, Hugh Dickins <hughd@...gle.com> wrote:
> On Sat, 19 Nov 2011, Hillf Danton wrote:
>
>> The flag, FAULT_FLAG_ALLOW_RETRY, was introduced by the patch,
>>
>>       mm: retry page fault when blocking on disk transfer
>>       commit: d065bd810b6deb67d4897a14bfe21f8eb526ba99
>>
>> for reducing mmap_sem hold times that are caused by waiting for disk
>> transfers when accessing file mapped VMAs.
>>
>> To break COW, handle_mm_fault() is repeated with mmap_sem held, where
>> the introduced flag could be used again.
>>
>> The straight way is to add changes in break_ksm(), but the function could be
>> under write-mode mmap_sem, so it has to be dupilcated.
>>
>> Signed-off-by: Hillf Danton <dhillf@...il.com>
>
> Thank you for making the patch; but unless I'm mistaken - please
> correct me if so - I think it's better to keep break_cow() simple
> than add special FAULT_FLAG_ALLOW_RETRY handling there.  Do you
> have any evidence that its down_read of mmap_sem is a problem in
> some workload?  I sense that you're using it "because it's there".
>
> I'm sceptical on several grounds.
>
> One, break_cow() is itself only called on an "error" path: not
> really an error, but when KSM's bet that it can merge pages turns
> out to be wrong before it can complete the merge; not a rare case,
> but not on the hot path.
>
> Two, break_ksm()'s loop is required for correctness, but it
> is a rare case that it actually needs to go round a second time.
> The typical case it's needed (am I forgetting a more common one?)
> is when userspace access flips a pte bit in between handle_pte_fault()
> noting faulting pte, and the chosen fault handler checking pte_same()
> before committing to its action.  With the page marked PageKsm, yet
> not in the stable tree, even page reclaim is unable to interfere.
>
> Three, FAULT_FLAG_ALLOW_RETRY is acted upon only in lock_page_or_retry(),
> which is called only from filemap_fault() (not the case here since we
> don't consider file pages for conversion to PageKsm) or do_swap_page();
> yet the fault we're provoking would be handled by do_wp_page().
>
> Four, lock_page_or_retry() is called in those places when there's a
> possibility that the page is being read in from disk, to drop the
> mmap_sem across the slow I/O.  There is no precedent for dropping
> mmap_sem here while allocating a new page, nor when pte_same() fails:
> in the former case it could only be a win when the system is already
> slowed by memory pressure, in the latter case there's little point,
> since mmap_sem would be reacquired in a moment.
>
> I think that amounts to a genial Nack!
>
Hello Hugh,

After reading your reply and the comments in break_ksm(), if the patch does
not mess up
	"The important thing is to not let VM_MERGEABLE be cleared while any
	 such pages might remain in the area",
and
	"because handle_mm_fault() may back out if there's
	 any difficulty e.g. if pte accessed bit gets updated concurrently",

then if the path in which lock_page_or_retry() is called is not involved,
mmap_sem is not upped, so the patch has nearly same behavior with break_ksm.

And the overhead of the patch, I think, could match break_ksm.

With dozen cases of writers of mmap_sem in the mm directory, the patch looks
more flexible in rare and rare corners.

Best regards
Hillf
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ