Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp4701608rwb; Mon, 21 Nov 2022 10:42:56 -0800 (PST) X-Google-Smtp-Source: AA0mqf52CKvgqwNfRcNTYtj+PwkR9FyPG285I0h1CKJ1TRrAkxlu2cKNCDF5INA5D1ipq2cEe59w X-Received: by 2002:a05:6a00:32c7:b0:565:f8bb:96f8 with SMTP id cl7-20020a056a0032c700b00565f8bb96f8mr235592pfb.45.1669056176077; Mon, 21 Nov 2022 10:42:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669056176; cv=none; d=google.com; s=arc-20160816; b=CX4w8ytPdbnWPqjYRbs0eM9uN60HdF7PvE9a43fMqql+PAJzdEkpTW91ZeZP4ORGaz Th4QAb9cO2ii0bXhF0MRyW+iYUTxqu/oYjuzWfvgAFJ2TMKRorzn8Y351+rxpl1ERpdc wCbM6evDac6l6uno3AkLo9ZevrmOvEv4Jl3DO3Bc3WoHeHLWcK5jRFq+5T6ZGrP6q4z1 Cn9O1rvbL49UYJiNpwcbNhbGFUJQhIA049/wpYRXmf+GIRqtshXQRdMnF821PTZ4/QUB 28rLdMfPv07utAJCFKrjSYHzrqc7cfv8Av991+9YrsIarT3DpsEp6qwijGVX9a80lGRl SvWg== 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=qg+e2O0H9WsioRdDgWCYzvTng7LFE6we2RznhTrz2ws=; b=DoftUi0EG42kf6/eybeBfCT9TFs2Jaip7T0xavJTYW4xBulCH5TQJz4934UYmzCv36 WPzx5BYByMAf8F5sVpcsU4MXwHS7s0PfIIaS8GWgJ613QbdGACoRJkPvIw6acxXDQ4w/ gKvGfEB96SSP/Q2ToFk4dogHc2Lph7a73Izz7qKVO8l5BfNV6kYwYBg7ewjqC1PQAE2G ljZIUw47Oiea/5IOOczF6ny4PzOPz+ZdEdMM9mvbi8Npzh188RKc2Vxp8a3uerfmc5wH l/3vPP40jJWI1ONAbs0S278fWG931D1sKpFzr4TB115sNkjZN7KONGwrld3+XdDdyKC/ s0+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=BgcAbTBk; 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 h71-20020a63834a000000b004772ea50c14si9968307pge.171.2022.11.21.10.42.42; Mon, 21 Nov 2022 10:42:56 -0800 (PST) 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=BgcAbTBk; 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 S229806AbiKUSeA (ORCPT + 91 others); Mon, 21 Nov 2022 13:34:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229682AbiKUSd7 (ORCPT ); Mon, 21 Nov 2022 13:33:59 -0500 Received: from mail-yb1-xb2b.google.com (mail-yb1-xb2b.google.com [IPv6:2607:f8b0:4864:20::b2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC422C9026 for ; Mon, 21 Nov 2022 10:33:56 -0800 (PST) Received: by mail-yb1-xb2b.google.com with SMTP id 7so14574477ybp.13 for ; Mon, 21 Nov 2022 10:33:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=qg+e2O0H9WsioRdDgWCYzvTng7LFE6we2RznhTrz2ws=; b=BgcAbTBkUmbQyhNx3mRxuxNPych+Rkwd57U7c2CWZjgUTwsFkbwOTlnfj8SFjEK+Z5 XKKwkbnMdNN9i+PWrALNhZ4n1abMXnd8sYi8o7E+mWPrakYoJDzRy0yfL9RQy0cJW6Hb KXLguPyXXnGE/QshUwiBmN+AtC2kMzQZUJ6q3iWZr3/Mf93lTBqsJDMyNPlxYSZqdsoO nkocPx9qu6DEnC0c+Ckio5j+YNvna/M+t8fWB9erqvOyv/MFk647s7fvJ6QDGp3MIZj+ IL553LR4C6yl7wUx3v/sDQqm3VmkDMJ1Vp1uNJk+vLRtOEyW1vbQWS1XNgNEJO/+kVFd 6q/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=qg+e2O0H9WsioRdDgWCYzvTng7LFE6we2RznhTrz2ws=; b=0H82MAAj02oNMbu3SyV09ceUQJFgMvl+TTaJkscdJGQ/NeD6ao2qMTaPytUOz37+vA 8zUpLtQzZN+jLp+/7n13I8k+Rt6Atw7fuK8aTdGtVvIR4Xx2IKt3m3+Hk+mQJ0mJ1jW9 yyctsYfBRdnBUoS+JaI99OWHIjxuMsCP6jG6FDza4f3bPmMWzx06rW7VJorPDA0slVYa qBWi69tjW6gPQprBymhrpAlZZXDI05cxFGYWAq7ZFCncSvOYdhf3wC4/7VBxtFh8ldAw gRCeMXCUlJUN1b58Ufpt9VWiqmD9OWh0EWpQRzw1mdXlRg9MO21Elhtzj5HQ3WKc7eWM UTEA== X-Gm-Message-State: ANoB5pk8vQyH34AfK5Wkh0TeYPwzrlCbBtrWBfqmmRk5WTgHUhbF/ivh CrHYMy6/OBQF93jpbVUUe+XZ5WdRG+fj5KVFB2zrXg== X-Received: by 2002:a5b:505:0:b0:6cf:e605:7707 with SMTP id o5-20020a5b0505000000b006cfe6057707mr117675ybp.638.1669055635817; Mon, 21 Nov 2022 10:33:55 -0800 (PST) MIME-Version: 1.0 References: <20221021163703.3218176-1-jthoughton@google.com> <20221021163703.3218176-2-jthoughton@google.com> In-Reply-To: From: James Houghton Date: Mon, 21 Nov 2022 10:33:45 -0800 Message-ID: Subject: Re: [RFC PATCH v2 01/47] hugetlb: don't set PageUptodate for UFFDIO_CONTINUE To: Peter Xu 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 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 Wed, Nov 16, 2022 at 8:30 AM Peter Xu wrote: > > 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. Failing the ioctl sounds better than only WARNing. I'll do that and drop the WARN_ON_ONCE for v1. Thanks! - James > > > > > /* Add shared, newly allocated pages to the page cache. */ > > if (vm_shared && !is_continue) { > > -- > > 2.38.0.135.g90850a2211-goog > > > > > > -- > Peter Xu >