From patchwork Thu Mar 2 22:24:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Houghton X-Patchwork-Id: 63617 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp100229wrd; Thu, 2 Mar 2023 14:27:25 -0800 (PST) X-Google-Smtp-Source: AK7set/GBvBOyRshdxt/hfagrmV5pVIR1kcPoNpvkSFKAxTDu8r7reZXY2riG1ia92gS+WOXXtOR X-Received: by 2002:aa7:c9cb:0:b0:4ac:bda8:32a4 with SMTP id i11-20020aa7c9cb000000b004acbda832a4mr12885461edt.1.1677796045420; Thu, 02 Mar 2023 14:27:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677796045; cv=none; d=google.com; s=arc-20160816; b=DycdQVyyPbb/15u7PzocP+YxDGf4uTbpIkWTiV2u+NNF2eB26NTqUIcCghh0n7lFuw yY80nR6Nu1/VAo1N4TPJFZQ4VN18FF1e+j+y38Hy7Qa+DWqnIn/cow7EdmDuiWLvaSKD W2WjD7nrN/nLS3qaBoCL3sPvrcVnrVR0hD0w7zbIu4tIPAjAJpDO1Bv4ElfL91DjDepy ozkMNk55hm/2PDuDzIGm6T8sTjlxHT7QrK5YdFo888v0eqhZgZPUuebg41oc+XsJpnQS ZxCtLVnI5tMk8n5f3sEPMRauZ25lZnCoGGbePBtoBYk7bVCWWQIN2iDy+o2LEtVW7Tov dxJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:mime-version:date :dkim-signature; bh=p/JMMuDjw3H8CXzuyUx8aTGbQPmUlzXe13PcSv0YCfA=; b=BKCpygkSxWYbcerqZqHjHbq9IKBfLSA0eZGG2PW3OlI7cJalsiWDH1ro2DRCrtFER+ ZcJ6aeT74MTkDv2EsmrD8D0DXyhU4S1/yuOcy+hyhxM3MYj66bBOnz8PynH9jV5ybV6L lA1DTC0Nu4RWCQc/Ig9U1iJoHfLIH1B9JAF+450TnR+6ZoH9q5RWFcHGQqA0dnrZhSmB 40aoEdmENndHNE6YrZMX1WlYhHR0QqRsDv9XeqBUUOT9I7M53CA7Qe213F2S/yIG2MPb WhN30pI/Z4+pHyluaTgdDpgODwOxn49DBho//dJ0wpd20PIri5sTjgXq6js9JaLn9oeT o0nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=QwtuoBvQ; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p9-20020a056402074900b004bb85968255si698021edy.349.2023.03.02.14.26.59; Thu, 02 Mar 2023 14:27:25 -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=QwtuoBvQ; 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 S229788AbjCBWYV (ORCPT + 99 others); Thu, 2 Mar 2023 17:24:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229642AbjCBWYT (ORCPT ); Thu, 2 Mar 2023 17:24:19 -0500 Received: from mail-ua1-x949.google.com (mail-ua1-x949.google.com [IPv6:2607:f8b0:4864:20::949]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A5CB15143 for ; Thu, 2 Mar 2023 14:24:18 -0800 (PST) Received: by mail-ua1-x949.google.com with SMTP id g27-20020ab05fdb000000b0068ffe2ec956so240294uaj.18 for ; Thu, 02 Mar 2023 14:24:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1677795857; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=p/JMMuDjw3H8CXzuyUx8aTGbQPmUlzXe13PcSv0YCfA=; b=QwtuoBvQNsXjDF/5E0s2kkJBbQ7N49ADAjWzU3BQXBopWQfnrTRLV6Z27JDOp6F5HB KQDTPH0Az27+IuYaiI1PnvtwbnfX1xp2V/WIXY9jtVrW81TkyehvTbjngvholMVC6bYw aXNIbkpRqujqfrWNdj3CeyzPnH3lcE6M202ox8JoOqbXk5FnwxEzPf3mWnw06gwYe+0t TOB3hVaZRJnAAfhdTBOQB08H6bDIkashLN7H4FaXTKBss6G6pFjmVE7V0iKJZdXWr5bS 8taEkfzuDL2mp8mFxDS2vdSt1ZJItRkZOTrHSWy4SlA8jwTE7IwUcgdpzQwmwOoH3675 90XQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677795857; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=p/JMMuDjw3H8CXzuyUx8aTGbQPmUlzXe13PcSv0YCfA=; b=N+y04xlX+A0Pd84670TVcD4P4R37W7G2MgZR+wrvjXWEU4wj97wnAijzy1NSfGSEBo kmx3+QAbQ5p/Y6Zcw6s/DDcPgqDuLYk9+9FYPLRxlqFyrFr2qKd7eCiORkg1FVn1T519 GiXZC3Q5cCorNewY4pUbAwVET3ukT87byO++uxnlDq7sLWs4qN8NVynTXpwjp05/BzNn Zc7DTnIinDRjY5G7cYDtoI3V15q/ZkmHB/b3ZdFF0U+NRv5jlKQy1XMBLQMqTixukAwj HjXeTZWiey3ATleq8vy1v4vTxH7QWeQeaM6h96XzY7OPoiqZ2yhokKnqltcTWfCPkrb7 8rmQ== X-Gm-Message-State: AO0yUKXWXPqAOGywWhK9IXE+t7xjuiTWYxSvqq0gfhUnMK2a4V0jKeC+ hIX95Eo7ttBb2xxYjrwYFv09R97edenSz1dQ X-Received: from jthoughton.c.googlers.com ([fda3:e722:ac3:cc00:14:4d90:c0a8:2a4f]) (user=jthoughton job=sendgmr) by 2002:ab0:4ad5:0:b0:68b:90f4:1d8c with SMTP id t21-20020ab04ad5000000b0068b90f41d8cmr6973689uae.1.1677795857710; Thu, 02 Mar 2023 14:24:17 -0800 (PST) Date: Thu, 2 Mar 2023 22:24:04 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.40.0.rc0.216.gc4246ad0f0-goog Message-ID: <20230302222404.175303-1-jthoughton@google.com> Subject: [PATCH] mm: teach mincore_hugetlb about pte markers From: James Houghton To: Peter Xu , Andrew Morton Cc: David Hildenbrand , Axel Rasmussen , Anish Moorthy , linux-mm@kvack.org, linux-kernel@vger.kernel.org, James Houghton X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759296666201445553?= X-GMAIL-MSGID: =?utf-8?q?1759296666201445553?= By checking huge_pte_none(), we incorrectly classify PTE markers as "present". Instead, check huge_pte_none_mostly(), classifying PTE markers the same as if the PTE were completely blank. PTE markers, unlike other kinds of swap entries, don't reference any physical page and don't indicate that a physical page was mapped previously. As such, treat them as non-present for the sake of mincore(). Fixes: 5c041f5d1f23 ("mm: teach core mm about pte markers") Signed-off-by: James Houghton Acked-by: Peter Xu Acked-by: David Hildenbrand --- mm/mincore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/mincore.c b/mm/mincore.c index cd69b9db0081..d359650b0f75 100644 --- a/mm/mincore.c +++ b/mm/mincore.c @@ -33,7 +33,7 @@ static int mincore_hugetlb(pte_t *pte, unsigned long hmask, unsigned long addr, * Hugepages under user process are always in RAM and never * swapped out, but theoretically it needs to be checked. */ - present = pte && !huge_pte_none(huge_ptep_get(pte)); + present = pte && !huge_pte_none_mostly(huge_ptep_get(pte)); for (; addr != end; vec++, addr += PAGE_SIZE) *vec = present; walk->private = vec;