From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.0 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6E34C352AB for ; Fri, 27 Sep 2019 09:27:14 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 60D1F217D9 for ; Fri, 27 Sep 2019 09:27:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=shipmail.org header.i=@shipmail.org header.b="aVVJqjzH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 60D1F217D9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=shipmail.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B60F18E0005; Fri, 27 Sep 2019 05:27:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B10228E0001; Fri, 27 Sep 2019 05:27:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9FEE88E0005; Fri, 27 Sep 2019 05:27:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 79FB18E0001 for ; Fri, 27 Sep 2019 05:27:13 -0400 (EDT) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with SMTP id 22011ABEA for ; Fri, 27 Sep 2019 09:27:13 +0000 (UTC) X-FDA: 75980171946.02.smell78_3ebe35d472a38 X-HE-Tag: smell78_3ebe35d472a38 X-Filterd-Recvd-Size: 6509 Received: from pio-pvt-msa3.bahnhof.se (pio-pvt-msa3.bahnhof.se [79.136.2.42]) by imf33.hostedemail.com (Postfix) with ESMTP for ; Fri, 27 Sep 2019 09:27:11 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by pio-pvt-msa3.bahnhof.se (Postfix) with ESMTP id 85F7E3F4B6; Fri, 27 Sep 2019 11:27:09 +0200 (CEST) Authentication-Results: pio-pvt-msa3.bahnhof.se; dkim=pass (1024-bit key; unprotected) header.d=shipmail.org header.i=@shipmail.org header.b=aVVJqjzH; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at bahnhof.se Received: from pio-pvt-msa3.bahnhof.se ([127.0.0.1]) by localhost (pio-pvt-msa3.bahnhof.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bnsC5UR0WgFA; Fri, 27 Sep 2019 11:27:08 +0200 (CEST) Received: from mail1.shipmail.org (h-205-35.A357.priv.bahnhof.se [155.4.205.35]) (Authenticated sender: mb878879) by pio-pvt-msa3.bahnhof.se (Postfix) with ESMTPA id 98AE13F36B; Fri, 27 Sep 2019 11:27:07 +0200 (CEST) Received: from localhost.localdomain (h-205-35.A357.priv.bahnhof.se [155.4.205.35]) by mail1.shipmail.org (Postfix) with ESMTPSA id 0FDA53600A4; Fri, 27 Sep 2019 11:27:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=shipmail.org; s=mail; t=1569576427; bh=XRuI+mdK64UN9f0IeE6ubS+3LhYSwvzPKVNTt/eWvTo=; h=Subject:From:To:Cc:References:Date:In-Reply-To:From; b=aVVJqjzHaKb9eBsNDILfQZF2R14j+nRA+RRDjqzGB9Ej0EE7hrJHuKL3+ulcpRIfB XjiX9tOA6tJtNW2ryPe5tnZqjd+uax5e5edCN+eNbz3Y8EwMEviyf+l3tCW3su16IG NXyLR9s7+TVF4PZqCiB99XcOuPUXLkpPjgp/DvMk= Subject: Re: Ack to merge through DRM? WAS Re: [PATCH v2 1/5] mm: Add write-protect and clean utilities for address space ranges From: =?UTF-8?Q?Thomas_Hellstr=c3=b6m_=28VMware=29?= To: Linus Torvalds Cc: Linux Kernel Mailing List , dri-devel , Linux-MM , Andrew Morton , Matthew Wilcox References: <20190926115548.44000-1-thomas_os@shipmail.org> <20190926115548.44000-2-thomas_os@shipmail.org> <85e31bcf-d3c8-2fcf-e659-2c9f82ebedc7@shipmail.org> Organization: VMware Inc. Message-ID: Date: Fri, 27 Sep 2019 11:27:06 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 9/27/19 7:55 AM, Thomas Hellstr=C3=B6m (VMware) wrote: > On 9/27/19 12:20 AM, Linus Torvalds wrote: >> On Thu, Sep 26, 2019 at 1:55 PM Thomas Hellstr=C3=B6m (VMware) >> wrote: >>> Well, we're working on supporting huge puds and pmds in the graphics >>> VMAs, although in the write-notify cases we're looking at here, we=20 >>> would >>> probably want to split them down to PTE level. >> Well, that's what the existing walker code does if you don't have that >> "pud_entry()" callback. >> >> That said, I assume you would *not* want to do that if the huge >> pud/pmd is already clean and read-only, but just continue. >> >> So you may want to have a special pud_entry() that handles that case. >> Eventually. Maybe. Although honestly, if you're doing dirty tracking, >> I doubt it makes much sense to use largepages. > > The approach we're looking at in this case is to keep huge entries=20 > write-protected and split them in the wp_huge_xxx() code's fallback=20 > path with the mmap_sem held. This means that there will actually be=20 > huge entries in the page-walking code soon, but as you say, only=20 > entries that we want to ignore and not split. So we'd also need a way=20 > to avoid the pagewalk splitting for the situation when someone faults=20 > a huge entry in just before the call to split_huge_xxx. > >> >>> Looking at zap_pud_range() which when called from unmap_mapping_pages= () >>> uses identical locking (no mmap_sem), it seems we should be able to g= et >>> away with i_mmap_lock(), making sure the whole page table doesn't >>> disappear under us. So it's not clear to me why the mmap_sem is=20 >>> strictly >>> needed here. Better to sort those restrictions out now rather than wh= en >>> huge entries start appearing. >> zap_pud_range()actually does have that >> >> VM_BUG_ON_VMA(!rwsem_is_locked(&tlb->mm->mmap_sem), vma); >> >> exactly for the case where it might have to split the pud entry. > > Yes. My take on this is that locking the PUD ptl can be done either=20 > with the mmap_sem or the i_mmap_lock if present and that we should=20 > update the asserts in xxx_trans_huge_lock to reflect that. But when=20 > actually splitting transhuge pages you don't want to race with=20 > khugepaged, so you need the mmap_sem. For the graphics VMAs=20 > (MIXEDMAP), khugepaged never touches them. Yet. > >> >> It's why they've never gotten translated to use the generic walker cod= e. > > OK. Yes there are a number of various specialized pagewalks all over=20 > the mm code. > > But another thing that worries me is that the page-table modifications=20 > that happen in the callback use functionality that is not guaranteed=20 > to be exported, and that mm people don't want them to be exported=20 > because you don't want the drivers to go hacking around in page=20 > tables, which means that the two callbacks used here would need to be=20 > a set of core helpers anyway. > > So I figure what I would end up with would actually be an extern=20 > __walk_page_range anyway, and slightly modified asserts. Do you think=20 > that could be acceptible? Actually, I'll give your original suggestion a try and see what I come=20 up with. Thanks, Thomas