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 <peterx@xxxxxxxxxx> 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 <jthoughton@xxxxxxxxxx> > > > > 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