From patchwork Fri Oct 21 16:36:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Houghton X-Patchwork-Id: 13015070 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 BA9C1FA373E for ; Fri, 21 Oct 2022 16:37:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 37A148E0003; Fri, 21 Oct 2022 12:37:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2DC268E0001; Fri, 21 Oct 2022 12:37:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 12F8E8E0003; Fri, 21 Oct 2022 12:37:17 -0400 (EDT) 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 F29F98E0001 for ; Fri, 21 Oct 2022 12:37:16 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id C415E80556 for ; Fri, 21 Oct 2022 16:37:16 +0000 (UTC) X-FDA: 80045511672.30.A45C9B7 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf30.hostedemail.com (Postfix) with ESMTP id 304AD80035 for ; Fri, 21 Oct 2022 16:37:15 +0000 (UTC) Received: by mail-yb1-f202.google.com with SMTP id n6-20020a5b0486000000b006aff8dc9865so3736362ybp.11 for ; Fri, 21 Oct 2022 09:37:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=PyHYN0BZDkl5R+we+ok2phOJ6Br6Eo9HknyqZ/f6blI=; b=k4YSYz8Eqmi/g8cLFz6T0cXUQewY5TrykcLo3J6vLFEFW+zVg07R+6L2pGz4hYkpjh YeRSCb3IFz9Lx2ADjHguv3Bcl2NzvlSG0UaHoorM2hx35cBJZbjKBwoRh5rxOv53PUtH 6JfJ5o1zynpQr144bkb1sr56ifBdHTV2T5B0ZasYzlZTGp6KE2/lEQXR+tm8Fb9Lka+0 ayKHUamTEhmRm9nNm0eDQcbCVIN9xZXd7NlM3NhcPsDm0mH+iuwgerGgDIztDwXkgbUe GoioeQ/qERTklWRzJZVlo//zRoztIQ/e5hovtXxIkbCWhIHv+mW+9bZYapriY1Hylf8f cQlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=PyHYN0BZDkl5R+we+ok2phOJ6Br6Eo9HknyqZ/f6blI=; b=sGjYx0nQNYgdnO87EoT07mB8e5GlWGKTM/HW/HztQQjhi7jNL0wgZB2HQHwS7dinxi wNKhS12XCispkCZBEYsfcm03zt5ZgNVKdtWlXAUGed3+hWxbEySNYepmbVLK3V//ayEW fOwY/8ho7zHHTekKX/raS1T/jwom0CN7hDj93Csx3MU/aVE1f2Shc9lXs7eJHUuoTWLY 9dUuScgM9txPn/w04UXgZE/6kfNMnrohRXjZHt2H37udZldCyetkzEwaURPIa8ye9aow 6bRTuQhQXM2wmTLHLnePfqK9LP6vkSENSWZFur0aja54wf+aq30o4RxRTt+ujBPyvu9Q 4N6Q== X-Gm-Message-State: ACrzQf1UumI6EihMIB3CE37ndGmjUgdeJ93gw0065+peRZJ6lmP4c3y5 kKztp9YcXO+KmV2Ue28OYPYyztQ3ZYgNfhcD X-Google-Smtp-Source: AMsMyM71R8GW+ChtJoWlK0QDaMYn9Alr4ayX6EmYtj3WLRdsrGZ2zJ8HM0W8AKSaOIsOoFkltQC4RNu16EZ4KvtE X-Received: from jthoughton.c.googlers.com ([fda3:e722:ac3:cc00:14:4d90:c0a8:2a4f]) (user=jthoughton job=sendgmr) by 2002:a25:6a8b:0:b0:6c0:5610:b6f1 with SMTP id f133-20020a256a8b000000b006c05610b6f1mr17608546ybc.273.1666370235466; Fri, 21 Oct 2022 09:37:15 -0700 (PDT) Date: Fri, 21 Oct 2022 16:36:17 +0000 In-Reply-To: <20221021163703.3218176-1-jthoughton@google.com> Mime-Version: 1.0 References: <20221021163703.3218176-1-jthoughton@google.com> X-Mailer: git-send-email 2.38.0.135.g90850a2211-goog Message-ID: <20221021163703.3218176-2-jthoughton@google.com> Subject: [RFC PATCH v2 01/47] hugetlb: don't set PageUptodate for UFFDIO_CONTINUE From: James Houghton To: Mike Kravetz , Muchun Song , Peter Xu Cc: 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, James Houghton ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666370236; a=rsa-sha256; cv=none; b=D2oF9G71h61x3biBVnS0ZEEqBCgyCi/tJEs5LL0h1MG9f5HGIUAhN0PRfXGfa2o+P+pY/G lRguoa4bHJeWwj27/CYp08gOyWuEvc7C0x7baVLGJbhBVFPexVoAapENeVePDdpYJLrlhZ ZbLTrd8hwerUyRY5CO+c9Y6kuqyE5kc= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=k4YSYz8E; spf=pass (imf30.hostedemail.com: domain of 3u8pSYwoKCLwlvjqwijvqpiqqing.eqonkpwz-oomxcem.qti@flex--jthoughton.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3u8pSYwoKCLwlvjqwijvqpiqqing.eqonkpwz-oomxcem.qti@flex--jthoughton.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666370236; 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=PyHYN0BZDkl5R+we+ok2phOJ6Br6Eo9HknyqZ/f6blI=; b=NFNLTDY6fAw6eo1HGdtzikoEsgIqQyVkaiPWAXbAOCjucgceYY66+4nBgGtob6deI0UCOL yKNyVbTwPgHI6XmAYWygsKv31iqmWEowFISXjVyhfXJSCq36gYVdx3rxf1JhyZCPiNiJuM V5lAgAM7LsLKSZE5XWFR30wWYozeM3I= Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=k4YSYz8E; spf=pass (imf30.hostedemail.com: domain of 3u8pSYwoKCLwlvjqwijvqpiqqing.eqonkpwz-oomxcem.qti@flex--jthoughton.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3u8pSYwoKCLwlvjqwijvqpiqqing.eqonkpwz-oomxcem.qti@flex--jthoughton.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com X-Stat-Signature: 9a1u6jhan6srm64eq97oxymmytp9rjch X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 304AD80035 X-Rspam-User: X-HE-Tag: 1666370235-200954 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: 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); /* Add shared, newly allocated pages to the page cache. */ if (vm_shared && !is_continue) {