Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp238723rwl; Wed, 4 Jan 2023 18:28:47 -0800 (PST) X-Google-Smtp-Source: AMrXdXsu00pnP3bE1nBddcPWzNrh3IS9XsifeCS0gytuo7CJagZVcoZ+WG9zv6h9lyBxYMMeZkbI X-Received: by 2002:aa7:8f8c:0:b0:576:14a4:b76a with SMTP id t12-20020aa78f8c000000b0057614a4b76amr46393634pfs.34.1672885726986; Wed, 04 Jan 2023 18:28:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672885726; cv=none; d=google.com; s=arc-20160816; b=bU6tXDIls3un8ns9fZ8AMFDJZ+0UmwJJDNSd73EFukeUbbEPA79NgCxcIQyc5XjkF3 4rModjsDzO0V2DQjE12r4Qc3TgBpF2BI9YjFeLHBU7VFtx3adE6vaGE9WFSKkbWwsFiK CmU0LHWH3QMgj4unHUMV7GrOtovgINiKQ0ZvD5WIfYDcQVgNhBDjh77V9eO0QkXq/ckC /RcD4QVu2H8km83SzYRaZlpv3wEEBi8eSt/DEpAeYg1utZjcqXAC4kOQ9w9i0n0StiTM po8TEXvg+cbx58/git1BlCBFPKhlD0RT59FHFt9iW40Scgv5oykvkcJi62ezCrmiP+J5 mUZA== 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=yqfl4xJm+Wld0bPquuUz0o/yojxexveabYMG4JIRCRw=; b=y8M9nIkvNE3j6zoKAeuxUJSbwWwYd9RHXbzrBc7JbVJjUtdFoMKjf2sUGKnawQvynq CtFNeKh77v68GdaGVoFfYs9O4CnM3zjirkiE/KZ7fyuK7IRXT1UTrMvKVOk2gWTVOSHQ YuFT20yt4N+gbsZJGwE0UysVQhgnjm5LkvxLxrtT5izTt13z5HhtGUh7M/65oykyphjF 41Y8W+i34QSITvqWK72TwoVzOj44Tt8j2ym6HTbkU4CdC37yrn27XZX7z+7rZoDsXYx1 Piaa+lQOwM4C0VizWBsghsB1CaeHqGvpCGoFc2IiU8hqRxjdg98R01hCCDLOIhC74RXB Vz1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Qok5PnDt; 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 d4-20020a056a00244400b0056ec68563d6si38620814pfj.135.2023.01.04.18.28.38; Wed, 04 Jan 2023 18:28:46 -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=Qok5PnDt; 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 S229759AbjAEBvB (ORCPT + 56 others); Wed, 4 Jan 2023 20:51:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229662AbjAEBu7 (ORCPT ); Wed, 4 Jan 2023 20:50:59 -0500 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1ACCA33F for ; Wed, 4 Jan 2023 17:50:57 -0800 (PST) Received: by mail-wm1-x334.google.com with SMTP id ay2-20020a05600c1e0200b003d22e3e796dso292098wmb.0 for ; Wed, 04 Jan 2023 17:50:57 -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=yqfl4xJm+Wld0bPquuUz0o/yojxexveabYMG4JIRCRw=; b=Qok5PnDts10sjUXsNh9QcIsGF42bksh+y/PzDySJHxG0qPjMJGnjJu0D2IBu9Ljw0S bKWr6Oqgz24nXkftP02bkHPGE8PGfIlchPKVTQnioZ97vJ913mBvaoPzir/3gmdnj6S6 p0ml9kjP1sgAvonF5uWIf39mt9iE4GT9DeJ4WxTIHqdXOXm6zVA8Y4SKKWQ3qHgdfGJ6 6yGt7L2qZyt+ECDwFtr8DARAUHVnH2qTtZKmiwW33+gJILmfie2jXi7MtqyWDrpEpz0k sS6J6yd414UxQsb2UE8WdLl74rUmPEEv7VskJ2+2+kzkNqcLSXHpt/wxBVa0neVubM2o SQQw== 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=yqfl4xJm+Wld0bPquuUz0o/yojxexveabYMG4JIRCRw=; b=qoSxpEn7nS2g2fGH5Ou+D779W5A1O4jEiwHP2f8hRGsGISNmiQIVnjwms/4OeH/7c8 Ewy4/le9e1k02/9vtjOtRk+A1iZgXj9KtSD2bhYfRNZ9k2tk4jk6tAqB6BQl3S4ciFej fMYpm5hv03783JBy5OCDvPQEOa0PBS1fLLxyrVg1QtursbwRbvjrGStbKOSBTXA1g6/1 okg3P3ftLqoG4e6HHk/0HPlwyTYmI1xLTNJXiZ75i2jb5jUvOGP6ZOMh1pWO3py75+zH dN32DkfBwaaieEhLKGeCy1C7Kxe7KBs6nSZ/CjYIrANKJLQ9HAgkg1BTf8+n5lg6UiDn VLIw== X-Gm-Message-State: AFqh2krGPaDG1FnXuObFfIeaIB3c9RKTYk/ZDbo2eDn4vBXdUzNdU1j7 d85B5S+5bZp7bahtJxvb1tJsxT8ZhUaC+R2kH3wvgw== X-Received: by 2002:a05:600c:4b95:b0:3d1:da8c:7869 with SMTP id e21-20020a05600c4b9500b003d1da8c7869mr2632215wmp.26.1672883455586; Wed, 04 Jan 2023 17:50:55 -0800 (PST) MIME-Version: 1.0 References: <20230104225207.1066932-1-peterx@redhat.com> <20230104225207.1066932-2-peterx@redhat.com> In-Reply-To: <20230104225207.1066932-2-peterx@redhat.com> From: James Houghton Date: Thu, 5 Jan 2023 01:50:42 +0000 Message-ID: Subject: Re: [PATCH 1/3] mm/hugetlb: Pre-allocate pgtable pages for uffd wr-protects To: Peter Xu Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Mike Kravetz , Muchun Song , Nadav Amit , Andrea Arcangeli , David Hildenbrand , Axel Rasmussen , Andrew Morton , linux-stable 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, Jan 4, 2023 at 10:52 PM Peter Xu wrote: > > Userfaultfd-wp uses pte markers to mark wr-protected pages for both shmem > and hugetlb. Shmem has pre-allocation ready for markers, but hugetlb path > was overlooked. > > Doing so by calling huge_pte_alloc() if the initial pgtable walk fails to > find the huge ptep. It's possible that huge_pte_alloc() can fail with high > memory pressure, in that case stop the loop immediately and fail silently. > This is not the most ideal solution but it matches with what we do with > shmem meanwhile it avoids the splat in dmesg. > > Cc: linux-stable # 5.19+ > Fixes: 60dfaad65aa9 ("mm/hugetlb: allow uffd wr-protect none ptes") > Reported-by: James Houghton > Signed-off-by: Peter Xu > --- > mm/hugetlb.c | 13 +++++++++++-- > 1 file changed, 11 insertions(+), 2 deletions(-) Acked-by: James Houghton