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: 13157956 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 4B32FC678D4 for ; Thu, 2 Mar 2023 22:24:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B3B066B0072; Thu, 2 Mar 2023 17:24:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AEB016B0073; Thu, 2 Mar 2023 17:24:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A016E6B0074; Thu, 2 Mar 2023 17:24:20 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 8EA936B0072 for ; Thu, 2 Mar 2023 17:24:20 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 45596A0378 for ; Thu, 2 Mar 2023 22:24:20 +0000 (UTC) X-FDA: 80525387880.13.6C0105A Received: from mail-ua1-f73.google.com (mail-ua1-f73.google.com [209.85.222.73]) by imf29.hostedemail.com (Postfix) with ESMTP id 9BA0F120011 for ; Thu, 2 Mar 2023 22:24:18 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=QwtuoBvQ; spf=pass (imf29.hostedemail.com: domain of 3ESIBZAoKCIAnxlsyklxsrksskpi.gsqpmry1-qqozego.svk@flex--jthoughton.bounces.google.com designates 209.85.222.73 as permitted sender) smtp.mailfrom=3ESIBZAoKCIAnxlsyklxsrksskpi.gsqpmry1-qqozego.svk@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=1677795858; 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: references:dkim-signature; bh=p/JMMuDjw3H8CXzuyUx8aTGbQPmUlzXe13PcSv0YCfA=; b=32n5xIAyF3O6badXwQcZ8mCGYUXCJCA/atDxOyWP27/kXHc8J2DrjJ6WTSslFmN/EcVkFS H/M7JWa5oRrZ3OgSjYV7GoBNZ68qzeHh6c98CKEUF74FB9tg1DjG9/nnQdkqPl3SlMnBen mKviGNZ2U/Fe8X9lnNBxUwrnR0dwvgM= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=QwtuoBvQ; spf=pass (imf29.hostedemail.com: domain of 3ESIBZAoKCIAnxlsyklxsrksskpi.gsqpmry1-qqozego.svk@flex--jthoughton.bounces.google.com designates 209.85.222.73 as permitted sender) smtp.mailfrom=3ESIBZAoKCIAnxlsyklxsrksskpi.gsqpmry1-qqozego.svk@flex--jthoughton.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677795858; a=rsa-sha256; cv=none; b=cw0+JAhHPCHjOSmGgzZZleCm15wmJ6jFkENGhlRxgAoI7kHTrFWL3WvblvhRpyEHNsCVC9 ZDqzBmqhzGmydiQOK+s6pOiiiA68j+8oQMW3x8L/C/4+mTDutBaEGe6KF1g4umXCH1IQ7N asS73f4rpaTcm+yC0NZQJXmDjtULd1U= Received: by mail-ua1-f73.google.com with SMTP id g34-20020ab059a5000000b0068fb77b4fccso269434uad.3 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=46qumEpBFxKaf3yNXizmhLxuVfPevp0aq9t4/ubwn8HXowtTgvyuOWVsYMfnO9clhD RQj03iCyUx9YCwJJljuzJLJP2letulcA8K9utEFseFmFMavVH2/8yQUDnZ7CtU0k4lM9 OzVE2OAm/NES0uyluMLbkUcgxuV/8BbMRTx3E/IJaOZygm4aN8Fwi8/VsnH+WD5QRw0o AcoAOcBQESxWMZvbvW9vy9/KVEjAcn5Xj4wWQn+538I2bG4UBfwmIMCYZihqyOI//kGS HhcEau/JS0mxUByGcVZh8JIq3fGENVkp1Yza/hHpcuQkMj+Ow5rcTtgmD78aMY8unYvk Bjzw== X-Gm-Message-State: AO0yUKVdh1HU3J4kBb/hM7DVMB9wdWoIOzDJGB87CNR65dJ6h3U8EyeB 7IZ9UNdZqcSYZRbWxz5svzECEj3iZsbDBT1E X-Google-Smtp-Source: AK7set+jM4FnUzOsiQZgYL+m6qqmD5EyS8XVoY3pBRGESuYSP0JXzthHQrD3igTCVn2odnvH4hP/WUYncqTEZm/o 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-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 9BA0F120011 X-Rspam-User: X-Stat-Signature: 1997hqahimhgudwedsm4qhpdjat9ocgq X-HE-Tag: 1677795858-710717 X-HE-Meta: U2FsdGVkX18Nelhpuxhrno3szGBa3JBGzFcK1D4Q8XxHWXvSyIFlQv/PNBMiXa8TTtdV4vbNPTzuM4Ku1mAMPmYRnqnYqOSZ3OEFv+ag/nReoO4HIeGrDCK79E8i3JgFNnUjZ6Q5Uh7oRELPQ+bGywITAWK3qySFEqjndf166bBeFzYrx6R1gp7nYqYj9Y8NnmaVJLjTvEp5VO8Bz9B5OLvPPXpzu2CWBLCEPFeaf51Qt90R7UnB5ubiGK+dowbY9ZJ5gEik09gT+ZYcZ0ctgyX48xrVG8K5fBmOr0Hmcx/9J+qA/wpcLQm7LrIR8ejuTkZ1vs/hvN8cXcKZL0Hrn/yK2AV6Fx8v3OWGKoBANT8L8oIeBArRqjshZffhHMI8BZj3VAwVNJ05iHEg99425m1iTPC0W1rKqWo1d9p6LbuQ8X3niGDz4RSSXy4IxAUb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7OWqDtcE+r+uG7uhr6SbSz2QEWtK/WZDhRInzBWuLJK8D8YB30c5TrrbxIheJ9cRCyYc6wttoo/iWzohsTZfFXPA7RCH0JmQ1FphGt4E7zCrzGjtSVJT5y8uZp4W/iyQSX4ejzPZTrv0TGAj/ofI2pK1Z56HSv+nx/901uCyVI6A X-Bogosity: Ham, tests=bogofilter, spamicity=0.002359, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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;