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=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS 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 C70D9C43217 for ; Wed, 23 Dec 2020 08:14:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 93AC9224BE for ; Wed, 23 Dec 2020 08:14:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728078AbgLWIOX (ORCPT ); Wed, 23 Dec 2020 03:14:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727838AbgLWIOW (ORCPT ); Wed, 23 Dec 2020 03:14:22 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A401C0613D6; Wed, 23 Dec 2020 00:13:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=9mT6ehxNEt1jUz3TfJecdTTXQ2Ih2qfV3QTcUD44O04=; b=JPB0a4t7K8WEKPQv3hVXh7yGzq 9wAt2jVARSqPuaCHW+1jygDtQ11enIvosGCFjiLDVmuSCI8gUnDAxJtkTlAzV5L94gaz7Nlurb6om yHj7+cinD8X0Hx0hjLaW/sFbtlTe5TqGuH4hTiPGacWQ8228r7/V1ZR7RvvW/gervcVRB6cU7hP9j 8Ye+VK76pyC3CaL4DQ/AVEiAzsuPUIrmQTmCmkIqWzDKIiHn5tTplGa0VeBlmQNf2yjzl2DdKFAXy p/0B807UKBAiXZohjVUCLoOmCQL5L6j1HusyL4nlAeQapxfq2STMvgRXEPAa76V5nNERvvE7Y7T2U AR6qBiNQ==; Received: from hch by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1krzGu-0005kz-5Q; Wed, 23 Dec 2020 08:13:24 +0000 Date: Wed, 23 Dec 2020 08:13:24 +0000 From: Christoph Hellwig To: Yongji Xie Cc: Christoph Hellwig , "Michael S. Tsirkin" , Jason Wang , Stefan Hajnoczi , sgarzare@redhat.com, Parav Pandit , akpm@linux-foundation.org, Randy Dunlap , Matthew Wilcox , viro@zeniv.linux.org.uk, axboe@kernel.dk, bcrl@kvack.org, corbet@lwn.net, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, kvm@vger.kernel.org, linux-aio@kvack.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [RFC v2 01/13] mm: export zap_page_range() for driver use Message-ID: <20201223081324.GA21558@infradead.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Wed, Dec 23, 2020 at 02:32:07PM +0800, Yongji Xie wrote: > Now I want to map/unmap some pages in an userland vma dynamically. The > vm_insert_page() is being used for mapping. In the unmapping case, it > looks like the zap_page_range() does what I want. So I export it. > Otherwise, we need some ways to notify userspace to trigger it with > madvise(MADV_DONTNEED), which might not be able to meet all our needs. > For example, unmapping some pages in a memory shrinker function. > > So I'd like to know what's the limitation to use zap_page_range() in a > module. And if we can't use it in a module, is there any acceptable > way to achieve that? I think the anser is: don't play funny games with unmapped outside of munmap. Especially as synchronization is very hard to get right.