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 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 395C0C433F5 for ; Mon, 7 Mar 2022 11:13:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A1E0D10F64E; Mon, 7 Mar 2022 11:13:18 +0000 (UTC) Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by gabe.freedesktop.org (Postfix) with ESMTPS id A439B10E229; Sun, 6 Mar 2022 04:12:05 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 3FAD8B80B52; Sun, 6 Mar 2022 04:12:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7D11DC340EF; Sun, 6 Mar 2022 04:12:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1646539922; bh=Qq7CIqw/wyoNGqP8SxKCADK3EiMnqFZiz0Fy3Y+3lI4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=dChxswxCVJWoQTWcJUnuMIlYUbzfRbQW+eLId9/Ei0rHOIrcrbjcXm/220WNeg06J RJSF/JqGVMgJHgTfiHNK2RdJgtuL1oOzDROr+1RBVmy23C/R4Q5soWU18mTaVTuYbx RxhEsAShP8lWIyrYhxtwmWYQWrgTIefRVR1iSIh5+gSp0JetS7+9tqkhX219cJxnM3 1p/tS5jnPbQDScKHexmgcMK7qz5OyRTw4wTvpR6qWMpAbIsV1y7AlMbPNV/rLsKwqc KEdDBDvuqvOoKbhTfoYuFyF5GiKzZ325omdd6KQ05ZiG+sFsHZ5JPQE1M75KOw85rU s1B3+qZ+VarQg== Date: Sun, 6 Mar 2022 06:11:21 +0200 From: Jarkko Sakkinen To: Matthew Wilcox Message-ID: References: <20220306021534.83553-1-jarkko@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Mailman-Approved-At: Mon, 07 Mar 2022 11:13:15 +0000 Subject: Re: [Intel-gfx] [PATCH RFC] mm: Add f_ops->populate() X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nathaniel McCallum , linux-unionfs@vger.kernel.org, intel-gfx@lists.freedesktop.org, Dave Hansen , linux-mips@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Andrew Morton , Reinette Chatre , codalist@coda.cs.cmu.edu, linux-sgx@vger.kernel.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" On Sun, Mar 06, 2022 at 03:52:12AM +0000, Matthew Wilcox wrote: > On Sun, Mar 06, 2022 at 05:21:11AM +0200, Jarkko Sakkinen wrote: > > On Sun, Mar 06, 2022 at 02:57:55AM +0000, Matthew Wilcox wrote: > > > On Sun, Mar 06, 2022 at 04:15:33AM +0200, Jarkko Sakkinen wrote: > > > > Sometimes you might want to use MAP_POPULATE to ask a device driver to > > > > initialize the device memory in some specific manner. SGX driver can use > > > > this to request more memory by issuing ENCLS[EAUG] x86 opcode for each > > > > page in the address range. > > > > > > > > Add f_ops->populate() with the same parameters as f_ops->mmap() and make > > > > it conditionally called inside call_mmap(). Update call sites > > > > accodingly. > > > > > > Your device driver has a ->mmap operation. Why does it need another > > > one? More explanation required here. > > > > f_ops->mmap() would require an additional parameter, which results > > heavy refactoring. > > > > struct file_operations has 1125 references in the kernel tree, so I > > decided to check this way around first. > > Are you saying that your device driver behaves differently if > MAP_POPULATE is set versus if it isn't? That seems hideously broken. MAP_POPULATE does not do anything (according to __mm_populate in mm/gup.c) with VMA's that have some sort of device/IO memory, i.e. vm_flags intersecting with VM_PFNMAP | VM_IO. I can extend the guard obviously to: if (!ret && do_populate && file->f_op->populate && !!(vma->vm_flags & (VM_IO | VM_PFNMAP))) file->f_op->populate(file, vma); BR, Jarkko