Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp882860imi; Thu, 21 Jul 2022 12:53:12 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tkhMiTIw1rtaqNZQMGPYi0hry1pEfC+oIUcJoy9nQK62X6BRSr6Lbi8XMyAHSRqbh2LdFn X-Received: by 2002:a17:902:c945:b0:16c:49c9:7932 with SMTP id i5-20020a170902c94500b0016c49c97932mr45599697pla.80.1658433192745; Thu, 21 Jul 2022 12:53:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658433192; cv=none; d=google.com; s=arc-20160816; b=FI/bC82+oolm+lxM4sdsnTKe9pFDs6Gh7/hUhZ7r+4mvFbgBdkTpyjeIEpxZmcbgth rRAb4jwApdufbDhcV6vHz3IcEjUvcgXnqQs0WLAHlWiXXll5pyo8YDUkvyvjCZHmjnKt 4hhWCrHcjWYcbfIZAuNaDqGgPrizwSUlZ4XLhGN/75A/0qnDoITJc3J4LHuHRBCdLgy5 AoCRSyEeZuuXK/o+wKLx6sjuEAHQ+h8dqkUYRmtYZmiTxryOqSbiJb8AuQs+8fBwSOOl GHBjNnwfI3EJDh80YDDsRUPj6BGK/QHzgTz7ARh/+EFh4kfGjD1YuK9mhs2LTxhDRgyY J8qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=wWzcp1Z8HWXlZGBmd2SY3dRRfAqxHf8nagIP1lsSW5w=; b=JAclG3bV5wAQo/CnZgCKxv7zpkMtmBQDDpKvEtWVdEr5T7BR3XVBFCR3beAF16pcFE ZRks2p5ElSanWahsUyvKtNuoJk5Pwpw2gZbtoWASPp7ifcOPGu22JO3U8OYK5NCVSFul lOQ5Gs40WW1ribCKPS2BfBpGYGCGR6By9jWvIBa3dWKEgrwn+hCIxnTkuFFdDVerlVV8 qKMXJtfrC3uommzMWz7+9f6JEwS1tNnYHsPt5Qhbn2UMRZBl2euffnOZghIxBcqq4a5y Xhgj5flbJs/A9v3BPYlAxn92FWFhkFgxqm8Y8Ktjj8/bpaG2aWT+bgbA3Lnfmt/Z75qJ 5Hbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=GfvL2JFN; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ip3-20020a17090b314300b001e887404411si7313423pjb.8.2022.07.21.12.52.58; Thu, 21 Jul 2022 12:53:12 -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=@google.com header.s=20210112 header.b=GfvL2JFN; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229793AbiGUTpP (ORCPT + 99 others); Thu, 21 Jul 2022 15:45:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231644AbiGUTpO (ORCPT ); Thu, 21 Jul 2022 15:45:14 -0400 Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [IPv6:2a00:1450:4864:20::235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F70B1E6 for ; Thu, 21 Jul 2022 12:45:11 -0700 (PDT) Received: by mail-lj1-x235.google.com with SMTP id w2so3055366ljj.7 for ; Thu, 21 Jul 2022 12:45:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=wWzcp1Z8HWXlZGBmd2SY3dRRfAqxHf8nagIP1lsSW5w=; b=GfvL2JFNB8yDOfrBzXPR28ePl1mIvysTBOgaKcjnGva2ZTymhmVH+3mZDIioZs5lAz ERjUW3sMTOYwCNHAp73jtQ3XmGcQ7PWTNHkwwhll77e/9uFc3rhIc7vnZLzass58FLiR /okJG5sVVAthcVmBD9xoLnJLj/WpWqPKr6BiB1nwz6JG2skQR1BPkGKiSs0d8fO2EEYW TMbSh4Nrx7DZ95TYYIjXRcebiQCguVpTU/h1LY2hwiDNIUp4EF+lJXAGeQ2H+gYvwFhy b4WbAq2uLtd0DWU9bueYB7oj4pPk7msqqTh2/EjsE4U9CNUKEBMdqkM9Rulr4M+RoQwE gfNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=wWzcp1Z8HWXlZGBmd2SY3dRRfAqxHf8nagIP1lsSW5w=; b=0fR+RPe4MA2Xd1TqXajqnsowEXlYhREVdqWZ/W22XVhaCABoew7YbUZeEvJLOmU9ZC +ljUmQPJGcq04SwEGvxb8pG3D+ok4TE4ydh7YkzeTvFspQCUS/ztZsslpEMBgDzCgvh6 e9vxQdlqjSBYWG2jVb2wpjkEYIaJY2uhIZvUNLFMTCeXEh5/wKCe6GEXksa2Q/T2wtPm DYq3lak6EC0/delUdi9eQQa+Pe5nIVuUpH7Gg9wLdyxEn7ynu/T9JgEqiM8BNZMGIAeD 396lXuCQlltLZ9NMr/FJ8C/gzsPvSSPj8hh+g9k9M0pV4X4qmtuvAm31H8NgTp/MtXXG JqzA== X-Gm-Message-State: AJIora8EKu0rZmo+xCusisy/b0Xjl2HMKyvCt6F3Be16sXjsmNYzCSu9 qLEFZVDp72XIE8UPQ+eF8xMaMQF24pOaOFmtKkMeYA== X-Received: by 2002:a2e:b011:0:b0:25d:6208:77b1 with SMTP id y17-20020a2eb011000000b0025d620877b1mr19085765ljk.469.1658432709589; Thu, 21 Jul 2022 12:45:09 -0700 (PDT) MIME-Version: 1.0 References: <20220624173656.2033256-1-jthoughton@google.com> <20220624173656.2033256-21-jthoughton@google.com> In-Reply-To: From: James Houghton Date: Thu, 21 Jul 2022 12:44:58 -0700 Message-ID: Subject: Re: [RFC PATCH 20/26] hugetlb: add support for high-granularity UFFDIO_CONTINUE To: Peter Xu Cc: Mike Kravetz , Muchun Song , David Hildenbrand , David Rientjes , Axel Rasmussen , Mina Almasry , Jue Wang , Manish Mishra , "Dr . David Alan Gilbert" , linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 Thu, Jul 21, 2022 at 12:09 PM Peter Xu wrote: > > On Wed, Jul 20, 2022 at 01:58:06PM -0700, James Houghton wrote: > > > > > > @@ -335,12 +337,16 @@ static __always_inline ssize_t __mcopy_atomic_hugetlb(struct mm_struct *dst_mm, > > > > > > copied = 0; > > > > > > page = NULL; > > > > > > vma_hpagesize = vma_kernel_pagesize(dst_vma); > > > > > > + if (use_hgm) > > > > > > + vma_altpagesize = PAGE_SIZE; > > > > > > > > > > Do we need to check the "len" to know whether we should use sub-page > > > > > mapping or original hpage size? E.g. any old UFFDIO_CONTINUE code will > > > > > still want the old behavior I think. > > > > > > > > I think that's a fair point; however, if we enable HGM and the address > > > > and len happen to be hstate-aligned > > > > > > The address can, but len (note! not "end" here) cannot? > > > > They both (dst_start and len) need to be hpage-aligned, otherwise we > > won't be able to install hstate-sized PTEs. Like if we're installing > > 4K at the beginning of a 1G hpage, we can't install a PUD, because we > > only want to install that 4K. > > I'm still confused... > > Shouldn't one of the major goals of sub-page mapping is to grant user the > capability to do UFFDIO_CONTINUE with len sub-page level)? If so, why len needs to be always hpagesize aligned? Sorry I misunderstood what you were asking. We allow both to be PAGE_SIZE-aligned. :) That is indeed the goal of HGM. If dst_start and len were both hpage-aligned, then we *could* set `use_hgm = false`, and everything would still work. That's what I thought you were asking about. I don't see any reason to do this though, as `use_hgm = true` will only grant additional functionality, and `use_hgm = false` would only -- at best -- be a minor performance optimization in this case. - James > > -- > Peter Xu >