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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2D2B4C433F5 for ; Sun, 6 Mar 2022 04:26:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B64516B0071; Sat, 5 Mar 2022 23:26:38 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B13646B0072; Sat, 5 Mar 2022 23:26:38 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9DB916B0073; Sat, 5 Mar 2022 23:26:38 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0179.hostedemail.com [216.40.44.179]) by kanga.kvack.org (Postfix) with ESMTP id 8E2BB6B0071 for ; Sat, 5 Mar 2022 23:26:38 -0500 (EST) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 333608249980 for ; Sun, 6 Mar 2022 04:26:38 +0000 (UTC) X-FDA: 79212675276.26.F58E3E7 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf16.hostedemail.com (Postfix) with ESMTP id A7CA4180003 for ; Sun, 6 Mar 2022 04:26:37 +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 CFBA7B80CA5; Sun, 6 Mar 2022 04:26:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A59AC340EF; Sun, 6 Mar 2022 04:26:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1646540794; bh=0JU4U5+lOyIAdCnvSBFHtdXzenPHV8wshAXmaTDzyec=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=enYPYnhKNbQlGCuV9rgRWqwOZoAA2/26Pz1a1vQsn0dcwm0e7qQPAuiiY2aZa7UVz 8cDgv3TRivJP53dbTwDKRp/INFtVtTyBcFDsRfqyeQOWYlbNRFC5ZfECwydfiL3Fim SoL64RSWI/Bl0LUYpfWZ8NwrH4mco1sI8MJeRAxdqVYOWifM/pz21xXm607B8FMxuo gcy5ANlRYV2HeBFrmP15CJtH4vIXv+C1hKT6qAMtqDnXgqigiGroyxudYT9rqm7vTs Pfs7Ul86sEebvwI101HAVbOty5rPj/mvEXXDoOEnk6WPImCBA9+CkqPHxse1O0ONvE 6Q37wbuuZ5B0A== Date: Sun, 6 Mar 2022 06:25:52 +0200 From: Jarkko Sakkinen To: Matthew Wilcox Cc: Andrew Morton , Dave Hansen , Nathaniel McCallum , Reinette Chatre , linux-sgx@vger.kernel.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, codalist@coda.cs.cmu.edu, linux-unionfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH RFC] mm: Add f_ops->populate() 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-Rspamd-Queue-Id: A7CA4180003 X-Stat-Signature: n9x3jtuurhdzdkfauu1jddfg1f15ry4f X-Rspam-User: Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=enYPYnhK; spf=pass (imf16.hostedemail.com: domain of jarkko@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=jarkko@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Rspamd-Server: rspam07 X-HE-Tag: 1646540797-20853 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 Sun, Mar 06, 2022 at 04:19:26AM +0000, Matthew Wilcox wrote: > On Sun, Mar 06, 2022 at 06:11:21AM +0200, Jarkko Sakkinen wrote: > > 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); > > Are you deliberately avoiding the question? I'm not asking about > implementation. I'm asking about the semantics of MAP_POPULATE with > your driver. No. I just noticed a bug in the guard from your comment that I wanted point out. With the next version I post the corresponding change to the driver, in order to see this in context. BR, Jarkko