Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp699952rwb; Tue, 29 Nov 2022 04:21:56 -0800 (PST) X-Google-Smtp-Source: AA0mqf72xcsobllt4JMTs1nKWxpDLdAXlmqAQ2MwGdxTlkk9Yuv5rp2F6XA/bKMkZWHP4i8g1uoa X-Received: by 2002:a17:90a:f305:b0:20c:9d98:13f4 with SMTP id ca5-20020a17090af30500b0020c9d9813f4mr58239013pjb.87.1669724516770; Tue, 29 Nov 2022 04:21:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669724516; cv=none; d=google.com; s=arc-20160816; b=NU2hb4C6+AmpcGDNgO9vdo+VRJIKfBvRpjh7pdP4k9KQagO3IC5+ELvqJX4QP830Sq SUFLKSpb+IzxcRn3OXmY53+v5tMfQg8W8JQ0X1jfqVqDhRTO0Rb0jQsg/GKOqWLVqTH2 ptsd0POAwZUBVkZr+snTp/XaMYKuwous+QLCVoZPIVQgpgAnItgzYdCRqs7fJ2USsJAA i01Ph3/9AR8shed6EO5lABNPR9iu7o9zBx1NoQLPTKotVbIjHxsGMJaje5cpoBQ58KvC N1FKjIFv+AJHO5N7lTJfeRar0+riya5r0iEg7TXV6vyHkKBD/qC9FJu3p0uR23+SF11X 37BA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=eRu/Hx0QeU09vI6dag4oeFynexJuKZWNYSe4MiEdyGs=; b=AvlNG9h5e3JVh7hzPb7Z4fbtwC2JWPbvnyYy4OB3cWEluAavIf/6dvCwQYGI7Y+v+8 nFvftxjRO6reAKw+J3wv+2LssyF4FiVvi6K7PARmHn+0c9DH5OwiOXtW2ndWkN+YEvjs eDF2SVsRWpuisyqu9W8sFUr7MsUj8Oqa1Zaw5a3gLXNF9nf59NoO1luKZH8NNhRUEN7T TmxcSqK2O9N8nfDVzSXq2sJ+dewJkjF99s404hwV3gPCt3UmgFVkN9M4VQA1ctlEvjx4 g9ljgC2+qPT2GyX0jOj8Doy3yKypjWxOO4qCsmZhUx43Npbr+rebXxwAZiGJ2ddv0J7g ENkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DY1pFbkU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jc6-20020a17090325c600b0018989a041dfsi5388334plb.124.2022.11.29.04.21.45; Tue, 29 Nov 2022 04:21:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DY1pFbkU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230312AbiK2LkJ (ORCPT + 83 others); Tue, 29 Nov 2022 06:40:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229768AbiK2LkG (ORCPT ); Tue, 29 Nov 2022 06:40:06 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D10E165A6 for ; Tue, 29 Nov 2022 03:39:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669721951; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eRu/Hx0QeU09vI6dag4oeFynexJuKZWNYSe4MiEdyGs=; b=DY1pFbkUM1MIGvkYmEzktWFDEJKIDajUf044NWj1aFCx6VfR3SCLfpmRCKjsnEYsub5Awe QCfsxMM/j3ywnZurS9Qcb/sD9qqH41O+7AG53X/WBLMdI0vxZSJrISQFnIy14Yy+oxZprj M77lSprXFA5jMIqYUDPGM/sCTQWturo= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-620-xHse0vmFMIqVXpegWQ_1qg-1; Tue, 29 Nov 2022 06:39:10 -0500 X-MC-Unique: xHse0vmFMIqVXpegWQ_1qg-1 Received: by mail-wm1-f72.google.com with SMTP id u9-20020a05600c00c900b003cfb12839d6so4622811wmm.5 for ; Tue, 29 Nov 2022 03:39:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=eRu/Hx0QeU09vI6dag4oeFynexJuKZWNYSe4MiEdyGs=; b=jHufnb/f3wJni/X5gQN3lI8ufshg3GMgglcRu2WPn+a8azDff4052zjxkqfYSZCiHz 2Flkum978+KgTjwF7Wa9bVqE1Fi/cvswvqb1AJHEKp41LvH+oVyCI1MgIMx0VIIhE6FN s69WqAbdP+zSIi8hCZvgDPmtXsrH/ibyBO9X2ShtaRzt6ZP4rxRAW1cChjNCwOmGRG6q m3n52iqMYd4D0O21cgr70j6O9PqQxjeis/EkP+oNTPZbSa9Px847L4k1xVD+ywBRKuev cczy5gnoeIB1ytXKwBmvboQJRXd4ItrIPdZc0Kza1KtlxP1ZMzNlTHPqmRc6lJZouecE EU7A== X-Gm-Message-State: ANoB5pkmy6LjfmHnSOmbOBqDEwWgXrOrpJCrhpH+YS30yZwGtq43jpyn Ikh5gyh+7wp5t2lgPDrM4CtLhZjLD0Yzja71PBjePrOBmxZETvQ2D/rXk0KQFdd+0i8RYE4kFN4 lAK7bxy3RFyJpaCn6o+zIELOo X-Received: by 2002:a7b:ca45:0:b0:3c4:bda1:7c57 with SMTP id m5-20020a7bca45000000b003c4bda17c57mr44926217wml.6.1669721948942; Tue, 29 Nov 2022 03:39:08 -0800 (PST) X-Received: by 2002:a7b:ca45:0:b0:3c4:bda1:7c57 with SMTP id m5-20020a7bca45000000b003c4bda17c57mr44926175wml.6.1669721948661; Tue, 29 Nov 2022 03:39:08 -0800 (PST) Received: from [192.168.3.108] (p5b0c6623.dip0.t-ipconnect.de. [91.12.102.35]) by smtp.gmail.com with ESMTPSA id bg11-20020a05600c3c8b00b003d069fc7372sm1471927wmb.1.2022.11.29.03.39.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 29 Nov 2022 03:39:08 -0800 (PST) Message-ID: <6d7f7775-5703-c27a-e57b-03aafb4de712@redhat.com> Date: Tue, 29 Nov 2022 12:39:06 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.1 Subject: Re: [PATCH v9 1/8] mm: Introduce memfd_restricted system call to create restricted user memory Content-Language: en-US To: "Kirill A. Shutemov" , Michael Roth Cc: Chao Peng , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-arch@vger.kernel.org, linux-api@vger.kernel.org, linux-doc@vger.kernel.org, qemu-devel@nongnu.org, Paolo Bonzini , Jonathan Corbet , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H . Peter Anvin" , Hugh Dickins , Jeff Layton , "J . Bruce Fields" , Andrew Morton , Shuah Khan , Mike Rapoport , Steven Price , "Maciej S . Szmigiero" , Vlastimil Babka , Vishal Annapurve , Yu Zhang , "Kirill A . Shutemov" , luto@kernel.org, jun.nakajima@intel.com, dave.hansen@intel.com, ak@linux.intel.com, aarcange@redhat.com, ddutile@redhat.com, dhildenb@redhat.com, Quentin Perret , tabba@google.com, mhocko@suse.com, Muchun Song , wei.w.wang@intel.com References: <20221025151344.3784230-1-chao.p.peng@linux.intel.com> <20221025151344.3784230-2-chao.p.peng@linux.intel.com> <20221129000632.sz6pobh6p7teouiu@amd.com> <20221129112139.usp6dqhbih47qpjl@box.shutemov.name> From: David Hildenbrand Organization: Red Hat In-Reply-To: <20221129112139.usp6dqhbih47qpjl@box.shutemov.name> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 29.11.22 12:21, Kirill A. Shutemov wrote: > On Mon, Nov 28, 2022 at 06:06:32PM -0600, Michael Roth wrote: >> On Tue, Oct 25, 2022 at 11:13:37PM +0800, Chao Peng wrote: >>> From: "Kirill A. Shutemov" >>> >> >> >> >>> +static struct file *restrictedmem_file_create(struct file *memfd) >>> +{ >>> + struct restrictedmem_data *data; >>> + struct address_space *mapping; >>> + struct inode *inode; >>> + struct file *file; >>> + >>> + data = kzalloc(sizeof(*data), GFP_KERNEL); >>> + if (!data) >>> + return ERR_PTR(-ENOMEM); >>> + >>> + data->memfd = memfd; >>> + mutex_init(&data->lock); >>> + INIT_LIST_HEAD(&data->notifiers); >>> + >>> + inode = alloc_anon_inode(restrictedmem_mnt->mnt_sb); >>> + if (IS_ERR(inode)) { >>> + kfree(data); >>> + return ERR_CAST(inode); >>> + } >>> + >>> + inode->i_mode |= S_IFREG; >>> + inode->i_op = &restrictedmem_iops; >>> + inode->i_mapping->private_data = data; >>> + >>> + file = alloc_file_pseudo(inode, restrictedmem_mnt, >>> + "restrictedmem", O_RDWR, >>> + &restrictedmem_fops); >>> + if (IS_ERR(file)) { >>> + iput(inode); >>> + kfree(data); >>> + return ERR_CAST(file); >>> + } >>> + >>> + file->f_flags |= O_LARGEFILE; >>> + >>> + mapping = memfd->f_mapping; >>> + mapping_set_unevictable(mapping); >>> + mapping_set_gfp_mask(mapping, >>> + mapping_gfp_mask(mapping) & ~__GFP_MOVABLE); >> >> Is this supposed to prevent migration of pages being used for >> restrictedmem/shmem backend? > > Yes, my bad. I expected it to prevent migration, but it is not true. Maybe add a comment that these pages are not movable and we don't want to place them into movable pageblocks (including CMA and ZONE_MOVABLE). That's the primary purpose of the GFP mask here. -- Thanks, David / dhildenb