From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8FA26C43217 for ; Wed, 16 Nov 2022 16:30:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 04F9B6B0071; Wed, 16 Nov 2022 11:30:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 031B58E0001; Wed, 16 Nov 2022 11:30:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E56E36B0074; Wed, 16 Nov 2022 11:30:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id D77D36B0071 for ; Wed, 16 Nov 2022 11:30:10 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 545AC1C5E0C for ; Wed, 16 Nov 2022 16:30:10 +0000 (UTC) X-FDA: 80139842580.25.DAFEF73 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf15.hostedemail.com (Postfix) with ESMTP id 8D7ECA0012 for ; Wed, 16 Nov 2022 16:30:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668616208; 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=KLeAHhTgIs3sfF0MHUgRVFm01Nu2oqFmzIWBikyuyGo=; b=CH/9XdC9tO5/3PW6J/INct9GhHoFbcLoN4CuTkpbZYvir6WGpKukbEFbxyPaHWNDjkUlqq f6ZxO1oe0+AXCwuM3qhj6k28T7xZzMoW3g2Xrg/pDHS9eIRgfmz9Yjo95O8AwfvsF3/38K yO0bXgSli12R83WMPhntc8vKfr+rhTM= 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-647-7kXzh979MNiXkkaRN6ATVQ-1; Wed, 16 Nov 2022 11:30:05 -0500 X-MC-Unique: 7kXzh979MNiXkkaRN6ATVQ-1 Received: by mail-qv1-f70.google.com with SMTP id mi12-20020a056214558c00b004bb63393567so13789971qvb.21 for ; Wed, 16 Nov 2022 08:30:05 -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=KLeAHhTgIs3sfF0MHUgRVFm01Nu2oqFmzIWBikyuyGo=; b=W9ihD5uuOZG48TW96yS8GER+oDCsLesTyI/KxbQpKqYfoR7x0vXaClQI0C3zrDj0Um KErhexrG/Ppc54I3PfzYEG7TXK2HWWBm/eLKMTYFVpjam4wribPnmL2THn9NputDgVMC DU00psTIUHJM30a1ITAZ8MMptgBb4tRgGB2pIc/wpXrrBoXKliDWPREpnOUCp/20Zejx 0FU9XBWG6xFAHF0FL0VytxheuN9mbV+P5XSRJWOPmg9hLr7aOmffLSVXm5C90jn9hBk/ TYUC3O7Jy1aCtfehjY3z8Ap1tBkV6OgZrFUdXjehsdVG4sOGEB86Cg0JkJBCmIVoQioj opLg== X-Gm-Message-State: ANoB5pmRoehJM+BKOzoioYxngmeuq/p3r9auM7Bhf8L12mu79/AEREIY TYAm3PuitmkNjJHF3QMPBV4GU3xOulyj7QSQO02sSHg5Hg5mkcqrfkhJbqbwjeyPoO+NBudaD7Y JM7UJPOVBrP8= X-Received: by 2002:ac8:5982:0:b0:35c:ea7a:fcac with SMTP id e2-20020ac85982000000b0035cea7afcacmr22070721qte.172.1668616204836; Wed, 16 Nov 2022 08:30:04 -0800 (PST) X-Google-Smtp-Source: AA0mqf4H4ODhyaAdfXNNQskKRrtkGtobSVhMccIg90++BBAIaHrmD9mUQVq4LxT2Id/oKQmu/YsDcA== X-Received: by 2002:ac8:5982:0:b0:35c:ea7a:fcac with SMTP id e2-20020ac85982000000b0035cea7afcacmr22070695qte.172.1668616204607; Wed, 16 Nov 2022 08:30:04 -0800 (PST) Received: from x1n (bras-base-aurron9127w-grc-46-70-31-27-79.dsl.bell.ca. [70.31.27.79]) by smtp.gmail.com with ESMTPSA id o23-20020ac872d7000000b0039a610a04b1sm8938544qtp.37.2022.11.16.08.30.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Nov 2022 08:30:04 -0800 (PST) Date: Wed, 16 Nov 2022 11:30:02 -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 01/47] hugetlb: don't set PageUptodate for UFFDIO_CONTINUE Message-ID: References: <20221021163703.3218176-1-jthoughton@google.com> <20221021163703.3218176-2-jthoughton@google.com> MIME-Version: 1.0 In-Reply-To: <20221021163703.3218176-2-jthoughton@google.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668616209; a=rsa-sha256; cv=none; b=8N6D5bb5P1nB75NbQm2IPyN0PIfZ/UikMTEdOcmkmyBFEBHaLItPazKrvxvavbDfC/DuR+ nsqYIqnpObm7tOLjUVENCKyx26tLSBne1bQUe9HrzIXRoJSZGQSgXfyW6kT6PiBBWnhztM j1AwS7qNBMWzJEpc6lbo7SpXWsgJs2g= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="CH/9XdC9"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf15.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668616209; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=KLeAHhTgIs3sfF0MHUgRVFm01Nu2oqFmzIWBikyuyGo=; b=GyLlCcbZHEHcSpS0cOOe2gSFY1HJK519wwN1I5bfFmyITJu3/PWJd6FJM4WC6vRb0uCf/x kMb5dZd+/zOt594xH6IdW3uJNXZaGGTjH3w+wH+X71JwNES86iYVap20qpsIE8pT+UOnpC YbAz6Px5MQuU7NAeYHurDlzSRDW9Xck= X-Rspam-User: Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="CH/9XdC9"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf15.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com X-Rspamd-Server: rspam02 X-Stat-Signature: bewc5jrncr5tdokb6s651n3tm4qrgkwu X-Rspamd-Queue-Id: 8D7ECA0012 X-HE-Tag: 1668616209-76487 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, Oct 21, 2022 at 04:36:17PM +0000, James Houghton wrote: > This is how it should have been to begin with. It would be very bad if > we actually set PageUptodate with a UFFDIO_CONTINUE, as UFFDIO_CONTINUE > doesn't actually set/update the contents of the page, so we would be > exposing a non-zeroed page to the user. > > The reason this change is being made now is because UFFDIO_CONTINUEs on > subpages definitely shouldn't set this page flag on the head page. > > Signed-off-by: James Houghton > --- > mm/hugetlb.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > index 1a7dc7b2e16c..650761cdd2f6 100644 > --- a/mm/hugetlb.c > +++ b/mm/hugetlb.c > @@ -6097,7 +6097,10 @@ int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm, > * preceding stores to the page contents become visible before > * the set_pte_at() write. > */ > - __SetPageUptodate(page); > + if (!is_continue) > + __SetPageUptodate(page); > + else > + VM_WARN_ON_ONCE_PAGE(!PageUptodate(page), page); Yeah the old code looks wrong, I'm just wondering whether we can 100% guarantee this for hugetlb. E.g. for shmem that won't hold when we uffd-continue on a not used page (e.g. by an over-sized fallocate()). Another safer approach is simply fail the ioctl if !uptodate, but if you're certain then WARN_ON_ONCE sounds all good too. At least I did have a quick look on hugetlb fallocate() and pages will be uptodate immediately. > > /* Add shared, newly allocated pages to the page cache. */ > if (vm_shared && !is_continue) { > -- > 2.38.0.135.g90850a2211-goog > > -- Peter Xu