Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp317448rwb; Thu, 22 Sep 2022 18:55:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM50Z2CxjlPBgKkVtYmTg81zGpFiyieGnSXN3ixPMt0Y6NARsG2Yx7V24dN/9XOOwoicm5WQ X-Received: by 2002:a17:90b:4a82:b0:200:a89e:6f1f with SMTP id lp2-20020a17090b4a8200b00200a89e6f1fmr18072765pjb.13.1663898113222; Thu, 22 Sep 2022 18:55:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663898113; cv=none; d=google.com; s=arc-20160816; b=0c+VL8O+l9cPUAtp++fv+QJV9qJscHUNX2gNSjqJUPMoQifrHn2HdLPNHKl5tMNW5b 4l/ep6o4eJyHgGLYbARzy475OF8QB6g/TdE4HVmVb2qPhsc1j8qCvRiXQH6X/S+8ej4k vKkNd47u2Zr/vHx6JSTA/PfNsIt+u+O5AMTIbQn0pW9Lr59nZn8v2FkB7FrKLwLB2ZUm uuobrdIlNIBZ7wVfANtJ5V5hc0yXCWjWdn2OL4CxCoe1Tv26hCBnjan+NVcXxNxwVpVk HNjuqjbxh9AILwlW07bY1nwfgeXB5E/EGGj8Ynh8RfEujl6E0Dr9stnPC+UzT6eFY9OD vzaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=leOtOv11DUD3tfz4spgx1J/lUxgfb7XkT/QMzQe7W8c=; b=RsIQcT8X4jheXuJZxERFNa1aoi2WFIyt+4HM/RPWwLOSOKJ4l5YbAjiQR5PsOxKqko VASPb3ojGXzvV7u/D2h7qeliuMlHIaDYRlZHVAesQ8ufod5/LN82Eoxi5n3MPLU1lpEL pYk+6M3bW/51eBPh7JNG+qUg+08jeI8A0lr1elkBtU0wTjOGuw8jaFxDmIK9CQ3tCOCx Bc+tABMo+HLq5sY3qNKsn7MO1YrKHomTIRD/cYy8nRgjY/cjmK9MhgRukvXip/Oakv6h rXeWPbvuwXuf7GqWmatfh2h5Yw3+NfR/ZSZE5MR2KU+vC6mUwZCnbAhu96Xs6Y8YrtIX 6mng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="cd/1LyD4"; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c14-20020a170902d48e00b001789ee592e0si1894305plg.327.2022.09.22.18.55.00; Thu, 22 Sep 2022 18:55:13 -0700 (PDT) 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=@intel.com header.s=Intel header.b="cd/1LyD4"; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231708AbiIWA6Y (ORCPT + 99 others); Thu, 22 Sep 2022 20:58:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231532AbiIWA6V (ORCPT ); Thu, 22 Sep 2022 20:58:21 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89B8D1114E4; Thu, 22 Sep 2022 17:58:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1663894700; x=1695430700; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=Ml+yVLdWFYzsyDqjZioBXvGBweEy273hCGRMNDKeVO8=; b=cd/1LyD4UQVamNgO/s0DIDHY0YYMwsxXkU6wVfMS6PVBSRoZfSD1P2Ko Vnb1+yy8FZ6WSo25k6uJfqi9OR4R8b0mOeOgtbamZHM9K79UWaEcxEI16 6iX9z60x98poA+XBv6X7o/QPTdYBsdWWj8k5xg4/9wSLHgxiZAgdWrgtk 5mEMUtUysJRmxtmJFGIkNKs2cePtum9tu74+Nwz5byEdqLXmnVN5/bh+d FVaA44ytENtwrQyqnepff6pxG76WWar4D42MkVbXiKWBs2NmLS9txY5vw erguz2zz1ymybWIJUUw05E5/grhuqjbOTm190r1FX8vxytG6Ypc4W9JxJ w==; X-IronPort-AV: E=McAfee;i="6500,9779,10478"; a="364488768" X-IronPort-AV: E=Sophos;i="5.93,337,1654585200"; d="scan'208";a="364488768" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2022 17:58:19 -0700 X-IronPort-AV: E=Sophos;i="5.93,337,1654585200"; d="scan'208";a="615437441" Received: from dnessim-mobl1.ger.corp.intel.com (HELO box.shutemov.name) ([10.252.60.183]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2022 17:58:10 -0700 Received: by box.shutemov.name (Postfix, from userid 1000) id 5F4F01044E2; Fri, 23 Sep 2022 03:58:08 +0300 (+03) Date: Fri, 23 Sep 2022 03:58:08 +0300 From: "Kirill A . Shutemov" To: Paolo Bonzini , Sean Christopherson , David Hildenbrand Cc: Chao Peng , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org, linux-doc@vger.kernel.org, qemu-devel@nongnu.org, Jonathan Corbet , 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 , 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 , Michael Roth , mhocko@suse.com, Muchun Song , wei.w.wang@intel.com Subject: Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd Message-ID: <20220923005808.vfltoecttoatgw5o@box.shutemov.name> References: <20220915142913.2213336-1-chao.p.peng@linux.intel.com> <20220915142913.2213336-2-chao.p.peng@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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 Mon, Sep 19, 2022 at 11:12:46AM +0200, David Hildenbrand wrote: > > diff --git a/include/uapi/linux/magic.h b/include/uapi/linux/magic.h > > index 6325d1d0e90f..9d066be3d7e8 100644 > > --- a/include/uapi/linux/magic.h > > +++ b/include/uapi/linux/magic.h > > @@ -101,5 +101,6 @@ > > #define DMA_BUF_MAGIC 0x444d4142 /* "DMAB" */ > > #define DEVMEM_MAGIC 0x454d444d /* "DMEM" */ > > #define SECRETMEM_MAGIC 0x5345434d /* "SECM" */ > > +#define INACCESSIBLE_MAGIC 0x494e4143 /* "INAC" */ > > > [...] > > > + > > +int inaccessible_get_pfn(struct file *file, pgoff_t offset, pfn_t *pfn, > > + int *order) > > +{ > > + struct inaccessible_data *data = file->f_mapping->private_data; > > + struct file *memfd = data->memfd; > > + struct page *page; > > + int ret; > > + > > + ret = shmem_getpage(file_inode(memfd), offset, &page, SGP_WRITE); > > + if (ret) > > + return ret; > > + > > + *pfn = page_to_pfn_t(page); > > + *order = thp_order(compound_head(page)); > > + SetPageUptodate(page); > > + unlock_page(page); > > + > > + return 0; > > +} > > +EXPORT_SYMBOL_GPL(inaccessible_get_pfn); > > + > > +void inaccessible_put_pfn(struct file *file, pfn_t pfn) > > +{ > > + struct page *page = pfn_t_to_page(pfn); > > + > > + if (WARN_ON_ONCE(!page)) > > + return; > > + > > + put_page(page); > > +} > > +EXPORT_SYMBOL_GPL(inaccessible_put_pfn); > > Sorry, I missed your reply regarding get/put interface. > > https://lore.kernel.org/linux-mm/20220810092532.GD862421@chaop.bj.intel.com/ > > "We have a design assumption that somedays this can even support non-page > based backing stores." > > As long as there is no such user in sight (especially how to get the memfd > from even allocating such memory which will require bigger changes), I > prefer to keep it simple here and work on pages/folios. No need to > over-complicate it for now. Sean, Paolo , what is your take on this? Do you have conrete use case of pageless backend for the mechanism in sight? Maybe DAX? -- Kiryl Shutsemau / Kirill A. Shutemov