Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp6202076rwj; Wed, 21 Dec 2022 12:08:20 -0800 (PST) X-Google-Smtp-Source: AMrXdXuO7mEFzM5D1os3NwiWh2gPeeRMazx2kIOhE+fVWsfYfWR+nWD/oEG03kjPbGk4eX0ARnvj X-Received: by 2002:a05:6402:f04:b0:46d:ca42:2e59 with SMTP id i4-20020a0564020f0400b0046dca422e59mr3085137eda.11.1671653300209; Wed, 21 Dec 2022 12:08:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671653300; cv=none; d=google.com; s=arc-20160816; b=DeexukgIdHbziWXLimyypFLWxmYMIhYpoWvprRg+k2EXplxmk6sE3pyHjpz3YR6WwU LBymEpd4Zd+TdEQ9KQ9fxCG/JLNaTc0bKsmceEMOy9p8i0qPiSKXNcKMVNNWUFtsGQmO QglUwL3j0tApBNyYKk3fdiA9SNiPemtfIqACanGoDuhjmcg75IOaRmKn3o4VlCDGUzih qXLMXZKSk/M+jfKXOCHtHYyntatW7QV6ybFURBqePgW2XOs5t62EAN+KOsnoxIj9LY2S o0olsEOOal8/BfplYwFv/Qzb+twuji23c8GpkLzemb4CWwTOLm/dM/GzSPWtMyIAUgIf FwNg== 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=OEPPIEZvL3irasUeIG2Bu5N+ZbEQsDWkll1bdKF+MRg=; b=Mu5oYG+s2wzXt589qjWN76doW05EP6AR0EUSH2da9NS5fpHpRz4uYYwIoeNQsppbfo dTQvoa+g0wDG7z/41un01IG0fmX9G89YkRJclg0XARyUfr4WYZ8BKGwf2Mnmszl9Sd/v gkBk5HLMpBdUMmB0/M6jIIhCYdGRffT23Jo790at/72gFup44F3IvmjFrlF/zuQRNzH1 WizrM0TnytfTH5XgaXJM1GLEKH0Vs/VToPJ7bKu6ljh8wOynjfhYIjYituCWZHw1q4Q6 vizdB/aaMLb4DEjT1spupr6nh9F9ITx5odiEfty9+pIqfFUJ5gr93re1FDOPD+EFoBaR 6KSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=M8EzmHt9; 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 y10-20020a056402440a00b0046c9a4ab639si16434716eda.548.2022.12.21.12.08.04; Wed, 21 Dec 2022 12:08:20 -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=M8EzmHt9; 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 S231834AbiLUTYa (ORCPT + 67 others); Wed, 21 Dec 2022 14:24:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229728AbiLUTY2 (ORCPT ); Wed, 21 Dec 2022 14:24:28 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C539264A0 for ; Wed, 21 Dec 2022 11:23:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671650621; 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: in-reply-to:in-reply-to:references:references; bh=OEPPIEZvL3irasUeIG2Bu5N+ZbEQsDWkll1bdKF+MRg=; b=M8EzmHt9QC3cSGSOGDi+NMY4NgnDhcnAT5cVFIifqskagOP3YZ+ikHwJDKXZOzvFlyzJsB pFrHr9artcoDzY9IsUKdCP7s4bLL+Bwl+DSVudNp1+jdhBWYlyfjNOMLTnx/WvsjHrSVNz QqOZSq/5GeZX6g/MY2eQMsiMe450drs= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-279-uwQ252WHN8iHxX5GnkdSRg-1; Wed, 21 Dec 2022 14:23:40 -0500 X-MC-Unique: uwQ252WHN8iHxX5GnkdSRg-1 Received: by mail-qv1-f70.google.com with SMTP id o13-20020a056214108d00b004c6fb4f16dcso9071842qvr.6 for ; Wed, 21 Dec 2022 11:23:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=OEPPIEZvL3irasUeIG2Bu5N+ZbEQsDWkll1bdKF+MRg=; b=Xt1dva51wFSZVdfwcr0R4DkT10mTrLojLV3pcAemNto9LndvdIUkIGXAzvtGe4wDy3 l0nh18pU/zzKwOMyF+Dq2qgRBc5N4AMbN34pQjzyXgJYBJFXn7K4x+V8hA/NrHyw8WFW r40gQ3uqjANDAegdIJqlGlruvDeec+TcrTdyAPIQXzPLJ+KHIKe6UYA09gPHz4isIZkE 4MMNVwGi2xW6y8erQq4LsjREXintStASWpV2O5pimNo6gjeW5nOpdA8pMKNvXLqVjrZs vAp1d4kEy8DGacY9VUXEefWcJY/RvSBU9AoJR2qe1Tc3YhvVJWDvWxDbY4PvkrbfwkEZ hsCQ== X-Gm-Message-State: AFqh2kruYl7G4hiejHCzwYmNshKAtS4Sg11WTW7eyXD7kmM30ytf51jR vOHsEOfIG38poswvj5TyCJEp+GoEZowLY+Tjt7uBsTqrPR7c0JxOagQhw0M3DpgXKHwFYNoVv1q MR8yUYW2uZs9Bg0zcm4tyji2w X-Received: by 2002:ac8:4509:0:b0:3a8:162d:e977 with SMTP id q9-20020ac84509000000b003a8162de977mr3362671qtn.58.1671650619542; Wed, 21 Dec 2022 11:23:39 -0800 (PST) X-Received: by 2002:ac8:4509:0:b0:3a8:162d:e977 with SMTP id q9-20020ac84509000000b003a8162de977mr3362650qtn.58.1671650619320; Wed, 21 Dec 2022 11:23:39 -0800 (PST) Received: from x1n (bras-base-aurron9127w-grc-45-70-31-26-132.dsl.bell.ca. [70.31.26.132]) by smtp.gmail.com with ESMTPSA id q30-20020a37f71e000000b006faaf6dc55asm11148662qkj.22.2022.12.21.11.23.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Dec 2022 11:23:38 -0800 (PST) Date: Wed, 21 Dec 2022 14:23:35 -0500 From: Peter Xu To: James Houghton Cc: Mike Kravetz , Muchun Song , David Hildenbrand , David Rientjes , Axel Rasmussen , Mina Almasry , Zach O'Keefe , Manish Mishra , Naoya Horiguchi , "Dr . David Alan Gilbert" , "Matthew Wilcox (Oracle)" , Vlastimil Babka , Baolin Wang , Miaohe Lin , Yang Shi , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH v2 33/47] userfaultfd: add UFFD_FEATURE_MINOR_HUGETLBFS_HGM Message-ID: References: <20221021163703.3218176-1-jthoughton@google.com> <20221021163703.3218176-34-jthoughton@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 James, On Wed, Nov 16, 2022 at 03:30:00PM -0800, James Houghton wrote: > On Wed, Nov 16, 2022 at 2:28 PM Peter Xu wrote: > > > > On Fri, Oct 21, 2022 at 04:36:49PM +0000, James Houghton wrote: > > > Userspace must provide this new feature when it calls UFFDIO_API to > > > enable HGM. Userspace can check if the feature exists in > > > uffdio_api.features, and if it does not exist, the kernel does not > > > support and therefore did not enable HGM. > > > > > > Signed-off-by: James Houghton > > > > It's still slightly a pity that this can only be enabled by an uffd context > > plus a minor fault, so generic hugetlb users cannot directly leverage this. > > The idea here is that, for applications that can conceivably benefit > from HGM, we have a mechanism for enabling it for that application. So > this patch creates that mechanism for userfaultfd/UFFDIO_CONTINUE. I > prefer this approach over something more general like MADV_ENABLE_HGM > or something. Sorry to get back to this very late - I know this has been discussed since the very early stage of the feature, but is there any reasoning behind? When I start to think seriously on applying this to process snapshot with uffd-wp I found that the minor mode trick won't easily play - normally that's a case where all the pages were there mapped huge, but when the app wants UFFDIO_WRITEPROTECT it may want to remap the huge pages into smaller pages, probably some size that the user can specify. It'll be non-trivial to enable HGM during that phase using MINOR mode because in that case the pages are all mapped. For the long term, I am just still worried the current interface is still not as flexible. -- Peter Xu