Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp143890pxa; Fri, 21 Aug 2020 03:40:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZxF2zWnz85Ed/4ETo4fhFoPfCuofIng/rfD75w744y/jowSl1rDlNpE6oUPCmmvD17tL8 X-Received: by 2002:a50:a69a:: with SMTP id e26mr2114748edc.260.1598006429461; Fri, 21 Aug 2020 03:40:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598006429; cv=none; d=google.com; s=arc-20160816; b=MZtneAY0T+6gaAE7DNAqn/FyuczgzC2RLnXqkqN9rWuWcLOgD/Br65RUCx4oqb59cW R/INFl5lqUBamQ0il3iscDUous6hDxKBaeefTF9DaXYjDK9bQCt8Dxdq3c+++Xkwxkqp gfP+oqdyfjA/HPENnw8YZB/ECOc89C3JGO6FPOhY6K0Gy2/SY25CMpDQm9PckUoWS11R uN5GYr31hf+/cRwQ/7LtqaBltqsEra3iTZm7jrDI4izayyQanCM+0qyotDTjHe6Sl2w0 6BPvH+uXTrxSsRuf6veVDZnFGxGtIvJWDRi5yRDAmr/IFq53KSZLd6PaUIQ9URSfMxFm txjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:date:to:cc:from :subject:references:in-reply-to:content-transfer-encoding :mime-version; bh=RQ0W8Euvkh0GCZFfxDEEZhiyKWcR2V45D76VJf+1QK4=; b=YSnLIMa7MQweMEMf3v2Z9N2l6ROTGxFP7nFE5yQbtYI22rJXbPUVwBj9aPRTmgB49M rRb8U8LrXT9tnYX7KBMtwQEGXSqcoqw7ZTDGTxMiPy8uAqKpCKVfaPcR1qBYOJAiOTCU gF2XCiyz0m0d8adiVyvSKynIK9mFUwHafLKyj99yawjLoPpYIHjQofARPvVCqtkXCr0R YlLqUIDK3/PHYtTFuIBje1oLfsUGun97ZUIWxnyalRaS55mf2hHnBafvfgdircWwrJQD 1SxVjxKqhkNRyX0TgBXjuj2LC7bKX84vawCeAOBLrkxlh0sxinG+shhrbQW3uOMqDD8z zdww== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i19si870741edr.523.2020.08.21.03.40.06; Fri, 21 Aug 2020 03:40:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728595AbgHUKgn convert rfc822-to-8bit (ORCPT + 99 others); Fri, 21 Aug 2020 06:36:43 -0400 Received: from mail.fireflyinternet.com ([77.68.26.236]:58620 "EHLO fireflyinternet.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728428AbgHUKgR (ORCPT ); Fri, 21 Aug 2020 06:36:17 -0400 X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from localhost (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP (TLS) id 22196525-1500050 for multiple; Fri, 21 Aug 2020 11:36:09 +0100 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8BIT In-Reply-To: <20200821102204.GH3354@suse.de> References: <20200821085011.28878-1-chris@chris-wilson.co.uk> <20200821095129.GF3354@suse.de> <159800366215.29194.8455636122843151159@build.alporthouse.com> <20200821102204.GH3354@suse.de> Subject: Re: [PATCH 1/4] mm: Export flush_vm_area() to sync the PTEs upon construction From: Chris Wilson Cc: linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-mm@kvack.org, Pavel Machek , Andrew Morton , Linus Torvalds , Dave Airlie , Joonas Lahtinen , Rodrigo Vivi , David Vrabel , stable@vger.kernel.org To: Joerg Roedel Date: Fri, 21 Aug 2020 11:36:07 +0100 Message-ID: <159800616716.29194.8354000222129735639@build.alporthouse.com> User-Agent: alot/0.9 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Joerg Roedel (2020-08-21 11:22:04) > On Fri, Aug 21, 2020 at 10:54:22AM +0100, Chris Wilson wrote: > > Ok. I thought it had to be after assigning the *ptep. If we apply the > > sync first, do not have to worry about PGTBL_PTE_MODIFIED from the > > *ptep? > > Hmm, if I understand the code correctly, you are re-implementing some > generic ioremap/vmalloc mapping logic in the i915 driver. I don't know > the reason, but if it is valid you need to manually call > arch_sync_kernel_mappings() from your driver like this to be correct: > > if (ARCH_PAGE_TABLE_SYNC_MASK & PGTBL_PTE_MODIFIED) > arch_sync_kernel_mappings(); > > In practice this is a no-op, because nobody sets PGTBL_PTE_MODIFIED in > ARCH_PAGE_TABLE_SYNC_MASK, so the above code would be optimized away. > > But what you really care about is the tracking in apply_to_page_range(), > as that allocates the !pte levels of your page-table, which needs > synchronization on x86-32. > > Btw, what are the reasons you can't use generic vmalloc/ioremap > interfaces to map the range? ioremap_prot and ioremap_page_range assume a contiguous IO address. So we needed to allocate the vmalloc area [and would then need to iterate over the discontiguous iomem chunks with ioremap_page_range], and since alloc_vm_area returned the ptep, it looked clearer to then assign those according to whether we wanted ioremapping or a plain page. So we ended up with one call to the core to return us a vm_struct and a pte array that worked for either backing store. -Chris