From patchwork Sat Feb 18 00:27:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Houghton X-Patchwork-Id: 13145366 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 4382EC636D6 for ; Sat, 18 Feb 2023 00:28:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7B6F76B0072; Fri, 17 Feb 2023 19:28:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6A2556B0073; Fri, 17 Feb 2023 19:28:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 569576B0074; Fri, 17 Feb 2023 19:28:47 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 47B516B0072 for ; Fri, 17 Feb 2023 19:28:47 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 163281C5DF5 for ; Sat, 18 Feb 2023 00:28:47 +0000 (UTC) X-FDA: 80478527094.22.82F33E9 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) by imf19.hostedemail.com (Postfix) with ESMTP id 5F4E91A0002 for ; Sat, 18 Feb 2023 00:28:45 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=JUkI+uUZ; spf=pass (imf19.hostedemail.com: domain of 3vBvwYwoKCNkEOCJPBCOJIBJJBG9.7JHGDIPS-HHFQ57F.JMB@flex--jthoughton.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3vBvwYwoKCNkEOCJPBCOJIBJJBG9.7JHGDIPS-HHFQ57F.JMB@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=1676680125; 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=WRJSWRU8dQHXXhdXAbgeFtewLtYoHueyg1zV/lollrc=; b=xX5mhwdO7/HyZee/+4l9stR0JI5wmEbC2sBi+qSv+alTEaQT1XmT0qq8K2QiGVjJhJVYL8 bjIvG5r7AHNU7j+AWVzogzbskcJrU/8e76Xaa6Mijh13uQ3ajgsdCHGWQX8FuzvhrJtI5T 0dTMXpnSDlmMnptoFlJcrfTnWXv2kjU= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=JUkI+uUZ; spf=pass (imf19.hostedemail.com: domain of 3vBvwYwoKCNkEOCJPBCOJIBJJBG9.7JHGDIPS-HHFQ57F.JMB@flex--jthoughton.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3vBvwYwoKCNkEOCJPBCOJIBJJBG9.7JHGDIPS-HHFQ57F.JMB@flex--jthoughton.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1676680125; a=rsa-sha256; cv=none; b=W8MX7KAsCPTSicmZSkAxYV+oS/vEdieFKePn5++PzN9HOFmLxErnkC1+Y9tn+5zVeWkNTx 8u0F3lZ3KOlwUG8NrHQi17sVCywCkO50i7O27aPk/xPuKLSHTRhqD9DHZ4DslruRmgXR7B ZLhcPYkAs2xFeUy8L0L0tYXYyWMLHl0= Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-536587ff9e1so22047857b3.21 for ; Fri, 17 Feb 2023 16:28:45 -0800 (PST) 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=WRJSWRU8dQHXXhdXAbgeFtewLtYoHueyg1zV/lollrc=; b=JUkI+uUZUGikStVOrWOWfUFvkifZQjdvysrYVMcxjv1b2yQplxM71vw1fjhTzhEkxI BEohrL6MRF518g9B3YG2ljl8T7G93FwY6nToc+IVWoDTzVPkWMKdK99Fw+Y/07yhJ3P2 Pt0n2XoDP+p37aLwSJxXkZR/Jyh8LDLuXTOP46PclH0WaRZarQPsfJWYdmcsYTgivcxA V29rcePGsSV2Bm8JBI3cnvgY6VYwZ38Vy23D8uxt/hblg5U5P6fb6PnTeEwjCMXWB3jt Xt02v+X21m74LuwV377B2oYbsfLR/FpkRSgMkEe4zOTBZt33XomrJuA07ToJPeOqmC5B 2qvw== 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=WRJSWRU8dQHXXhdXAbgeFtewLtYoHueyg1zV/lollrc=; b=1BbVsaFVwlbBPx78wZNO0rfN2PqX3dYV2DY8wzIfz9MOchZq4z4ipmET2mGU9DzWmw LM9zQSTZtU9knBM7pTha+xKdki4bwNN5N/nLX7Xw2Jb9d1UCLonHzt2Fip577S8M5Ug5 7KYKaJW/JOuQsIKNaPzFgnDi4LkJNgBHGj/AeJ/nl/QDxZL2y1HNdMahThN6tdYAELb9 hqxA1tBpgZlrbPKxj5rIeOmfRIF+7/jpLoz9p4wuT1YvVR2ogRFKMkYeAwbk8jZ4nEPm 52JYOSsZk4bkeUWN9VQtZ+W1dJsXnLsbRX+2L8BXKncBQrQHdCTjcIhiHapPViNuoW4r aq2w== X-Gm-Message-State: AO0yUKXYMqqOiT2o0Sx/PiUh80narCp9wIWL0dyMWbHelbZhKVFnRoaR Q3nvE2x2bUADoqhBpPl7gZM7jNJJ6vB8ec9c X-Google-Smtp-Source: AK7set/WjcZL+XrN64oa4iFWZNoLag2qFEizB65Q47paRVpixNGKzuLMD0K/0D4ZsPotwj/bHVSjyMfKhh7AGtfF X-Received: from jthoughton.c.googlers.com ([fda3:e722:ac3:cc00:14:4d90:c0a8:2a4f]) (user=jthoughton job=sendgmr) by 2002:a81:4981:0:b0:527:adb4:3297 with SMTP id w123-20020a814981000000b00527adb43297mr1507453ywa.161.1676680124408; Fri, 17 Feb 2023 16:28:44 -0800 (PST) Date: Sat, 18 Feb 2023 00:27:34 +0000 In-Reply-To: <20230218002819.1486479-1-jthoughton@google.com> Mime-Version: 1.0 References: <20230218002819.1486479-1-jthoughton@google.com> X-Mailer: git-send-email 2.39.2.637.g21b0678d19-goog Message-ID: <20230218002819.1486479-2-jthoughton@google.com> Subject: [PATCH v2 01/46] hugetlb: don't set PageUptodate for UFFDIO_CONTINUE From: James Houghton To: Mike Kravetz , Muchun Song , Peter Xu , Andrew Morton 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 , Frank van der Linden , Jiaqi Yan , linux-mm@kvack.org, linux-kernel@vger.kernel.org, James Houghton X-Stat-Signature: z14h55x3fbwrp76sbi1rqxhfz79s7fkm X-Rspam-User: X-Rspamd-Queue-Id: 5F4E91A0002 X-Rspamd-Server: rspam06 X-HE-Tag: 1676680125-906181 X-HE-Meta: U2FsdGVkX19NC6D1oW9rR6jN0q8pTB+ObOZOVJuyaWSsklnhpmN3/34aNEoweNoxz70Itd8ekAAHvz1aUrM9V8C5rbaJxN4LNNhYJNCfGKx37l5YBEeNg0waFg2oOI3CDs2jRKpgw1vvU4bPE+7kSMi8wCAomFzktURhOkvu+lFULHxIzwSQCQSTweUH8ewb6wZd9+mueALgyttHkdyM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WdwuD5ee4upf6GnmrW9J5JjRFblFptZSmOqSe3+8zfWlSZsiU/cRyF5V2cMzfFYzAlwijqY0b1v7TvY6FxAGeN9s3Z+FiQ+l9f1IPtYHLgqvt5jOWAUzpSib8/+KycQZhxMIuxuCCpO3iBcnfW2e6VsRUsYB3/BBg3wIwhYmCZSXLMFlBn5xgyBk2Oa03Q2NZeBx24SrVPZekB2kmgt8/waG4jRmCuAwAammCU+MSvPFgguD7ApqfIHLGboNOD6jytgQXfRd+oZATErfnISPziZHgfDwjgcCuaiYMySo6RYkC9oTL+S4PR2p1LoMqsim0oX+Rlsn9Q6R7Zpt2q74XfKR3BsDy6EWajrR4eOmH/tZQQeL3Gp3za8H1GM1lAliZJnpMB4hdbFZ/xgFlgiITGdO5p7ITc5Q= 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: If would be bad if we actually set PageUptodate with UFFDIO_CONTINUE; PageUptodate indicates that the page has been zeroed, and we don't want to give 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 diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 07abcb6eb203..792cb2e67ce5 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -6256,7 +6256,16 @@ int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm, * preceding stores to the page contents become visible before * the set_pte_at() write. */ - __folio_mark_uptodate(folio); + if (!is_continue) + __folio_mark_uptodate(folio); + else if (!folio_test_uptodate(folio)) { + /* + * This should never happen; HugeTLB pages are always Uptodate + * as soon as they are allocated. + */ + ret = -EFAULT; + goto out_release_nounlock; + } /* Add shared, newly allocated pages to the page cache. */ if (vm_shared && !is_continue) {